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/hardware_display_controller.h" | 6 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
7 #include "ui/ozone/platform/dri/screen_manager.h" | 7 #include "ui/ozone/platform/dri/screen_manager.h" |
8 #include "ui/ozone/platform/dri/test/mock_dri_surface.h" | |
9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" | 8 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" |
| 9 #include "ui/ozone/platform/dri/test/mock_surface_generator.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 class MockScreenManager : public ui::ScreenManager { | 17 class MockScreenManager : public ui::ScreenManager { |
18 public: | 18 public: |
19 MockScreenManager(ui::DriWrapper* dri) : ScreenManager(dri), dri_(dri) {} | 19 MockScreenManager(ui::DriWrapper* dri, |
| 20 ui::ScanoutSurfaceGenerator* surface_generator) |
| 21 : ScreenManager(dri, surface_generator), dri_(dri) {} |
20 | 22 |
21 virtual void ForceInitializationOfPrimaryDisplay() OVERRIDE {} | 23 virtual void ForceInitializationOfPrimaryDisplay() OVERRIDE {} |
22 virtual ui::DriSurface* CreateSurface(const gfx::Size& size) OVERRIDE { | |
23 return new ui::MockDriSurface(dri_, size); | |
24 } | |
25 | 24 |
26 private: | 25 private: |
27 ui::DriWrapper* dri_; | 26 ui::DriWrapper* dri_; |
28 | 27 |
29 DISALLOW_COPY_AND_ASSIGN(MockScreenManager); | 28 DISALLOW_COPY_AND_ASSIGN(MockScreenManager); |
30 }; | 29 }; |
31 | 30 |
32 } // namespace | 31 } // namespace |
33 | 32 |
34 class ScreenManagerTest : public testing::Test { | 33 class ScreenManagerTest : public testing::Test { |
35 public: | 34 public: |
36 ScreenManagerTest() {} | 35 ScreenManagerTest() {} |
37 virtual ~ScreenManagerTest() {} | 36 virtual ~ScreenManagerTest() {} |
38 | 37 |
39 virtual void SetUp() OVERRIDE { | 38 virtual void SetUp() OVERRIDE { |
40 dri_.reset(new ui::MockDriWrapper(3)); | 39 dri_.reset(new ui::MockDriWrapper(3)); |
41 screen_manager_.reset(new MockScreenManager(dri_.get())); | 40 surface_generator_.reset(new ui::MockSurfaceGenerator(dri_.get())); |
| 41 screen_manager_.reset(new MockScreenManager( |
| 42 dri_.get(), surface_generator_.get())); |
42 } | 43 } |
43 virtual void TearDown() OVERRIDE { | 44 virtual void TearDown() OVERRIDE { |
44 screen_manager_.reset(); | 45 screen_manager_.reset(); |
45 dri_.reset(); | 46 dri_.reset(); |
46 } | 47 } |
47 | 48 |
48 protected: | 49 protected: |
49 scoped_ptr<ui::MockDriWrapper> dri_; | 50 scoped_ptr<ui::MockDriWrapper> dri_; |
| 51 scoped_ptr<ui::MockSurfaceGenerator> surface_generator_; |
50 scoped_ptr<MockScreenManager> screen_manager_; | 52 scoped_ptr<MockScreenManager> screen_manager_; |
51 | 53 |
52 private: | 54 private: |
53 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); | 55 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); |
54 }; | 56 }; |
55 | 57 |
56 TEST_F(ScreenManagerTest, CheckWithNoControllers) { | 58 TEST_F(ScreenManagerTest, CheckWithNoControllers) { |
57 EXPECT_FALSE(screen_manager_->GetDisplayController(1)); | 59 EXPECT_FALSE(screen_manager_->GetDisplayController(1)); |
58 } | 60 } |
59 | 61 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 drmModeModeInfo new_mode = kDefaultMode; | 117 drmModeModeInfo new_mode = kDefaultMode; |
116 new_mode.vdisplay = 10; | 118 new_mode.vdisplay = 10; |
117 screen_manager_->ConfigureDisplayController(1, 2, new_mode); | 119 screen_manager_->ConfigureDisplayController(1, 2, new_mode); |
118 | 120 |
119 EXPECT_TRUE(screen_manager_->GetDisplayController(1)); | 121 EXPECT_TRUE(screen_manager_->GetDisplayController(1)); |
120 EXPECT_FALSE(screen_manager_->GetDisplayController(2)); | 122 EXPECT_FALSE(screen_manager_->GetDisplayController(2)); |
121 drmModeModeInfo mode = screen_manager_->GetDisplayController(1)->get_mode(); | 123 drmModeModeInfo mode = screen_manager_->GetDisplayController(1)->get_mode(); |
122 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay); | 124 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay); |
123 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay); | 125 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay); |
124 } | 126 } |
OLD | NEW |