| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <X11/extensions/Xrandr.h> | 6 #include <X11/extensions/Xrandr.h> |
| 7 | 7 |
| 8 #undef Bool | 8 #undef Bool |
| 9 #undef None | 9 #undef None |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/test/simple_test_tick_clock.h" | 12 #include "base/test/simple_test_tick_clock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/display/manager/chromeos/x11/display_mode_x11.h" | 14 #include "ui/display/manager/chromeos/x11/display_mode_x11.h" |
| 15 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" | 15 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" |
| 16 #include "ui/display/manager/chromeos/x11/native_display_delegate_x11.h" | 16 #include "ui/display/manager/chromeos/x11/native_display_delegate_x11.h" |
| 17 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h" | 17 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace display { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 DisplaySnapshotX11* CreateOutput(int64_t id, | 23 DisplaySnapshotX11* CreateOutput(int64_t id, |
| 24 DisplayConnectionType type, | 24 DisplayConnectionType type, |
| 25 RROutput output, | 25 RROutput output, |
| 26 RRCrtc crtc) { | 26 RRCrtc crtc) { |
| 27 static const DisplayModeX11 kDefaultDisplayMode(gfx::Size(1, 1), false, 60.0f, | 27 static const DisplayModeX11 kDefaultDisplayMode(gfx::Size(1, 1), false, 60.0f, |
| 28 20); | 28 20); |
| 29 std::vector<std::unique_ptr<const DisplayMode>> modes; | 29 std::vector<std::unique_ptr<const DisplayMode>> modes; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 dispatcher_->SetTickClockForTest( | 130 dispatcher_->SetTickClockForTest( |
| 131 std::unique_ptr<base::TickClock>(test_tick_clock_)); | 131 std::unique_ptr<base::TickClock>(test_tick_clock_)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 NativeDisplayEventDispatcherX11Test::~NativeDisplayEventDispatcherX11Test() {} | 134 NativeDisplayEventDispatcherX11Test::~NativeDisplayEventDispatcherX11Test() {} |
| 135 | 135 |
| 136 void NativeDisplayEventDispatcherX11Test::DispatchScreenChangeEvent() { | 136 void NativeDisplayEventDispatcherX11Test::DispatchScreenChangeEvent() { |
| 137 XRRScreenChangeNotifyEvent event = {0}; | 137 XRRScreenChangeNotifyEvent event = {0}; |
| 138 event.type = xrandr_event_base_ + RRScreenChangeNotify; | 138 event.type = xrandr_event_base_ + RRScreenChangeNotify; |
| 139 | 139 |
| 140 dispatcher_->DispatchEvent(reinterpret_cast<const PlatformEvent>(&event)); | 140 dispatcher_->DispatchEvent(reinterpret_cast<const ui::PlatformEvent>(&event)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void NativeDisplayEventDispatcherX11Test::DispatchOutputChangeEvent( | 143 void NativeDisplayEventDispatcherX11Test::DispatchOutputChangeEvent( |
| 144 RROutput output, | 144 RROutput output, |
| 145 RRCrtc crtc, | 145 RRCrtc crtc, |
| 146 RRMode mode, | 146 RRMode mode, |
| 147 bool connected) { | 147 bool connected) { |
| 148 XRROutputChangeNotifyEvent event = {0}; | 148 XRROutputChangeNotifyEvent event = {0}; |
| 149 event.type = xrandr_event_base_ + RRNotify; | 149 event.type = xrandr_event_base_ + RRNotify; |
| 150 event.subtype = RRNotify_OutputChange; | 150 event.subtype = RRNotify_OutputChange; |
| 151 event.output = output; | 151 event.output = output; |
| 152 event.crtc = crtc; | 152 event.crtc = crtc; |
| 153 event.mode = mode; | 153 event.mode = mode; |
| 154 event.connection = connected ? RR_Connected : RR_Disconnected; | 154 event.connection = connected ? RR_Connected : RR_Disconnected; |
| 155 | 155 |
| 156 dispatcher_->DispatchEvent(reinterpret_cast<const PlatformEvent>(&event)); | 156 dispatcher_->DispatchEvent(reinterpret_cast<const ui::PlatformEvent>(&event)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace | 159 } // namespace |
| 160 | 160 |
| 161 TEST_F(NativeDisplayEventDispatcherX11Test, OnScreenChangedEvent) { | 161 TEST_F(NativeDisplayEventDispatcherX11Test, OnScreenChangedEvent) { |
| 162 DispatchScreenChangeEvent(); | 162 DispatchScreenChangeEvent(); |
| 163 EXPECT_EQ(1, helper_delegate_->num_calls_update_xrandr_config()); | 163 EXPECT_EQ(1, helper_delegate_->num_calls_update_xrandr_config()); |
| 164 EXPECT_EQ(0, helper_delegate_->num_calls_notify_observers()); | 164 EXPECT_EQ(0, helper_delegate_->num_calls_notify_observers()); |
| 165 } | 165 } |
| 166 | 166 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 outputs.clear(); | 307 outputs.clear(); |
| 308 outputs.push_back(CreateOutput(0, DISPLAY_CONNECTION_TYPE_UNKNOWN, 2, 11)); | 308 outputs.push_back(CreateOutput(0, DISPLAY_CONNECTION_TYPE_UNKNOWN, 2, 11)); |
| 309 helper_delegate_->set_cached_outputs(outputs.get()); | 309 helper_delegate_->set_cached_outputs(outputs.get()); |
| 310 | 310 |
| 311 // External display should be updated if the id is zero. | 311 // External display should be updated if the id is zero. |
| 312 DispatchOutputChangeEvent(2, 11, 20, true); | 312 DispatchOutputChangeEvent(2, 11, 20, true); |
| 313 EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers()); | 313 EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace ui | 316 } // namespace display |
| OLD | NEW |