OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/display/output_configurator.h" | 5 #include "chromeos/display/output_configurator.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 virtual void UpdateXRandRConfiguration( | 121 virtual void UpdateXRandRConfiguration( |
122 const base::NativeEvent& event) OVERRIDE { AppendAction(kUpdateXRandR); } | 122 const base::NativeEvent& event) OVERRIDE { AppendAction(kUpdateXRandR); } |
123 virtual void GrabServer() OVERRIDE { AppendAction(kGrab); } | 123 virtual void GrabServer() OVERRIDE { AppendAction(kGrab); } |
124 virtual void UngrabServer() OVERRIDE { AppendAction(kUngrab); } | 124 virtual void UngrabServer() OVERRIDE { AppendAction(kUngrab); } |
125 virtual void SyncWithServer() OVERRIDE { AppendAction(kSync); } | 125 virtual void SyncWithServer() OVERRIDE { AppendAction(kSync); } |
126 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE { | 126 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE { |
127 AppendAction(GetBackgroundAction(color_argb)); | 127 AppendAction(GetBackgroundAction(color_argb)); |
128 } | 128 } |
129 virtual void ForceDPMSOn() OVERRIDE { AppendAction(kForceDPMS); } | 129 virtual void ForceDPMSOn() OVERRIDE { AppendAction(kForceDPMS); } |
130 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() | 130 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs( |
131 OVERRIDE { | 131 const OutputConfigurator::StateController* controller) OVERRIDE { |
132 return outputs_; | 132 return outputs_; |
133 } | 133 } |
134 virtual bool GetModeDetails( | 134 virtual bool GetModeDetails( |
135 RRMode mode, | 135 RRMode mode, |
136 int* width, | 136 int* width, |
137 int* height, | 137 int* height, |
138 bool* interlaced) OVERRIDE { | 138 bool* interlaced) OVERRIDE { |
139 std::map<RRMode, ModeDetails>::const_iterator it = modes_.find(mode); | 139 std::map<RRMode, ModeDetails>::const_iterator it = modes_.find(mode); |
140 if (it == modes_.end()) | 140 if (it == modes_.end()) |
141 return false; | 141 return false; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 class TestStateController : public OutputConfigurator::StateController { | 203 class TestStateController : public OutputConfigurator::StateController { |
204 public: | 204 public: |
205 TestStateController() : state_(STATE_DUAL_EXTENDED) {} | 205 TestStateController() : state_(STATE_DUAL_EXTENDED) {} |
206 virtual ~TestStateController() {} | 206 virtual ~TestStateController() {} |
207 | 207 |
208 void set_state(OutputState state) { state_ = state; } | 208 void set_state(OutputState state) { state_ = state; } |
209 | 209 |
210 // OutputConfigurator::StateController overrides: | 210 // OutputConfigurator::StateController overrides: |
211 virtual OutputState GetStateForDisplayIds( | 211 virtual OutputState GetStateForDisplayIds( |
212 const std::vector<int64>& outputs) const OVERRIDE { return state_; } | 212 const std::vector<int64>& outputs) const OVERRIDE { return state_; } |
| 213 virtual bool GetResolutionForDisplayId( |
| 214 int64 display_id, |
| 215 int *width, |
| 216 int *height) const OVERRIDE { |
| 217 return false; |
| 218 } |
213 | 219 |
214 private: | 220 private: |
215 OutputState state_; | 221 OutputState state_; |
216 | 222 |
217 DISALLOW_COPY_AND_ASSIGN(TestStateController); | 223 DISALLOW_COPY_AND_ASSIGN(TestStateController); |
218 }; | 224 }; |
219 | 225 |
220 class TestMirroringController | 226 class TestMirroringController |
221 : public OutputConfigurator::SoftwareMirroringController { | 227 : public OutputConfigurator::SoftwareMirroringController { |
222 public: | 228 public: |
(...skipping 25 matching lines...) Expand all Loading... |
248 configurator_.SetDelegateForTesting( | 254 configurator_.SetDelegateForTesting( |
249 scoped_ptr<OutputConfigurator::Delegate>(delegate_)); | 255 scoped_ptr<OutputConfigurator::Delegate>(delegate_)); |
250 configurator_.set_state_controller(&state_controller_); | 256 configurator_.set_state_controller(&state_controller_); |
251 configurator_.set_mirroring_controller(&mirroring_controller_); | 257 configurator_.set_mirroring_controller(&mirroring_controller_); |
252 | 258 |
253 OutputConfigurator::OutputSnapshot* o = &outputs_[0]; | 259 OutputConfigurator::OutputSnapshot* o = &outputs_[0]; |
254 o->output = 1; | 260 o->output = 1; |
255 o->crtc = 10; | 261 o->crtc = 10; |
256 o->current_mode = kSmallModeId; | 262 o->current_mode = kSmallModeId; |
257 o->native_mode = kSmallModeId; | 263 o->native_mode = kSmallModeId; |
| 264 o->selected_mode = kSmallModeId; |
258 o->mirror_mode = kSmallModeId; | 265 o->mirror_mode = kSmallModeId; |
259 o->y = 0; | 266 o->y = 0; |
260 o->height = kSmallModeHeight; | 267 o->height = kSmallModeHeight; |
261 o->is_internal = true; | 268 o->is_internal = true; |
262 o->is_aspect_preserving_scaling = true; | 269 o->is_aspect_preserving_scaling = true; |
263 o->touch_device_id = 0; | 270 o->touch_device_id = 0; |
264 o->has_display_id = true; | 271 o->has_display_id = true; |
265 | 272 |
266 o = &outputs_[1]; | 273 o = &outputs_[1]; |
267 o->output = 2; | 274 o->output = 2; |
268 o->crtc = 11; | 275 o->crtc = 11; |
269 o->current_mode = kBigModeId; | 276 o->current_mode = kBigModeId; |
270 o->native_mode = kBigModeId; | 277 o->native_mode = kBigModeId; |
| 278 o->selected_mode = kBigModeId; |
271 o->mirror_mode = kSmallModeId; | 279 o->mirror_mode = kSmallModeId; |
272 o->y = 0; | 280 o->y = 0; |
273 o->height = kBigModeHeight; | 281 o->height = kBigModeHeight; |
274 o->is_internal = false; | 282 o->is_internal = false; |
275 o->is_aspect_preserving_scaling = true; | 283 o->is_aspect_preserving_scaling = true; |
276 o->touch_device_id = 0; | 284 o->touch_device_id = 0; |
277 o->has_display_id = true; | 285 o->has_display_id = true; |
278 | 286 |
279 UpdateOutputs(2); | 287 UpdateOutputs(2); |
280 delegate_->AddMode(kSmallModeId, kSmallModeWidth, kSmallModeHeight, false); | 288 delegate_->AddMode(kSmallModeId, kSmallModeWidth, kSmallModeHeight, false); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 OutputConfigurator::kSetDisplayPowerNoFlags); | 682 OutputConfigurator::kSetDisplayPowerNoFlags); |
675 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), delegate_->GetActionsAndClear()); | 683 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), delegate_->GetActionsAndClear()); |
676 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_ON, | 684 configurator_.SetDisplayPower(DISPLAY_POWER_ALL_ON, |
677 OutputConfigurator::kSetDisplayPowerNoFlags); | 685 OutputConfigurator::kSetDisplayPowerNoFlags); |
678 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 686 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), |
679 delegate_->GetActionsAndClear()); | 687 delegate_->GetActionsAndClear()); |
680 | 688 |
681 // Connect an external display and check that it's configured correctly. | 689 // Connect an external display and check that it's configured correctly. |
682 outputs_[0].is_internal = false; | 690 outputs_[0].is_internal = false; |
683 outputs_[0].native_mode = kBigModeId; | 691 outputs_[0].native_mode = kBigModeId; |
| 692 outputs_[0].selected_mode = kBigModeId; |
684 UpdateOutputs(1); | 693 UpdateOutputs(1); |
685 EXPECT_TRUE(test_api_.SendOutputChangeEvents(true)); | 694 EXPECT_TRUE(test_api_.SendOutputChangeEvents(true)); |
686 EXPECT_EQ(JoinActions(kUpdateXRandR, kGrab, | 695 EXPECT_EQ(JoinActions(kUpdateXRandR, kGrab, |
687 GetFramebufferAction(kBigModeWidth, kBigModeHeight, | 696 GetFramebufferAction(kBigModeWidth, kBigModeHeight, |
688 outputs_[0].crtc, 0).c_str(), | 697 outputs_[0].crtc, 0).c_str(), |
689 GetCrtcAction(outputs_[0].crtc, 0, 0, kBigModeId, | 698 GetCrtcAction(outputs_[0].crtc, 0, 0, kBigModeId, |
690 outputs_[0].output).c_str(), | 699 outputs_[0].output).c_str(), |
691 kUngrab, kProjectingOff, NULL), | 700 kUngrab, kProjectingOff, NULL), |
692 delegate_->GetActionsAndClear()); | 701 delegate_->GetActionsAndClear()); |
693 } | 702 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 test_api_.SendOutputChangeEvents(true); | 757 test_api_.SendOutputChangeEvents(true); |
749 EXPECT_EQ(STATE_DUAL_EXTENDED, configurator_.output_state()); | 758 EXPECT_EQ(STATE_DUAL_EXTENDED, configurator_.output_state()); |
750 | 759 |
751 outputs_[0].has_display_id = true; | 760 outputs_[0].has_display_id = true; |
752 UpdateOutputs(2); | 761 UpdateOutputs(2); |
753 test_api_.SendOutputChangeEvents(true); | 762 test_api_.SendOutputChangeEvents(true); |
754 EXPECT_EQ(STATE_DUAL_MIRROR, configurator_.output_state()); | 763 EXPECT_EQ(STATE_DUAL_MIRROR, configurator_.output_state()); |
755 } | 764 } |
756 | 765 |
757 } // namespace chromeos | 766 } // namespace chromeos |
OLD | NEW |