OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/widget/desktop_aura/desktop_screen_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 explicit TestDesktopNativeWidgetAura( | 27 explicit TestDesktopNativeWidgetAura( |
28 views::internal::NativeWidgetDelegate* delegate) | 28 views::internal::NativeWidgetDelegate* delegate) |
29 : views::DesktopNativeWidgetAura(delegate) {} | 29 : views::DesktopNativeWidgetAura(delegate) {} |
30 virtual ~TestDesktopNativeWidgetAura() {} | 30 virtual ~TestDesktopNativeWidgetAura() {} |
31 | 31 |
32 void set_window_component(int window_component) { | 32 void set_window_component(int window_component) { |
33 window_component_ = window_component; | 33 window_component_ = window_component; |
34 } | 34 } |
35 | 35 |
36 // DesktopNativeWidgetAura: | 36 // DesktopNativeWidgetAura: |
37 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { | 37 virtual int GetNonClientComponent(const gfx::Point& point) const override { |
38 return window_component_; | 38 return window_component_; |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 int window_component_; | 42 int window_component_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(TestDesktopNativeWidgetAura); | 44 DISALLOW_COPY_AND_ASSIGN(TestDesktopNativeWidgetAura); |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 namespace views { | 49 namespace views { |
50 | 50 |
51 const int64 kFirstDisplay = 5321829; | 51 const int64 kFirstDisplay = 5321829; |
52 const int64 kSecondDisplay = 928310; | 52 const int64 kSecondDisplay = 928310; |
53 | 53 |
54 class DesktopScreenX11Test : public views::ViewsTestBase, | 54 class DesktopScreenX11Test : public views::ViewsTestBase, |
55 public gfx::DisplayObserver { | 55 public gfx::DisplayObserver { |
56 public: | 56 public: |
57 DesktopScreenX11Test() {} | 57 DesktopScreenX11Test() {} |
58 virtual ~DesktopScreenX11Test() {} | 58 virtual ~DesktopScreenX11Test() {} |
59 | 59 |
60 // Overridden from testing::Test: | 60 // Overridden from testing::Test: |
61 virtual void SetUp() OVERRIDE { | 61 virtual void SetUp() override { |
62 ViewsTestBase::SetUp(); | 62 ViewsTestBase::SetUp(); |
63 // Initialize the world to the single monitor case. | 63 // Initialize the world to the single monitor case. |
64 std::vector<gfx::Display> displays; | 64 std::vector<gfx::Display> displays; |
65 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); | 65 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); |
66 screen_.reset(new DesktopScreenX11(displays)); | 66 screen_.reset(new DesktopScreenX11(displays)); |
67 screen_->AddObserver(this); | 67 screen_->AddObserver(this); |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() OVERRIDE { | 70 virtual void TearDown() override { |
71 screen_.reset(); | 71 screen_.reset(); |
72 ViewsTestBase::TearDown(); | 72 ViewsTestBase::TearDown(); |
73 } | 73 } |
74 | 74 |
75 protected: | 75 protected: |
76 std::vector<gfx::Display> changed_display_; | 76 std::vector<gfx::Display> changed_display_; |
77 std::vector<gfx::Display> added_display_; | 77 std::vector<gfx::Display> added_display_; |
78 std::vector<gfx::Display> removed_display_; | 78 std::vector<gfx::Display> removed_display_; |
79 | 79 |
80 DesktopScreenX11* screen() { return screen_.get(); } | 80 DesktopScreenX11* screen() { return screen_.get(); } |
(...skipping 23 matching lines...) Expand all Loading... |
104 new views::DesktopNativeWidgetAura(toplevel); | 104 new views::DesktopNativeWidgetAura(toplevel); |
105 } | 105 } |
106 toplevel_params.bounds = bounds; | 106 toplevel_params.bounds = bounds; |
107 toplevel_params.remove_standard_frame = true; | 107 toplevel_params.remove_standard_frame = true; |
108 toplevel->Init(toplevel_params); | 108 toplevel->Init(toplevel_params); |
109 return toplevel; | 109 return toplevel; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 // Overridden from gfx::DisplayObserver: | 113 // Overridden from gfx::DisplayObserver: |
114 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 114 virtual void OnDisplayAdded(const gfx::Display& new_display) override { |
115 added_display_.push_back(new_display); | 115 added_display_.push_back(new_display); |
116 } | 116 } |
117 | 117 |
118 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { | 118 virtual void OnDisplayRemoved(const gfx::Display& old_display) override { |
119 removed_display_.push_back(old_display); | 119 removed_display_.push_back(old_display); |
120 } | 120 } |
121 | 121 |
122 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 122 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
123 uint32_t metrics) OVERRIDE { | 123 uint32_t metrics) override { |
124 changed_display_.push_back(display); | 124 changed_display_.push_back(display); |
125 } | 125 } |
126 | 126 |
127 scoped_ptr<DesktopScreenX11> screen_; | 127 scoped_ptr<DesktopScreenX11> screen_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11Test); | 129 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11Test); |
130 }; | 130 }; |
131 | 131 |
132 TEST_F(DesktopScreenX11Test, BoundsChangeSingleMonitor) { | 132 TEST_F(DesktopScreenX11Test, BoundsChangeSingleMonitor) { |
133 std::vector<gfx::Display> displays; | 133 std::vector<gfx::Display> displays; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 NotifyDisplaysChanged(displays); | 444 NotifyDisplaysChanged(displays); |
445 EXPECT_EQ(2u, changed_display_.size()); | 445 EXPECT_EQ(2u, changed_display_.size()); |
446 | 446 |
447 displays[0].set_device_scale_factor(1.f); | 447 displays[0].set_device_scale_factor(1.f); |
448 displays[1].set_device_scale_factor(1.f); | 448 displays[1].set_device_scale_factor(1.f); |
449 NotifyDisplaysChanged(displays); | 449 NotifyDisplaysChanged(displays); |
450 EXPECT_EQ(4u, changed_display_.size()); | 450 EXPECT_EQ(4u, changed_display_.size()); |
451 } | 451 } |
452 | 452 |
453 } // namespace views | 453 } // namespace views |
OLD | NEW |