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 d2b9727375865c78e5988b41001ccc942aaadf4a..812e943e558fa3b7a9304dc70a9ee2e1484a987e 100644 |
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc |
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc |
@@ -69,12 +69,16 @@ class HardwareDisplayControllerTest : public testing::Test { |
scoped_refptr<ui::MockDrmDevice> drm_; |
int page_flips_; |
+ gfx::SwapResult last_swap_result_; |
private: |
DISALLOW_COPY_AND_ASSIGN(HardwareDisplayControllerTest); |
}; |
void HardwareDisplayControllerTest::SetUp() { |
+ page_flips_ = 0; |
+ last_swap_result_ = gfx::SwapResult::SWAP_FAILED; |
+ |
std::vector<uint32_t> crtcs; |
crtcs.push_back(kPrimaryCrtc); |
crtcs.push_back(kSecondaryCrtc); |
@@ -90,8 +94,9 @@ void HardwareDisplayControllerTest::TearDown() { |
drm_ = nullptr; |
} |
-void HardwareDisplayControllerTest::PageFlipCallback(gfx::SwapResult) { |
+void HardwareDisplayControllerTest::PageFlipCallback(gfx::SwapResult result) { |
page_flips_++; |
+ last_swap_result_ = result; |
} |
TEST_F(HardwareDisplayControllerTest, CheckModesettingResult) { |
@@ -112,14 +117,15 @@ TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) { |
new MockScanoutBuffer(kDefaultModeSize))); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane2); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
EXPECT_TRUE(plane1.buffer->HasOneRef()); |
EXPECT_FALSE(plane2.buffer->HasOneRef()); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_EQ(1, drm_->get_page_flip_call_count()); |
EXPECT_EQ(0, drm_->get_overlay_flip_call_count()); |
} |
@@ -145,13 +151,14 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfPageFlipFails) { |
new MockScanoutBuffer(kDefaultModeSize))); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane2); |
- EXPECT_FALSE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
planes.clear(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_FALSE(plane1.buffer->HasOneRef()); |
EXPECT_TRUE(plane2.buffer->HasOneRef()); |
} |
@@ -170,11 +177,12 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) { |
planes.push_back(plane1); |
planes.push_back(plane2); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_EQ(1, drm_->get_page_flip_call_count()); |
EXPECT_EQ(1, drm_->get_overlay_flip_call_count()); |
} |
@@ -193,28 +201,25 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) { |
planes.push_back(plane1); |
planes.push_back(plane2); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
- drm_->RunCallbacks(); |
- EXPECT_EQ(1, drm_->get_page_flip_call_count()); |
- EXPECT_EQ(1, drm_->get_overlay_flip_call_count()); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
// A test call shouldn't cause new flips, but should succeed. |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, true, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ EXPECT_TRUE(controller_->TestPageFlip(planes)); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_EQ(1, drm_->get_page_flip_call_count()); |
EXPECT_EQ(1, drm_->get_overlay_flip_call_count()); |
// Regular flips should continue on normally. |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(2, page_flips_); |
EXPECT_EQ(2, drm_->get_page_flip_call_count()); |
EXPECT_EQ(2, drm_->get_overlay_flip_call_count()); |
} |
@@ -233,11 +238,12 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayFullScreenMode) { |
planes.push_back(plane1); |
planes.push_back(plane2); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_EQ(1, drm_->get_page_flip_call_count()); |
EXPECT_EQ(0, drm_->get_overlay_flip_call_count()); |
} |
@@ -256,10 +262,11 @@ TEST_F(HardwareDisplayControllerTest, RejectUnderlays) { |
planes.push_back(plane1); |
planes.push_back(plane2); |
- EXPECT_FALSE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
} |
TEST_F(HardwareDisplayControllerTest, PageflipMirroredControllers) { |
@@ -275,11 +282,12 @@ TEST_F(HardwareDisplayControllerTest, PageflipMirroredControllers) { |
new MockScanoutBuffer(kDefaultModeSize))); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane2); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_EQ(2, drm_->get_page_flip_call_count()); |
EXPECT_EQ(1, page_flips_); |
} |
@@ -290,30 +298,35 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterRemoveCrtc) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
const ui::HardwareDisplayPlane* owned_plane = nullptr; |
- for (const auto& plane : drm_->plane_manager()->planes()) |
+ 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()); |
+ |
// 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 |
+ // Check that controller doesn't affect the state of removed plane in |
// subsequent page flip. |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
EXPECT_TRUE(owned_plane->in_use()); |
EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); |
} |
@@ -324,11 +337,12 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
const ui::HardwareDisplayPlane* owned_plane = nullptr; |
for (const auto& plane : drm_->plane_manager()->planes()) |
@@ -346,16 +360,20 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) { |
} |
TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) { |
+ controller_->AddCrtc(scoped_ptr<ui::CrtcController>( |
+ new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); |
+ |
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 /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(1, page_flips_); |
ui::HardwareDisplayPlane* primary_crtc_plane = nullptr; |
for (const auto& plane : drm_->plane_manager()->planes()) { |
@@ -368,11 +386,12 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) { |
scoped_ptr<ui::HardwareDisplayController> hdc_controller; |
hdc_controller.reset(new ui::HardwareDisplayController( |
controller_->RemoveCrtc(drm_, kPrimaryCrtc), controller_->origin())); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(2, page_flips_); |
EXPECT_TRUE(primary_crtc_plane->in_use()); |
EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); |
@@ -381,11 +400,12 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) { |
// 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 /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ hdc_controller->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
+ EXPECT_EQ(3, page_flips_); |
EXPECT_TRUE(primary_crtc_plane->in_use()); |
EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); |
} |
@@ -396,13 +416,13 @@ TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
EXPECT_EQ(1, page_flips_); |
} |
@@ -414,12 +434,12 @@ TEST_F(HardwareDisplayControllerTest, FailPageFlipping) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_FALSE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_); |
EXPECT_EQ(1, page_flips_); |
} |
@@ -431,12 +451,12 @@ TEST_F(HardwareDisplayControllerTest, FailPageFlippingDueToNoPrimaryPlane) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_FALSE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_); |
EXPECT_EQ(1, page_flips_); |
} |
@@ -446,15 +466,15 @@ TEST_F(HardwareDisplayControllerTest, AddCrtcMidPageFlip) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
controller_->AddCrtc(scoped_ptr<ui::CrtcController>( |
new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
EXPECT_EQ(1, page_flips_); |
} |
@@ -464,14 +484,14 @@ TEST_F(HardwareDisplayControllerTest, RemoveCrtcMidPageFlip) { |
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
std::vector<ui::OverlayPlane> planes = |
std::vector<ui::OverlayPlane>(1, plane1); |
- EXPECT_TRUE(controller_->SchedulePageFlip( |
- planes, false /* test_only */, |
- base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
- base::Unretained(this)))); |
+ controller_->SchedulePageFlip( |
+ planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
+ base::Unretained(this))); |
controller_->RemoveCrtc(drm_, kPrimaryCrtc); |
EXPECT_EQ(1, page_flips_); |
drm_->RunCallbacks(); |
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); |
EXPECT_EQ(1, page_flips_); |
} |