| Index: ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc
|
| diff --git a/chromeos/display/native_display_event_dispatcher_x11_unittest.cc b/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc
|
| similarity index 64%
|
| rename from chromeos/display/native_display_event_dispatcher_x11_unittest.cc
|
| rename to ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc
|
| index 965914893a5513608239e0e9f323a4797949f502..abb42375cd214d16bc419d8141adcd64a174c995 100644
|
| --- a/chromeos/display/native_display_event_dispatcher_x11_unittest.cc
|
| +++ b/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc
|
| @@ -7,20 +7,32 @@
|
| #undef Bool
|
| #undef None
|
|
|
| -#include "chromeos/display/native_display_delegate_x11.h"
|
| -#include "chromeos/display/native_display_event_dispatcher_x11.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/display/chromeos/x11/display_mode_x11.h"
|
| +#include "ui/display/chromeos/x11/display_snapshot_x11.h"
|
| +#include "ui/display/chromeos/x11/native_display_delegate_x11.h"
|
| +#include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h"
|
|
|
| -namespace chromeos {
|
| +namespace ui {
|
|
|
| namespace {
|
|
|
| -OutputConfigurator::OutputSnapshot CreateOutput(
|
| - RROutput output, RRCrtc crtc, RRMode mode) {
|
| - OutputConfigurator::OutputSnapshot snapshot;
|
| - snapshot.output = output;
|
| - snapshot.crtc = crtc;
|
| - snapshot.current_mode = mode;
|
| +const DisplayModeX11 kDefaultDisplayMode(gfx::Size(1, 1), false, 60.0f, 20);
|
| +
|
| +DisplaySnapshotX11* CreateOutput(RROutput output, RRCrtc crtc) {
|
| + DisplaySnapshotX11* snapshot = new DisplaySnapshotX11(
|
| + 0,
|
| + false,
|
| + gfx::Point(0, 0),
|
| + gfx::Size(0, 0),
|
| + OUTPUT_TYPE_UNKNOWN,
|
| + false,
|
| + std::vector<const DisplayMode*>(1, &kDefaultDisplayMode),
|
| + &kDefaultDisplayMode,
|
| + NULL,
|
| + output,
|
| + crtc,
|
| + 0);
|
|
|
| return snapshot;
|
| }
|
| @@ -34,34 +46,30 @@ class TestHelperDelegate : public NativeDisplayDelegateX11::HelperDelegate {
|
| return num_calls_update_xrandr_config_;
|
| }
|
|
|
| - int num_calls_notify_observers() const {
|
| - return num_calls_notify_observers_;
|
| - }
|
| + int num_calls_notify_observers() const { return num_calls_notify_observers_; }
|
|
|
| - void set_cached_outputs(
|
| - const std::vector<OutputConfigurator::OutputSnapshot>& outputs) {
|
| + void set_cached_outputs(const std::vector<DisplaySnapshot*>& outputs) {
|
| cached_outputs_ = outputs;
|
| }
|
|
|
| // NativeDisplayDelegateX11::HelperDelegate overrides:
|
| - virtual void UpdateXRandRConfiguration(
|
| - const base::NativeEvent& event) OVERRIDE;
|
| - virtual const std::vector<OutputConfigurator::OutputSnapshot>&
|
| - GetCachedOutputs() const OVERRIDE;
|
| + virtual void UpdateXRandRConfiguration(const base::NativeEvent& event)
|
| + OVERRIDE;
|
| + virtual const std::vector<DisplaySnapshot*>& GetCachedOutputs() const
|
| + OVERRIDE;
|
| virtual void NotifyDisplayObservers() OVERRIDE;
|
|
|
| private:
|
| int num_calls_update_xrandr_config_;
|
| int num_calls_notify_observers_;
|
|
|
| - std::vector<OutputConfigurator::OutputSnapshot> cached_outputs_;
|
| + std::vector<DisplaySnapshot*> cached_outputs_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestHelperDelegate);
|
| };
|
|
|
| TestHelperDelegate::TestHelperDelegate()
|
| - : num_calls_update_xrandr_config_(0),
|
| - num_calls_notify_observers_(0) {}
|
| + : num_calls_update_xrandr_config_(0), num_calls_notify_observers_(0) {}
|
|
|
| TestHelperDelegate::~TestHelperDelegate() {}
|
|
|
| @@ -70,8 +78,8 @@ void TestHelperDelegate::UpdateXRandRConfiguration(
|
| ++num_calls_update_xrandr_config_;
|
| }
|
|
|
| -const std::vector<OutputConfigurator::OutputSnapshot>&
|
| -TestHelperDelegate::GetCachedOutputs() const {
|
| +const std::vector<DisplaySnapshot*>& TestHelperDelegate::GetCachedOutputs()
|
| + const {
|
| return cached_outputs_;
|
| }
|
|
|
| @@ -89,8 +97,10 @@ class NativeDisplayEventDispatcherX11Test : public testing::Test {
|
|
|
| protected:
|
| void DispatchScreenChangeEvent();
|
| - void DispatchOutputChangeEvent(
|
| - RROutput output, RRCrtc crtc, RRMode mode, bool connected);
|
| + void DispatchOutputChangeEvent(RROutput output,
|
| + RRCrtc crtc,
|
| + RRMode mode,
|
| + bool connected);
|
|
|
| int xrandr_event_base_;
|
| scoped_ptr<TestHelperDelegate> helper_delegate_;
|
| @@ -104,8 +114,7 @@ NativeDisplayEventDispatcherX11Test::NativeDisplayEventDispatcherX11Test()
|
| : xrandr_event_base_(10),
|
| helper_delegate_(new TestHelperDelegate()),
|
| dispatcher_(new NativeDisplayEventDispatcherX11(helper_delegate_.get(),
|
| - xrandr_event_base_)) {
|
| -}
|
| + xrandr_event_base_)) {}
|
|
|
| NativeDisplayEventDispatcherX11Test::~NativeDisplayEventDispatcherX11Test() {}
|
|
|
| @@ -117,7 +126,10 @@ void NativeDisplayEventDispatcherX11Test::DispatchScreenChangeEvent() {
|
| }
|
|
|
| void NativeDisplayEventDispatcherX11Test::DispatchOutputChangeEvent(
|
| - RROutput output, RRCrtc crtc, RRMode mode, bool connected) {
|
| + RROutput output,
|
| + RRCrtc crtc,
|
| + RRMode mode,
|
| + bool connected) {
|
| XRROutputChangeNotifyEvent event = {0};
|
| event.type = xrandr_event_base_ + RRNotify;
|
| event.subtype = RRNotify_OutputChange;
|
| @@ -147,54 +159,54 @@ TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationAfterSecondEvent) {
|
| DispatchOutputChangeEvent(1, 10, 20, true);
|
|
|
| // Simulate addition of the first output to the cached output list.
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(2, 11, 20, true);
|
| EXPECT_EQ(2, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test, AvoidNotificationOnDuplicateEvent) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(1, 10, 20, true);
|
| EXPECT_EQ(0, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationOnDisconnect) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(1, 10, 20, false);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationOnModeChange) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(1, 10, 21, true);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationOnSecondOutput) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(2, 11, 20, true);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationOnDifferentCrtc) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(1, 11, 20, true);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| @@ -202,10 +214,10 @@ TEST_F(NativeDisplayEventDispatcherX11Test, CheckNotificationOnDifferentCrtc) {
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test,
|
| CheckNotificationOnSecondOutputDisconnect) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - outputs.push_back(CreateOutput(2, 11, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + outputs.push_back(CreateOutput(2, 11));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(2, 11, 20, false);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| @@ -213,20 +225,20 @@ TEST_F(NativeDisplayEventDispatcherX11Test,
|
|
|
| TEST_F(NativeDisplayEventDispatcherX11Test,
|
| AvoidDuplicateNotificationOnSecondOutputDisconnect) {
|
| - std::vector<OutputConfigurator::OutputSnapshot> outputs;
|
| - outputs.push_back(CreateOutput(1, 10, 20));
|
| - outputs.push_back(CreateOutput(2, 11, 20));
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + ScopedVector<DisplaySnapshot> outputs;
|
| + outputs.push_back(CreateOutput(1, 10));
|
| + outputs.push_back(CreateOutput(2, 11));
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(2, 11, 20, false);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
|
|
| // Simulate removal of second output from cached output list.
|
| outputs.erase(outputs.begin() + 1);
|
| - helper_delegate_->set_cached_outputs(outputs);
|
| + helper_delegate_->set_cached_outputs(outputs.get());
|
|
|
| DispatchOutputChangeEvent(2, 11, 20, false);
|
| EXPECT_EQ(1, helper_delegate_->num_calls_notify_observers());
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace ui
|
|
|