713
715 OCMStub([engineMock
renderer]).andReturn(renderer_);
716 __block bool called = false;
719 .andDo((^(NSInvocation* invocation) {
721 [invocation getArgument:&event atIndex:2];
722 called = true;
724 }));
725
727 nibName:@""
728 bundle:nil];
730
731
732
733 CGEventRef cgEventStart = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
734 CGEventSetType(cgEventStart, kCGEventScrollWheel);
735 CGEventSetIntegerValueField(cgEventStart, kCGScrollWheelEventScrollPhase, kCGScrollPhaseBegan);
736 CGEventSetIntegerValueField(cgEventStart, kCGScrollWheelEventIsContinuous, 1);
737
738 called = false;
739 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventStart]];
745
746
747 CGEventRef cgEventUpdate = CGEventCreateCopy(cgEventStart);
748 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventScrollPhase, kCGScrollPhaseChanged);
749 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventDeltaAxis2, 1);
750 CGEventSetIntegerValueField(cgEventUpdate, kCGScrollWheelEventDeltaAxis1, 2);
751
752 called = false;
753 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventUpdate]];
761
762
763 called = false;
764 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventUpdate]];
772
773
774 CGEventRef cgEventEnd = CGEventCreateCopy(cgEventStart);
775 CGEventSetIntegerValueField(cgEventEnd, kCGScrollWheelEventScrollPhase, kCGScrollPhaseEnded);
776
777 called = false;
778 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventEnd]];
784
785
786 CGEventRef cgEventMomentumStart = CGEventCreateCopy(cgEventStart);
787 CGEventSetIntegerValueField(cgEventMomentumStart, kCGScrollWheelEventScrollPhase, 0);
788 CGEventSetIntegerValueField(cgEventMomentumStart, kCGScrollWheelEventMomentumPhase,
789 kCGMomentumScrollPhaseBegin);
790
791 called = false;
792 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumStart]];
793 EXPECT_FALSE(called);
794
795
796 CGEventRef cgEventMomentumUpdate = CGEventCreateCopy(cgEventStart);
797 CGEventSetIntegerValueField(cgEventMomentumUpdate, kCGScrollWheelEventScrollPhase, 0);
798 CGEventSetIntegerValueField(cgEventMomentumUpdate, kCGScrollWheelEventMomentumPhase,
799 kCGMomentumScrollPhaseContinue);
800
801 called = false;
802 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumUpdate]];
803 EXPECT_FALSE(called);
804
805
806 id touchMock = OCMClassMock([NSTouch class]);
807 NSSet* touchSet = [NSSet setWithObject:touchMock];
808 id touchEventMock1 = OCMClassMock([NSEvent class]);
809 OCMStub([touchEventMock1 allTouches]).andReturn(touchSet);
810 CGPoint touchLocation = {0, 0};
811 OCMStub([touchEventMock1 locationInWindow]).andReturn(touchLocation);
812 OCMStub([(NSEvent*)touchEventMock1 timestamp]).andReturn(0.150);
813
814
815 called = false;
817 EXPECT_FALSE(called);
818
819
820 id touchEventMock2 = OCMClassMock([NSEvent class]);
821 OCMStub([touchEventMock2 allTouches]).andReturn(touchSet);
822 OCMStub([touchEventMock2 locationInWindow]).andReturn(touchLocation);
823 OCMStub([(NSEvent*)touchEventMock2 timestamp]).andReturn(0.005);
824
825
826 called = false;
831
832
833 CGEventRef cgEventMomentumEnd = CGEventCreateCopy(cgEventStart);
834 CGEventSetIntegerValueField(cgEventMomentumEnd, kCGScrollWheelEventScrollPhase, 0);
835 CGEventSetIntegerValueField(cgEventMomentumEnd, kCGScrollWheelEventMomentumPhase,
836 kCGMomentumScrollPhaseEnd);
837
838 called = false;
839 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventMomentumEnd]];
840 EXPECT_FALSE(called);
841
842
843 CGEventRef cgEventMayBegin = CGEventCreateCopy(cgEventStart);
844 CGEventSetIntegerValueField(cgEventMayBegin, kCGScrollWheelEventScrollPhase,
845 kCGScrollPhaseMayBegin);
846
847 called = false;
848 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventMayBegin]];
854
855
856 CGEventRef cgEventCancel = CGEventCreateCopy(cgEventStart);
857 CGEventSetIntegerValueField(cgEventCancel, kCGScrollWheelEventScrollPhase,
858 kCGScrollPhaseCancelled);
859
860 called = false;
861 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventCancel]];
867
868
869 CGEventRef cgEventDiscrete = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
870 CGEventSetType(cgEventDiscrete, kCGEventScrollWheel);
871 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventIsContinuous, 0);
872 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventDeltaAxis2, 1);
873 CGEventSetIntegerValueField(cgEventDiscrete, kCGScrollWheelEventDeltaAxis1, 2);
874
875 called = false;
876 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventDiscrete]];
879
882
883
884
885 CGEventRef cgEventDiscreteShift =
886 CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
887 CGEventSetType(cgEventDiscreteShift, kCGEventScrollWheel);
889 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventIsContinuous, 0);
890 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventDeltaAxis2,
891 0);
892 CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventDeltaAxis1,
893 2);
894
895 called = false;
896 [viewController
scrollWheel:[NSEvent eventWithCGEvent:cgEventDiscreteShift]];
899
901 EXPECT_FLOAT_EQ(last_event.scroll_delta_y,
903
904
905
906 called = false;
907 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
908 NSEventPhaseBegan, 1, 0)];
914
915
916 called = false;
917 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
918 NSEventPhaseChanged, 1, 0)];
924 EXPECT_EQ(last_event.pan_x, 0);
925 EXPECT_EQ(last_event.pan_y, 0);
926 EXPECT_EQ(last_event.scale, 2);
927
928 EXPECT_EQ(last_event.rotation, 0);
929
930
931 called = false;
932 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
933 NSEventPhaseChanged, 1, 0)];
939 EXPECT_EQ(last_event.pan_x, 0);
940 EXPECT_EQ(last_event.pan_y, 0);
941 EXPECT_EQ(last_event.scale, 4);
942
943 EXPECT_EQ(last_event.rotation, 0);
944
945
946 called = false;
947 [viewController magnifyWithEvent:flutter::testing::MockGestureEvent(NSEventTypeMagnify,
948 NSEventPhaseEnded, 0, 0)];
954
955
956
957 called = false;
958 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(NSEventTypeRotate,
959 NSEventPhaseBegan, 1, 0)];
965
966
967 called = false;
968 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(
969 NSEventTypeRotate, NSEventPhaseChanged, 0, -180)];
975 EXPECT_EQ(last_event.pan_x, 0);
976 EXPECT_EQ(last_event.pan_y, 0);
977 EXPECT_EQ(last_event.scale, 1);
978 EXPECT_EQ(last_event.rotation,
M_PI);
979
980
981 called = false;
982 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(
983 NSEventTypeRotate, NSEventPhaseChanged, 0, -360)];
989 EXPECT_EQ(last_event.pan_x, 0);
990 EXPECT_EQ(last_event.pan_y, 0);
991 EXPECT_EQ(last_event.scale, 1);
992 EXPECT_EQ(last_event.rotation, 3 *
M_PI);
993
994
995 called = false;
996 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(NSEventTypeRotate,
997 NSEventPhaseEnded, 0, 0)];
1003
1004
1005 called = false;
1006 [viewController rotateWithEvent:flutter::testing::MockGestureEvent(NSEventTypeRotate,
1007 NSEventPhaseCancelled, 0, 0)];
1008 EXPECT_FALSE(called);
1009
1010 return true;
1011}
@ kPanZoomUpdate
The pan/zoom updated.
@ kPanZoomStart
A pan/zoom started on this pointer.
@ kPanZoomEnd
The pan/zoom ended.
@ kFlutterPointerSignalKindScrollInertiaCancel
@ kFlutterPointerSignalKindScroll
@ kFlutterPointerSignalKindNone
@ kFlutterPointerDeviceKindTrackpad
FlutterView * flutterView
void touchesBeganWithEvent:(NSEvent *event)