| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/ozone/platform/dri/dri_buffer.h" | 6 #include "ui/ozone/platform/dri/dri_buffer.h" |
| 7 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 7 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 8 #include "ui/ozone/platform/dri/screen_manager.h" | 8 #include "ui/ozone/platform/dri/screen_manager.h" |
| 9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" | 9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // Create a basic mode for a 6x4 screen. | 13 // Create a basic mode for a 6x4 screen. |
| 14 const drmModeModeInfo kDefaultMode = | 14 const drmModeModeInfo kDefaultMode = |
| 15 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; | 15 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
| 16 | 16 |
| 17 const uint32_t kPrimaryCrtc = 1; | 17 const uint32_t kPrimaryCrtc = 1; |
| 18 const uint32_t kPrimaryConnector = 2; | 18 const uint32_t kPrimaryConnector = 2; |
| 19 const uint32_t kSecondaryCrtc = 3; | 19 const uint32_t kSecondaryCrtc = 3; |
| 20 const uint32_t kSecondaryConnector = 4; | 20 const uint32_t kSecondaryConnector = 4; |
| 21 | 21 |
| 22 class MockScreenManager : public ui::ScreenManager { | 22 class MockScreenManager : public ui::ScreenManager { |
| 23 public: | 23 public: |
| 24 MockScreenManager(ui::DriWrapper* dri, | 24 MockScreenManager(ui::DriWrapper* dri, |
| 25 ui::ScanoutBufferGenerator* buffer_generator) | 25 ui::ScanoutBufferGenerator* buffer_generator) |
| 26 : ScreenManager(dri, buffer_generator), dri_(dri) {} | 26 : ScreenManager(dri, buffer_generator), dri_(dri) {} |
| 27 | 27 |
| 28 virtual void ForceInitializationOfPrimaryDisplay() OVERRIDE {} | 28 virtual void ForceInitializationOfPrimaryDisplay() override {} |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 ui::DriWrapper* dri_; | 31 ui::DriWrapper* dri_; |
| 32 | 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(MockScreenManager); | 33 DISALLOW_COPY_AND_ASSIGN(MockScreenManager); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 class ScreenManagerTest : public testing::Test { | 38 class ScreenManagerTest : public testing::Test { |
| 39 public: | 39 public: |
| 40 ScreenManagerTest() {} | 40 ScreenManagerTest() {} |
| 41 virtual ~ScreenManagerTest() {} | 41 virtual ~ScreenManagerTest() {} |
| 42 | 42 |
| 43 gfx::Rect GetPrimaryBounds() const { | 43 gfx::Rect GetPrimaryBounds() const { |
| 44 return gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); | 44 return gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Secondary is in extended mode, right-of primary. | 47 // Secondary is in extended mode, right-of primary. |
| 48 gfx::Rect GetSecondaryBounds() const { | 48 gfx::Rect GetSecondaryBounds() const { |
| 49 return gfx::Rect( | 49 return gfx::Rect( |
| 50 kDefaultMode.hdisplay, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); | 50 kDefaultMode.hdisplay, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual void SetUp() OVERRIDE { | 53 virtual void SetUp() override { |
| 54 dri_.reset(new ui::MockDriWrapper(3)); | 54 dri_.reset(new ui::MockDriWrapper(3)); |
| 55 buffer_generator_.reset(new ui::DriBufferGenerator(dri_.get())); | 55 buffer_generator_.reset(new ui::DriBufferGenerator(dri_.get())); |
| 56 screen_manager_.reset(new MockScreenManager( | 56 screen_manager_.reset(new MockScreenManager( |
| 57 dri_.get(), buffer_generator_.get())); | 57 dri_.get(), buffer_generator_.get())); |
| 58 } | 58 } |
| 59 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() override { |
| 60 screen_manager_.reset(); | 60 screen_manager_.reset(); |
| 61 dri_.reset(); | 61 dri_.reset(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 scoped_ptr<ui::MockDriWrapper> dri_; | 65 scoped_ptr<ui::MockDriWrapper> dri_; |
| 66 scoped_ptr<ui::DriBufferGenerator> buffer_generator_; | 66 scoped_ptr<ui::DriBufferGenerator> buffer_generator_; |
| 67 scoped_ptr<MockScreenManager> screen_manager_; | 67 scoped_ptr<MockScreenManager> screen_manager_; |
| 68 | 68 |
| 69 private: | 69 private: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 screen_manager_->RemoveDisplayController(kSecondaryCrtc); | 245 screen_manager_->RemoveDisplayController(kSecondaryCrtc); |
| 246 EXPECT_TRUE( | 246 EXPECT_TRUE( |
| 247 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 247 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 248 kPrimaryConnector, | 248 kPrimaryConnector, |
| 249 GetPrimaryBounds().origin(), | 249 GetPrimaryBounds().origin(), |
| 250 kDefaultMode)); | 250 kDefaultMode)); |
| 251 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 251 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 252 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 252 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 253 } | 253 } |
| OLD | NEW |