Bug 1362889 - Ensure the MockContentController in APZ GTests doesn't outlive the test fixture. r=kats, a=test-only
authorBotond Ballo <botond@mozilla.com>
Mon, 08 May 2017 17:13:17 -0400
changeset 578480 68e0c0279f72f7fbd83c9a3aa11775dd2fa34679
parent 578479 5e85bc599d0c94f0ba792c9505081ba6486f7557
child 578481 d893dea8e7b47beccc6bfddcfc8a2866e77ea908
push id58939
push userbmo:cku@mozilla.com
push dateTue, 16 May 2017 04:17:59 +0000
reviewerskats, test-only
bugs1362889
milestone52.1.2
Bug 1362889 - Ensure the MockContentController in APZ GTests doesn't outlive the test fixture. r=kats, a=test-only MozReview-Commit-ID: AuSC5w1FXWG
gfx/layers/apz/test/gtest/APZCBasicTester.h
gfx/layers/apz/test/gtest/APZCTreeManagerTester.h
gfx/layers/apz/test/gtest/APZTestCommon.h
--- a/gfx/layers/apz/test/gtest/APZCBasicTester.h
+++ b/gfx/layers/apz/test/gtest/APZCBasicTester.h
@@ -44,16 +44,17 @@ protected:
         metrics.GetScrollableRect().Size() - metrics.CalculateCompositedSizeInCssPixels());
   }
 
   virtual void TearDown()
   {
     while (mcc->RunThroughDelayedTasks());
     apzc->Destroy();
     tm->ClearTree();
+    tm->ClearContentController();
   }
 
   void MakeApzcWaitForMainThread()
   {
     apzc->SetWaitForMainThread();
   }
 
   void MakeApzcZoomable()
--- a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h
+++ b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h
@@ -24,16 +24,17 @@ protected:
     APZThreadUtils::SetControllerThread(MessageLoop::current());
 
     manager = new TestAPZCTreeManager(mcc);
   }
 
   virtual void TearDown() {
     while (mcc->RunThroughDelayedTasks());
     manager->ClearTree();
+    manager->ClearContentController();
   }
 
   /**
    * Sample animations once for all APZCs, 1 ms later than the last sample.
    */
   void SampleAnimationsOnce() {
     const TimeDuration increment = TimeDuration::FromMilliseconds(1);
     ParentLayerPoint pointOut;
--- a/gfx/layers/apz/test/gtest/APZTestCommon.h
+++ b/gfx/layers/apz/test/gtest/APZTestCommon.h
@@ -169,16 +169,20 @@ private:
 class TestAPZCTreeManager : public APZCTreeManager {
 public:
   explicit TestAPZCTreeManager(MockContentControllerDelayed* aMcc) : mcc(aMcc) {}
 
   RefPtr<InputQueue> GetInputQueue() const {
     return mInputQueue;
   }
 
+  void ClearContentController() {
+    mcc = nullptr;
+  }
+
 protected:
   AsyncPanZoomController* NewAPZCInstance(uint64_t aLayersId,
                                           GeckoContentController* aController) override;
 
   TimeStamp GetFrameTime() override {
     return mcc->Time();
   }