| Index: ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc | 
| diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc | 
| index 761438ef80b04ab81fe117e4ee9623ddb52c4153..eb4f0914bf9b01e3c81158d332afc04b54dcdc78 100644 | 
| --- a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc | 
| +++ b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc | 
| @@ -273,10 +273,92 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterRemoveCrtc) { | 
| owned_plane = plane; | 
| ASSERT_TRUE(owned_plane != nullptr); | 
| EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | 
| -  // Removing the crtc should free the plane. | 
| +  // Removing the crtc should not free the plane or change ownership. | 
| scoped_ptr<ui::CrtcController> crtc = | 
| controller_->RemoveCrtc(drm_, kPrimaryCrtc); | 
| +  EXPECT_TRUE(owned_plane->in_use()); | 
| +  EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | 
| +  // Check that controller doesn't effect the state of removed plane in | 
| +  // subsequent page flip. | 
| +  EXPECT_TRUE(controller_->SchedulePageFlip( | 
| +      planes, false, false, | 
| +      base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 
| +                 base::Unretained(this)))); | 
| +  drm_->RunCallbacks(); | 
| +  EXPECT_TRUE(owned_plane->in_use()); | 
| +  EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | 
| +} | 
| + | 
| +TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) { | 
| +  ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 
| +      new MockScanoutBuffer(kDefaultModeSize))); | 
| +  EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | 
| +  std::vector<ui::OverlayPlane> planes = | 
| +      std::vector<ui::OverlayPlane>(1, plane1); | 
| +  EXPECT_TRUE(controller_->SchedulePageFlip( | 
| +      planes, false, false, | 
| +      base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 
| +                 base::Unretained(this)))); | 
| +  drm_->RunCallbacks(); | 
| + | 
| +  const ui::HardwareDisplayPlane* owned_plane = nullptr; | 
| +  for (const auto& plane : drm_->plane_manager()->planes()) | 
| +    if (plane->in_use()) | 
| +      owned_plane = plane; | 
| +  ASSERT_TRUE(owned_plane != nullptr); | 
| +  EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | 
| +  scoped_ptr<ui::CrtcController> crtc = | 
| +      controller_->RemoveCrtc(drm_, kPrimaryCrtc); | 
| +  // Destroying crtc should free the plane. | 
| +  crtc.reset(); | 
| +  uint32_t crtc_nullid = 0; | 
| EXPECT_FALSE(owned_plane->in_use()); | 
| +  EXPECT_EQ(crtc_nullid, owned_plane->owning_crtc()); | 
| +} | 
| + | 
| +TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) { | 
| +  ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 
| +      new MockScanoutBuffer(kDefaultModeSize))); | 
| +  EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | 
| +  std::vector<ui::OverlayPlane> planes = | 
| +      std::vector<ui::OverlayPlane>(1, plane1); | 
| +  EXPECT_TRUE(controller_->SchedulePageFlip( | 
| +      planes, false, false, | 
| +      base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 
| +                 base::Unretained(this)))); | 
| +  drm_->RunCallbacks(); | 
| + | 
| +  ui::HardwareDisplayPlane* primary_crtc_plane = nullptr; | 
| +  for (const auto& plane : drm_->plane_manager()->planes()) { | 
| +    if (plane->in_use() && kPrimaryCrtc == plane->owning_crtc()) | 
| +      primary_crtc_plane = plane; | 
| +  } | 
| + | 
| +  ASSERT_TRUE(primary_crtc_plane != nullptr); | 
| + | 
| +  scoped_ptr<ui::HardwareDisplayController> hdc_controller; | 
| +  hdc_controller.reset(new ui::HardwareDisplayController( | 
| +      controller_->RemoveCrtc(drm_, kPrimaryCrtc), controller_->origin())); | 
| +  EXPECT_TRUE(controller_->SchedulePageFlip( | 
| +      planes, false, false, | 
| +      base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 
| +                 base::Unretained(this)))); | 
| +  drm_->RunCallbacks(); | 
| +  EXPECT_TRUE(primary_crtc_plane->in_use()); | 
| +  EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); | 
| + | 
| +  // We reset state of plane here to test that the plane was actually added to | 
| +  // hdc_controller. In which case, the right state should be set to plane | 
| +  // after page flip call is handled by the controller. | 
| +  primary_crtc_plane->set_in_use(false); | 
| +  primary_crtc_plane->set_owning_crtc(0); | 
| +  EXPECT_TRUE(hdc_controller->SchedulePageFlip( | 
| +      planes, false, false, | 
| +      base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 
| +                 base::Unretained(this)))); | 
| +  drm_->RunCallbacks(); | 
| +  EXPECT_TRUE(primary_crtc_plane->in_use()); | 
| +  EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); | 
| } | 
|  | 
| TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { | 
|  |