Index: ui/gfx/ozone/dri/hardware_display_controller_unittest.cc |
diff --git a/ui/gfx/ozone/dri/hardware_display_controller_unittest.cc b/ui/gfx/ozone/dri/hardware_display_controller_unittest.cc |
index 3806b5a157b8860cb15c0c7bd6b122c4d76a66db..a145d3aa0f960c853593e00fd4ad6ac74b07da20 100644 |
--- a/ui/gfx/ozone/dri/hardware_display_controller_unittest.cc |
+++ b/ui/gfx/ozone/dri/hardware_display_controller_unittest.cc |
@@ -35,7 +35,6 @@ class MockDriWrapper : public gfx::DriWrapper { |
add_framebuffer_call_count_(0), |
remove_framebuffer_call_count_(0), |
set_crtc_expectation_(true), |
- add_framebuffer_expectation_(true), |
page_flip_expectation_(true) { |
fd_ = fd; |
} |
@@ -71,12 +70,13 @@ class MockDriWrapper : public gfx::DriWrapper { |
uint32_t handle, |
uint32_t* framebuffer) OVERRIDE { |
add_framebuffer_call_count_++; |
+ *framebuffer = add_framebuffer_call_count_; |
return add_framebuffer_expectation_; |
} |
virtual bool RemoveFramebuffer(uint32_t framebuffer) OVERRIDE { |
remove_framebuffer_call_count_++; |
- return true; |
+ return framebuffer != 0; |
} |
virtual bool PageFlip(uint32_t crtc_id, |
@@ -113,10 +113,6 @@ class MockDriWrapper : public gfx::DriWrapper { |
set_crtc_expectation_ = state; |
} |
- void set_add_framebuffer_expectation(bool state) { |
- add_framebuffer_expectation_ = state; |
- } |
- |
void set_page_flip_expectation(bool state) { |
page_flip_expectation_ = state; |
} |
@@ -129,7 +125,6 @@ class MockDriWrapper : public gfx::DriWrapper { |
int remove_framebuffer_call_count_; |
bool set_crtc_expectation_; |
- bool add_framebuffer_expectation_; |
bool page_flip_expectation_; |
DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); |
@@ -202,40 +197,42 @@ TEST_F(HardwareDisplayControllerTest, |
controller_->get_state()); |
} |
-TEST_F(HardwareDisplayControllerTest, CheckStateAfterSurfaceIsBound) { |
+TEST_F(HardwareDisplayControllerTest, CheckStateAfterAddFramebufferFails) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
- new MockDriSurface(controller_.get())); |
- EXPECT_TRUE(surface->Initialize()); |
- EXPECT_TRUE(controller_->BindSurfaceToController(surface.Pass())); |
- |
- EXPECT_EQ(2, drm_->get_add_framebuffer_call_count()); |
- EXPECT_EQ(gfx::HardwareDisplayController::SURFACE_INITIALIZED, |
+ drm_->set_add_framebuffer_expectation(false); |
+ uint32_t framebuffer = 0; |
+ EXPECT_FALSE(controller_->AddFramebuffer(24, 32, 100, 1, &framebuffer)); |
+ EXPECT_EQ(gfx::HardwareDisplayController::FAILED, |
controller_->get_state()); |
} |
-TEST_F(HardwareDisplayControllerTest, CheckStateIfBindingFails) { |
- drm_->set_add_framebuffer_expectation(false); |
+TEST_F(HardwareDisplayControllerTest, CheckReturnOfInvalidRemoveFramebuffer) { |
+ controller_->SetControllerInfo( |
+ drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
+ |
+ EXPECT_FALSE(controller_->RemoveFramebuffer(0)); |
+} |
+TEST_F(HardwareDisplayControllerTest, CheckStateAfterSurfaceIsBound) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
+ scoped_ptr<gfx::ScanoutSurface> surface( |
new MockDriSurface(controller_.get())); |
EXPECT_TRUE(surface->Initialize()); |
- EXPECT_FALSE(controller_->BindSurfaceToController(surface.Pass())); |
+ EXPECT_TRUE(controller_->BindSurfaceToController(surface.Pass())); |
- EXPECT_EQ(1, drm_->get_add_framebuffer_call_count()); |
- EXPECT_EQ(gfx::HardwareDisplayController::FAILED, |
+ EXPECT_EQ(2, drm_->get_add_framebuffer_call_count()); |
+ EXPECT_EQ(gfx::HardwareDisplayController::SURFACE_INITIALIZED, |
controller_->get_state()); |
} |
TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
+ scoped_ptr<gfx::ScanoutSurface> surface( |
new MockDriSurface(controller_.get())); |
EXPECT_TRUE(surface->Initialize()); |
@@ -252,7 +249,7 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfModesetFails) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
+ scoped_ptr<gfx::ScanoutSurface> surface( |
new MockDriSurface(controller_.get())); |
EXPECT_TRUE(surface->Initialize()); |
@@ -269,7 +266,7 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfPageFlipFails) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
+ scoped_ptr<gfx::ScanoutSurface> surface( |
new MockDriSurface(controller_.get())); |
EXPECT_TRUE(surface->Initialize()); |
@@ -284,7 +281,7 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfPageFlipFails) { |
TEST_F(HardwareDisplayControllerTest, CheckProperDestruction) { |
controller_->SetControllerInfo( |
drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); |
- scoped_ptr<gfx::DriSurface> surface( |
+ scoped_ptr<gfx::ScanoutSurface> surface( |
new MockDriSurface(controller_.get())); |
EXPECT_TRUE(surface->Initialize()); |