Bug 1062437 - Test APZC tree structure in gtest for multi-layer-apz. r=kats, a=bajaj
authorBotond Ballo <botond@mozilla.com>
Thu, 04 Sep 2014 14:43:31 -0400
changeset 224681 13685d3640ffc300d242a15a091de8f5dc375a1d
parent 224680 a0de2057c32aae223557cd5eab2af92f46f47e9c
child 224682 09e070cb6917b1cccab2ac0ce874468ef51d7f6d
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, bajaj
bugs1062437
milestone34.0a2
Bug 1062437 - Test APZC tree structure in gtest for multi-layer-apz. r=kats, a=bajaj
gfx/tests/gtest/TestAsyncPanZoomController.cpp
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -1455,36 +1455,38 @@ protected:
     root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers);
 
     SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 200, 200));
     SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 80, 80));
     SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 2, CSSRect(0, 0, 80, 80));
   }
 
   void CreateComplexMultiLayerTree() {
-    const char* layerTreeSyntax = "c(tc(t)tc(c(t)t))";
-    // LayerID                     0 12 3 45 6 7 8
+    const char* layerTreeSyntax = "c(tc(t)tc(c(t)tt))";
+    // LayerID                     0 12 3 45 6 7 89
     nsIntRegion layerVisibleRegion[] = {
       nsIntRegion(nsIntRect(0,0,300,400)),      // root(0)
       nsIntRegion(nsIntRect(0,0,100,100)),      // thebes(1) in top-left
       nsIntRegion(nsIntRect(50,50,200,300)),    // container(2) centered in root(0)
       nsIntRegion(nsIntRect(50,50,200,300)),    // thebes(3) fully occupying parent container(2)
       nsIntRegion(nsIntRect(0,200,100,100)),    // thebes(4) in bottom-left
       nsIntRegion(nsIntRect(200,0,100,400)),    // container(5) along the right 100px of root(0)
       nsIntRegion(nsIntRect(200,0,100,200)),    // container(6) taking up the top half of parent container(5)
       nsIntRegion(nsIntRect(200,0,100,200)),    // thebes(7) fully occupying parent container(6)
-      nsIntRegion(nsIntRect(200,200,100,200)),  // thebes(8) in bottom-right
+      nsIntRegion(nsIntRect(200,200,100,100)),  // thebes(8) in bottom-right (below (6))
+      nsIntRegion(nsIntRect(200,300,100,100)),  // thebes(9) in bottom-right (below (8))
     };
     root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, nullptr, lm, layers);
     SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID);
     SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID);
     SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 1);
     SetScrollableFrameMetrics(layers[6], FrameMetrics::START_SCROLL_ID + 1);
     SetScrollableFrameMetrics(layers[7], FrameMetrics::START_SCROLL_ID + 2);
-    SetScrollableFrameMetrics(layers[8], FrameMetrics::START_SCROLL_ID + 3);
+    SetScrollableFrameMetrics(layers[8], FrameMetrics::START_SCROLL_ID + 1);
+    SetScrollableFrameMetrics(layers[9], FrameMetrics::START_SCROLL_ID + 3);
   }
 };
 
 // A simple hit testing test that doesn't involve any transforms on layers.
 TEST_F(APZHitTestingTester, HitTesting1) {
   CreateHitTesting1LayerTree();
   ScopedLayerTreeRegistration registration(0, root, mcc);
 
@@ -1704,31 +1706,47 @@ TEST_F(APZHitTestingTester, ComplexMulti
   EXPECT_NE(nullAPZC, ApzcOf(layers[1]));
   EXPECT_NE(nullAPZC, ApzcOf(layers[2]));
   EXPECT_FALSE(layers[3]->HasScrollableFrameMetrics());
   EXPECT_NE(nullAPZC, ApzcOf(layers[4]));
   EXPECT_FALSE(layers[5]->HasScrollableFrameMetrics());
   EXPECT_NE(nullAPZC, ApzcOf(layers[6]));
   EXPECT_NE(nullAPZC, ApzcOf(layers[7]));
   EXPECT_NE(nullAPZC, ApzcOf(layers[8]));
+  EXPECT_NE(nullAPZC, ApzcOf(layers[9]));
   // Ensure those that scroll together have the same APZCs
   EXPECT_EQ(ApzcOf(layers[1]), ApzcOf(layers[2]));
   EXPECT_EQ(ApzcOf(layers[4]), ApzcOf(layers[6]));
+  EXPECT_EQ(ApzcOf(layers[8]), ApzcOf(layers[6]));
   // Ensure those that don't scroll together have different APZCs
   EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[4]));
   EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[7]));
-  EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[8]));
+  EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[9]));
   EXPECT_NE(ApzcOf(layers[4]), ApzcOf(layers[7]));
-  EXPECT_NE(ApzcOf(layers[4]), ApzcOf(layers[8]));
-  EXPECT_NE(ApzcOf(layers[7]), ApzcOf(layers[8]));
+  EXPECT_NE(ApzcOf(layers[4]), ApzcOf(layers[9]));
+  EXPECT_NE(ApzcOf(layers[7]), ApzcOf(layers[9]));
+
+  // Ensure the shape of the APZC tree is as expected
+  AsyncPanZoomController* layers1_2 = ApzcOf(layers[1]);
+  AsyncPanZoomController* layers4_6_8 = ApzcOf(layers[4]);
+  AsyncPanZoomController* layer7 = ApzcOf(layers[7]);
+  AsyncPanZoomController* layer9 = ApzcOf(layers[9]);
+  EXPECT_EQ(nullptr, layers1_2->GetParent());
+  EXPECT_EQ(nullptr, layers4_6_8->GetParent());
+  EXPECT_EQ(layers4_6_8, layer7->GetParent());
+  EXPECT_EQ(nullptr, layer9->GetParent());
+  EXPECT_EQ(nullptr, layers1_2->GetPrevSibling());
+  EXPECT_EQ(layers1_2, layers4_6_8->GetPrevSibling());
+  EXPECT_EQ(nullptr, layer7->GetPrevSibling());
+  EXPECT_EQ(layers4_6_8, layer9->GetPrevSibling());
 
   nsRefPtr<AsyncPanZoomController> hit = GetTargetAPZC(ScreenPoint(25, 25));
   EXPECT_EQ(ApzcOf(layers[1]), hit.get());
   hit = GetTargetAPZC(ScreenPoint(275, 375));
-  EXPECT_EQ(ApzcOf(layers[8]), hit.get());
+  EXPECT_EQ(ApzcOf(layers[9]), hit.get());
   hit = GetTargetAPZC(ScreenPoint(250, 100));
   EXPECT_EQ(ApzcOf(layers[7]), hit.get());
 }
 
 class APZOverscrollHandoffTester : public APZCTreeManagerTester {
 protected:
   UniquePtr<ScopedLayerTreeRegistration> registration;
   TestAsyncPanZoomController* rootApzc;