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 "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
6 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/display/chromeos/test/action_logger_util.h" | 10 #include "ui/display/chromeos/test/action_logger_util.h" |
11 #include "ui/display/chromeos/test/test_display_snapshot.h" | 11 #include "ui/display/chromeos/test/test_display_snapshot.h" |
12 #include "ui/display/chromeos/test/test_native_display_delegate.h" | 12 #include "ui/display/chromeos/test/test_native_display_delegate.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 class TestObserver : public DisplayConfigurator::Observer { | 19 class TestObserver : public DisplayConfigurator::Observer { |
20 public: | 20 public: |
21 explicit TestObserver(DisplayConfigurator* configurator) | 21 explicit TestObserver(DisplayConfigurator* configurator) |
22 : configurator_(configurator) { | 22 : configurator_(configurator) { |
23 Reset(); | 23 Reset(); |
24 configurator_->AddObserver(this); | 24 configurator_->AddObserver(this); |
25 } | 25 } |
26 virtual ~TestObserver() { configurator_->RemoveObserver(this); } | 26 ~TestObserver() override { configurator_->RemoveObserver(this); } |
27 | 27 |
28 int num_changes() const { return num_changes_; } | 28 int num_changes() const { return num_changes_; } |
29 int num_failures() const { return num_failures_; } | 29 int num_failures() const { return num_failures_; } |
30 const DisplayConfigurator::DisplayStateList& latest_outputs() const { | 30 const DisplayConfigurator::DisplayStateList& latest_outputs() const { |
31 return latest_outputs_; | 31 return latest_outputs_; |
32 } | 32 } |
33 MultipleDisplayState latest_failed_state() const { | 33 MultipleDisplayState latest_failed_state() const { |
34 return latest_failed_state_; | 34 return latest_failed_state_; |
35 } | 35 } |
36 | 36 |
37 void Reset() { | 37 void Reset() { |
38 num_changes_ = 0; | 38 num_changes_ = 0; |
39 num_failures_ = 0; | 39 num_failures_ = 0; |
40 latest_outputs_.clear(); | 40 latest_outputs_.clear(); |
41 latest_failed_state_ = MULTIPLE_DISPLAY_STATE_INVALID; | 41 latest_failed_state_ = MULTIPLE_DISPLAY_STATE_INVALID; |
42 } | 42 } |
43 | 43 |
44 // DisplayConfigurator::Observer overrides: | 44 // DisplayConfigurator::Observer overrides: |
45 virtual void OnDisplayModeChanged( | 45 void OnDisplayModeChanged( |
46 const DisplayConfigurator::DisplayStateList& outputs) override { | 46 const DisplayConfigurator::DisplayStateList& outputs) override { |
47 num_changes_++; | 47 num_changes_++; |
48 latest_outputs_ = outputs; | 48 latest_outputs_ = outputs; |
49 } | 49 } |
50 | 50 |
51 virtual void OnDisplayModeChangeFailed(MultipleDisplayState failed_new_state) | 51 void OnDisplayModeChangeFailed( |
52 override { | 52 MultipleDisplayState failed_new_state) override { |
53 num_failures_++; | 53 num_failures_++; |
54 latest_failed_state_ = failed_new_state; | 54 latest_failed_state_ = failed_new_state; |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 DisplayConfigurator* configurator_; // Not owned. | 58 DisplayConfigurator* configurator_; // Not owned. |
59 | 59 |
60 // Number of times that OnDisplayMode*() has been called. | 60 // Number of times that OnDisplayMode*() has been called. |
61 int num_changes_; | 61 int num_changes_; |
62 int num_failures_; | 62 int num_failures_; |
63 | 63 |
64 // Parameters most recently passed to OnDisplayMode*(). | 64 // Parameters most recently passed to OnDisplayMode*(). |
65 DisplayConfigurator::DisplayStateList latest_outputs_; | 65 DisplayConfigurator::DisplayStateList latest_outputs_; |
66 MultipleDisplayState latest_failed_state_; | 66 MultipleDisplayState latest_failed_state_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 68 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
69 }; | 69 }; |
70 | 70 |
71 class TestStateController : public DisplayConfigurator::StateController { | 71 class TestStateController : public DisplayConfigurator::StateController { |
72 public: | 72 public: |
73 TestStateController() : state_(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) {} | 73 TestStateController() : state_(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) {} |
74 virtual ~TestStateController() {} | 74 ~TestStateController() override {} |
75 | 75 |
76 void set_state(MultipleDisplayState state) { state_ = state; } | 76 void set_state(MultipleDisplayState state) { state_ = state; } |
77 | 77 |
78 // DisplayConfigurator::StateController overrides: | 78 // DisplayConfigurator::StateController overrides: |
79 virtual MultipleDisplayState GetStateForDisplayIds( | 79 MultipleDisplayState GetStateForDisplayIds( |
80 const std::vector<int64_t>& outputs) const override { | 80 const std::vector<int64_t>& outputs) const override { |
81 return state_; | 81 return state_; |
82 } | 82 } |
83 virtual bool GetResolutionForDisplayId(int64_t display_id, | 83 bool GetResolutionForDisplayId(int64_t display_id, |
84 gfx::Size* size) const override { | 84 gfx::Size* size) const override { |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 MultipleDisplayState state_; | 89 MultipleDisplayState state_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(TestStateController); | 91 DISALLOW_COPY_AND_ASSIGN(TestStateController); |
92 }; | 92 }; |
93 | 93 |
94 class TestMirroringController | 94 class TestMirroringController |
95 : public DisplayConfigurator::SoftwareMirroringController { | 95 : public DisplayConfigurator::SoftwareMirroringController { |
96 public: | 96 public: |
97 TestMirroringController() : software_mirroring_enabled_(false) {} | 97 TestMirroringController() : software_mirroring_enabled_(false) {} |
98 virtual ~TestMirroringController() {} | 98 ~TestMirroringController() override {} |
99 | 99 |
100 virtual void SetSoftwareMirroring(bool enabled) override { | 100 void SetSoftwareMirroring(bool enabled) override { |
101 software_mirroring_enabled_ = enabled; | 101 software_mirroring_enabled_ = enabled; |
102 } | 102 } |
103 | 103 |
104 virtual bool SoftwareMirroringEnabled() const override { | 104 bool SoftwareMirroringEnabled() const override { |
105 return software_mirroring_enabled_; | 105 return software_mirroring_enabled_; |
106 } | 106 } |
107 | 107 |
108 private: | 108 private: |
109 bool software_mirroring_enabled_; | 109 bool software_mirroring_enabled_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); | 111 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); |
112 }; | 112 }; |
113 | 113 |
114 class DisplayConfiguratorTest : public testing::Test { | 114 class DisplayConfiguratorTest : public testing::Test { |
115 public: | 115 public: |
116 DisplayConfiguratorTest() | 116 DisplayConfiguratorTest() |
117 : small_mode_(gfx::Size(1366, 768), false, 60.0f), | 117 : small_mode_(gfx::Size(1366, 768), false, 60.0f), |
118 big_mode_(gfx::Size(2560, 1600), false, 60.0f), | 118 big_mode_(gfx::Size(2560, 1600), false, 60.0f), |
119 observer_(&configurator_), | 119 observer_(&configurator_), |
120 test_api_(&configurator_) {} | 120 test_api_(&configurator_) {} |
121 virtual ~DisplayConfiguratorTest() {} | 121 ~DisplayConfiguratorTest() override {} |
122 | 122 |
123 virtual void SetUp() override { | 123 void SetUp() override { |
124 log_.reset(new ActionLogger()); | 124 log_.reset(new ActionLogger()); |
125 | 125 |
126 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 126 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
127 configurator_.SetDelegateForTesting( | 127 configurator_.SetDelegateForTesting( |
128 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 128 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
129 | 129 |
130 configurator_.set_state_controller(&state_controller_); | 130 configurator_.set_state_controller(&state_controller_); |
131 configurator_.set_mirroring_controller(&mirroring_controller_); | 131 configurator_.set_mirroring_controller(&mirroring_controller_); |
132 | 132 |
133 std::vector<const DisplayMode*> modes; | 133 std::vector<const DisplayMode*> modes; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1179 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
1180 nullptr).c_str(), | 1180 nullptr).c_str(), |
1181 GetCrtcAction(outputs_[0], &small_mode_, | 1181 GetCrtcAction(outputs_[0], &small_mode_, |
1182 gfx::Point(0, 0)).c_str(), | 1182 gfx::Point(0, 0)).c_str(), |
1183 kUngrab, NULL), | 1183 kUngrab, NULL), |
1184 log_->GetActionsAndClear()); | 1184 log_->GetActionsAndClear()); |
1185 } | 1185 } |
1186 | 1186 |
1187 } // namespace test | 1187 } // namespace test |
1188 } // namespace ui | 1188 } // namespace ui |
OLD | NEW |