| 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 <X11/extensions/Xrandr.h> | 5 #include <X11/extensions/Xrandr.h> |
| 6 | 6 |
| 7 #undef Bool | 7 #undef Bool |
| 8 #undef None | 8 #undef None |
| 9 | 9 |
| 10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 DisplaySnapshotX11* CreateInternalOutput(RROutput output, RRCrtc crtc) { | 53 DisplaySnapshotX11* CreateInternalOutput(RROutput output, RRCrtc crtc) { |
| 54 return CreateOutput(0, | 54 return CreateOutput(0, |
| 55 DISPLAY_CONNECTION_TYPE_INTERNAL, | 55 DISPLAY_CONNECTION_TYPE_INTERNAL, |
| 56 output, | 56 output, |
| 57 crtc); | 57 crtc); |
| 58 } | 58 } |
| 59 | 59 |
| 60 class TestHelperDelegate : public NativeDisplayDelegateX11::HelperDelegate { | 60 class TestHelperDelegate : public NativeDisplayDelegateX11::HelperDelegate { |
| 61 public: | 61 public: |
| 62 TestHelperDelegate(); | 62 TestHelperDelegate(); |
| 63 virtual ~TestHelperDelegate(); | 63 ~TestHelperDelegate() override; |
| 64 | 64 |
| 65 int num_calls_update_xrandr_config() const { | 65 int num_calls_update_xrandr_config() const { |
| 66 return num_calls_update_xrandr_config_; | 66 return num_calls_update_xrandr_config_; |
| 67 } | 67 } |
| 68 | 68 |
| 69 int num_calls_notify_observers() const { return num_calls_notify_observers_; } | 69 int num_calls_notify_observers() const { return num_calls_notify_observers_; } |
| 70 | 70 |
| 71 void set_cached_outputs(const std::vector<DisplaySnapshot*>& outputs) { | 71 void set_cached_outputs(const std::vector<DisplaySnapshot*>& outputs) { |
| 72 cached_outputs_ = outputs; | 72 cached_outputs_ = outputs; |
| 73 } | 73 } |
| 74 | 74 |
| 75 // NativeDisplayDelegateX11::HelperDelegate overrides: | 75 // NativeDisplayDelegateX11::HelperDelegate overrides: |
| 76 virtual void UpdateXRandRConfiguration(const base::NativeEvent& event) | 76 void UpdateXRandRConfiguration(const base::NativeEvent& event) override; |
| 77 override; | 77 const std::vector<DisplaySnapshot*>& GetCachedDisplays() const override; |
| 78 virtual const std::vector<DisplaySnapshot*>& GetCachedDisplays() const | 78 void NotifyDisplayObservers() override; |
| 79 override; | |
| 80 virtual void NotifyDisplayObservers() override; | |
| 81 | 79 |
| 82 private: | 80 private: |
| 83 int num_calls_update_xrandr_config_; | 81 int num_calls_update_xrandr_config_; |
| 84 int num_calls_notify_observers_; | 82 int num_calls_notify_observers_; |
| 85 | 83 |
| 86 std::vector<DisplaySnapshot*> cached_outputs_; | 84 std::vector<DisplaySnapshot*> cached_outputs_; |
| 87 | 85 |
| 88 DISALLOW_COPY_AND_ASSIGN(TestHelperDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(TestHelperDelegate); |
| 89 }; | 87 }; |
| 90 | 88 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 void TestHelperDelegate::NotifyDisplayObservers() { | 104 void TestHelperDelegate::NotifyDisplayObservers() { |
| 107 ++num_calls_notify_observers_; | 105 ++num_calls_notify_observers_; |
| 108 } | 106 } |
| 109 | 107 |
| 110 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
| 111 // NativeDisplayEventDispatcherX11Test | 109 // NativeDisplayEventDispatcherX11Test |
| 112 | 110 |
| 113 class NativeDisplayEventDispatcherX11Test : public testing::Test { | 111 class NativeDisplayEventDispatcherX11Test : public testing::Test { |
| 114 public: | 112 public: |
| 115 NativeDisplayEventDispatcherX11Test(); | 113 NativeDisplayEventDispatcherX11Test(); |
| 116 virtual ~NativeDisplayEventDispatcherX11Test(); | 114 ~NativeDisplayEventDispatcherX11Test() override; |
| 117 | 115 |
| 118 protected: | 116 protected: |
| 119 void DispatchScreenChangeEvent(); | 117 void DispatchScreenChangeEvent(); |
| 120 void DispatchOutputChangeEvent(RROutput output, | 118 void DispatchOutputChangeEvent(RROutput output, |
| 121 RRCrtc crtc, | 119 RRCrtc crtc, |
| 122 RRMode mode, | 120 RRMode mode, |
| 123 bool connected); | 121 bool connected); |
| 124 | 122 |
| 125 int xrandr_event_base_; | 123 int xrandr_event_base_; |
| 126 scoped_ptr<TestHelperDelegate> helper_delegate_; | 124 scoped_ptr<TestHelperDelegate> helper_delegate_; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 outputs.clear(); | 318 outputs.clear(); |
| 321 outputs.push_back(CreateOutput(0, DISPLAY_CONNECTION_TYPE_UNKNOWN, 2, 11)); | 319 outputs.push_back(CreateOutput(0, DISPLAY_CONNECTION_TYPE_UNKNOWN, 2, 11)); |
| 322 helper_delegate_->set_cached_outputs(outputs.get()); | 320 helper_delegate_->set_cached_outputs(outputs.get()); |
| 323 | 321 |
| 324 // External display should be updated if the id is zero. | 322 // External display should be updated if the id is zero. |
| 325 DispatchOutputChangeEvent(2, 11, 20, true); | 323 DispatchOutputChangeEvent(2, 11, 20, true); |
| 326 EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers()); | 324 EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers()); |
| 327 } | 325 } |
| 328 | 326 |
| 329 } // namespace ui | 327 } // namespace ui |
| OLD | NEW |