Bug 996457 - Make apzc's LongPressPreventDefault test consider the touch action property. r=kats
authorMaksim Lebedev <alessarik@gmail.com>
Mon, 21 Apr 2014 11:30:15 -0400
changeset 197897 dcc3ce7fcd23ffb3c9d281edd91a7c7939191284
parent 197896 aaf8037b9e0f2ffdec6ae5ecbbe49be06cdc7ca0
child 197898 a0daa735e86571693584755f2b4badd67ce3a2d3
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs996457
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 996457 - Make apzc's LongPressPreventDefault test consider the touch action property. r=kats
gfx/tests/gtest/TestAsyncPanZoomController.cpp
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -808,43 +808,51 @@ DoLongPressTest(bool aShouldUseTouchActi
   // mechanism.
   check.Call("preHandleLongTapUp");
   apzc->ContentReceivedTouch(false);
   check.Call("postHandleLongTapUp");
 
   apzc->Destroy();
 }
 
-TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefault) {
+void
+DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
   // We have to initialize both an integer time and TimeStamp time because
   // TimeStamp doesn't have any ToXXX() functions for converting back to
   // primitives.
   TimeStamp testStartTime = TimeStamp::Now();
   int time = 0;
   AsyncPanZoomController::SetFrameTime(testStartTime);
 
   nsRefPtr<MockContentControllerDelayed> mcc = new MockContentControllerDelayed();
   nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
   nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(
     0, mcc, tm, AsyncPanZoomController::USE_GESTURE_DETECTOR);
 
   apzc->SetFrameMetrics(TestFrameMetrics());
   apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
   apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
 
+  apzc->SetTouchActionEnabled(aShouldUseTouchAction);
+
   EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(0);
   EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
 
   int touchX = 10,
       touchStartY = 10,
       touchEndY = 50;
 
   nsEventStatus status = ApzcDown(apzc, touchX, touchStartY, time);
   EXPECT_EQ(nsEventStatus_eConsumeNoDefault, status);
 
+  // SetAllowedTouchBehavior() must be called after sending touch-start.
+  nsTArray<uint32_t> allowedTouchBehaviors;
+  allowedTouchBehaviors.AppendElement(aBehavior);
+  apzc->SetAllowedTouchBehavior(allowedTouchBehaviors);
+
   MockFunction<void(std::string checkPointName)> check;
 
   {
     InSequence s;
 
     EXPECT_CALL(check, Call("preHandleLongTap"));
     EXPECT_CALL(*mcc, HandleLongTap(CSSPoint(touchX, touchStartY), 0, apzc->GetGuid())).Times(1);
     EXPECT_CALL(check, Call("postHandleLongTap"));
@@ -890,22 +898,31 @@ TEST_F(AsyncPanZoomControllerTester, Lon
 
   apzc->Destroy();
 }
 
 TEST_F(AsyncPanZoomControllerTester, LongPress) {
   DoLongPressTest(false, mozilla::layers::AllowedTouchBehavior::NONE);
 }
 
-TEST_F(AsyncPanZoomControllerTester, LongPressPanAndZoom) {
+TEST_F(AsyncPanZoomControllerTester, LongPressWithTouchAction) {
   DoLongPressTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
                       | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
                       | mozilla::layers::AllowedTouchBehavior::ZOOM);
 }
 
+TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefault) {
+  DoLongPressPreventDefaultTest(false, mozilla::layers::AllowedTouchBehavior::NONE);
+}
+
+TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefaultWithTouchAction) {
+  DoLongPressPreventDefaultTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
+                                    | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
+                                    | mozilla::layers::AllowedTouchBehavior::ZOOM);
+}
 
 // Layer tree for HitTesting1
 static already_AddRefed<mozilla::layers::Layer>
 CreateTestLayerTree1(nsRefPtr<LayerManager>& aLayerManager, nsTArray<nsRefPtr<Layer> >& aLayers) {
   const char* layerTreeSyntax = "c(ttcc)";
   // LayerID                     0 1234
   nsIntRegion layerVisibleRegion[] = {
     nsIntRegion(nsIntRect(0,0,100,100)),