OSDN Git Service

SF: Fix for a leaked mock reported in processesVirtualDisplayAdded
authorLloyd Pique <lpique@google.com>
Wed, 27 Feb 2019 00:26:09 +0000 (16:26 -0800)
committerLloyd Pique <lpique@google.com>
Thu, 28 Feb 2019 23:53:16 +0000 (15:53 -0800)
I'm not sure why it only started being reported  recently, but removing
the injected virtual display from the SurfaceFlinger current/drawing
state fixes the leak.

Bug: None
Test: adb shell libsurfaceflinger_unittest
Change-Id: Ibaf1a8878e296707b9fbbd0a647908cc1205cdc2

services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp

index 1487d47..9bf29a2 100644 (file)
@@ -1926,6 +1926,10 @@ TEST_F(HandleTransactionLockedTest, processesVirtualDisplayAdded) {
     EXPECT_CALL(*mComposer, destroyVirtualDisplay(Case::Display::HWC_DISPLAY_ID))
             .WillOnce(Return(Error::NONE));
     EXPECT_CALL(*mConsumer, consumerDisconnect()).WillOnce(Return(NO_ERROR));
+
+    // Cleanup
+    mFlinger.mutableCurrentState().displays.removeItem(displayToken);
+    mFlinger.mutableDrawingState().displays.removeItem(displayToken);
 }
 
 TEST_F(HandleTransactionLockedTest, processesVirtualDisplayAddedWithNoSurface) {