| 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 06b47f4d5166f6ae1ccbe6af0ae9ad3cfe92cb65..e2bbdea2c77c5c799509113cfb3b4d861d7ba0f1 100644
|
| --- a/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
|
| +++ b/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
|
| @@ -67,12 +67,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);
|
| @@ -88,8 +92,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) {
|
| @@ -110,14 +115,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());
|
| }
|
| @@ -143,13 +149,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());
|
| }
|
| @@ -168,11 +175,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());
|
| }
|
| @@ -191,28 +199,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());
|
| }
|
| @@ -231,10 +236,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) {
|
| @@ -250,11 +256,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_);
|
| }
|
| @@ -265,30 +272,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());
|
| }
|
| @@ -299,11 +311,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())
|
| @@ -321,16 +334,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()) {
|
| @@ -343,11 +360,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());
|
|
|
| @@ -356,11 +374,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());
|
| }
|
| @@ -371,13 +390,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_);
|
| }
|
|
|
| @@ -389,12 +408,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_);
|
| }
|
|
|
| @@ -406,12 +425,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_);
|
| }
|
|
|
| @@ -421,15 +440,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_);
|
| }
|
|
|
| @@ -439,14 +458,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_);
|
| }
|
|
|