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 "ash/wm/workspace/multi_window_resize_controller.h" | 5 #include "ash/wm/workspace/multi_window_resize_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/test/shell_test_api.h" | 9 #include "ash/test/shell_test_api.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "ash/wm/workspace/workspace_event_handler_test_helper.h" |
11 #include "ash/wm/workspace_controller.h" | 12 #include "ash/wm/workspace_controller.h" |
12 #include "ash/wm/workspace_controller_test_helper.h" | 13 #include "ash/wm/workspace_controller_test_helper.h" |
13 #include "ash/wm/workspace/workspace_event_handler_test_helper.h" | |
14 #include "ui/aura/test/event_generator.h" | |
15 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
17 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 17 #include "ui/events/test/event_generator.h" |
18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 class MultiWindowResizeControllerTest : public test::AshTestBase { | 23 class MultiWindowResizeControllerTest : public test::AshTestBase { |
24 public: | 24 public: |
25 MultiWindowResizeControllerTest() : resize_controller_(NULL) {} | 25 MultiWindowResizeControllerTest() : resize_controller_(NULL) {} |
26 virtual ~MultiWindowResizeControllerTest() {} | 26 virtual ~MultiWindowResizeControllerTest() {} |
27 | 27 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Assertions around moving mouse over 2 windows. | 98 // Assertions around moving mouse over 2 windows. |
99 TEST_F(MultiWindowResizeControllerTest, BasicTests) { | 99 TEST_F(MultiWindowResizeControllerTest, BasicTests) { |
100 aura::test::TestWindowDelegate delegate1; | 100 aura::test::TestWindowDelegate delegate1; |
101 scoped_ptr<aura::Window> w1( | 101 scoped_ptr<aura::Window> w1( |
102 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); | 102 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); |
103 delegate1.set_window_component(HTRIGHT); | 103 delegate1.set_window_component(HTRIGHT); |
104 aura::test::TestWindowDelegate delegate2; | 104 aura::test::TestWindowDelegate delegate2; |
105 scoped_ptr<aura::Window> w2( | 105 scoped_ptr<aura::Window> w2( |
106 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); | 106 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); |
107 delegate2.set_window_component(HTRIGHT); | 107 delegate2.set_window_component(HTRIGHT); |
108 aura::test::EventGenerator generator(w1->GetRootWindow()); | 108 ui::test::EventGenerator generator(w1->GetRootWindow()); |
109 generator.MoveMouseTo(w1->bounds().CenterPoint()); | 109 generator.MoveMouseTo(w1->bounds().CenterPoint()); |
110 EXPECT_TRUE(HasPendingShow()); | 110 EXPECT_TRUE(HasPendingShow()); |
111 EXPECT_TRUE(IsShowing()); | 111 EXPECT_TRUE(IsShowing()); |
112 EXPECT_FALSE(HasPendingHide()); | 112 EXPECT_FALSE(HasPendingHide()); |
113 | 113 |
114 // Force a show now. | 114 // Force a show now. |
115 ShowNow(); | 115 ShowNow(); |
116 EXPECT_FALSE(HasPendingShow()); | 116 EXPECT_FALSE(HasPendingShow()); |
117 EXPECT_TRUE(IsShowing()); | 117 EXPECT_TRUE(IsShowing()); |
118 EXPECT_FALSE(HasPendingHide()); | 118 EXPECT_FALSE(HasPendingHide()); |
(...skipping 10 matching lines...) Expand all Loading... |
129 // Makes sure deleting a window hides. | 129 // Makes sure deleting a window hides. |
130 TEST_F(MultiWindowResizeControllerTest, DeleteWindow) { | 130 TEST_F(MultiWindowResizeControllerTest, DeleteWindow) { |
131 aura::test::TestWindowDelegate delegate1; | 131 aura::test::TestWindowDelegate delegate1; |
132 scoped_ptr<aura::Window> w1( | 132 scoped_ptr<aura::Window> w1( |
133 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); | 133 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); |
134 delegate1.set_window_component(HTRIGHT); | 134 delegate1.set_window_component(HTRIGHT); |
135 aura::test::TestWindowDelegate delegate2; | 135 aura::test::TestWindowDelegate delegate2; |
136 scoped_ptr<aura::Window> w2( | 136 scoped_ptr<aura::Window> w2( |
137 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); | 137 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); |
138 delegate2.set_window_component(HTRIGHT); | 138 delegate2.set_window_component(HTRIGHT); |
139 aura::test::EventGenerator generator(w1->GetRootWindow()); | 139 ui::test::EventGenerator generator(w1->GetRootWindow()); |
140 generator.MoveMouseTo(w1->bounds().CenterPoint()); | 140 generator.MoveMouseTo(w1->bounds().CenterPoint()); |
141 EXPECT_TRUE(HasPendingShow()); | 141 EXPECT_TRUE(HasPendingShow()); |
142 EXPECT_TRUE(IsShowing()); | 142 EXPECT_TRUE(IsShowing()); |
143 EXPECT_FALSE(HasPendingHide()); | 143 EXPECT_FALSE(HasPendingHide()); |
144 | 144 |
145 // Force a show now. | 145 // Force a show now. |
146 ShowNow(); | 146 ShowNow(); |
147 EXPECT_FALSE(HasPendingShow()); | 147 EXPECT_FALSE(HasPendingShow()); |
148 EXPECT_TRUE(IsShowing()); | 148 EXPECT_TRUE(IsShowing()); |
149 EXPECT_FALSE(HasPendingHide()); | 149 EXPECT_FALSE(HasPendingHide()); |
(...skipping 22 matching lines...) Expand all Loading... |
172 // Tests resizing. | 172 // Tests resizing. |
173 TEST_F(MultiWindowResizeControllerTest, Drag) { | 173 TEST_F(MultiWindowResizeControllerTest, Drag) { |
174 aura::test::TestWindowDelegate delegate1; | 174 aura::test::TestWindowDelegate delegate1; |
175 scoped_ptr<aura::Window> w1( | 175 scoped_ptr<aura::Window> w1( |
176 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); | 176 CreateTestWindow(&delegate1, gfx::Rect(0, 0, 100, 100))); |
177 delegate1.set_window_component(HTRIGHT); | 177 delegate1.set_window_component(HTRIGHT); |
178 aura::test::TestWindowDelegate delegate2; | 178 aura::test::TestWindowDelegate delegate2; |
179 scoped_ptr<aura::Window> w2( | 179 scoped_ptr<aura::Window> w2( |
180 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); | 180 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); |
181 delegate2.set_window_component(HTRIGHT); | 181 delegate2.set_window_component(HTRIGHT); |
182 aura::test::EventGenerator generator(w1->GetRootWindow()); | 182 ui::test::EventGenerator generator(w1->GetRootWindow()); |
183 generator.MoveMouseTo(w1->bounds().CenterPoint()); | 183 generator.MoveMouseTo(w1->bounds().CenterPoint()); |
184 EXPECT_TRUE(HasPendingShow()); | 184 EXPECT_TRUE(HasPendingShow()); |
185 EXPECT_TRUE(IsShowing()); | 185 EXPECT_TRUE(IsShowing()); |
186 EXPECT_FALSE(HasPendingHide()); | 186 EXPECT_FALSE(HasPendingHide()); |
187 | 187 |
188 // Force a show now. | 188 // Force a show now. |
189 ShowNow(); | 189 ShowNow(); |
190 EXPECT_FALSE(HasPendingShow()); | 190 EXPECT_FALSE(HasPendingShow()); |
191 EXPECT_TRUE(IsShowing()); | 191 EXPECT_TRUE(IsShowing()); |
192 EXPECT_FALSE(HasPendingHide()); | 192 EXPECT_FALSE(HasPendingHide()); |
(...skipping 27 matching lines...) Expand all Loading... |
220 delegate1.set_window_component(HTRIGHT); | 220 delegate1.set_window_component(HTRIGHT); |
221 aura::test::TestWindowDelegate delegate2; | 221 aura::test::TestWindowDelegate delegate2; |
222 scoped_ptr<aura::Window> w2( | 222 scoped_ptr<aura::Window> w2( |
223 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); | 223 CreateTestWindow(&delegate2, gfx::Rect(100, 0, 100, 100))); |
224 delegate2.set_window_component(HTRIGHT); | 224 delegate2.set_window_component(HTRIGHT); |
225 aura::test::TestWindowDelegate delegate3; | 225 aura::test::TestWindowDelegate delegate3; |
226 scoped_ptr<aura::Window> w3( | 226 scoped_ptr<aura::Window> w3( |
227 CreateTestWindow(&delegate3, gfx::Rect(200, 0, 100, 100))); | 227 CreateTestWindow(&delegate3, gfx::Rect(200, 0, 100, 100))); |
228 delegate3.set_window_component(HTRIGHT); | 228 delegate3.set_window_component(HTRIGHT); |
229 | 229 |
230 aura::test::EventGenerator generator(w1->GetRootWindow()); | 230 ui::test::EventGenerator generator(w1->GetRootWindow()); |
231 generator.MoveMouseTo(w1->bounds().CenterPoint()); | 231 generator.MoveMouseTo(w1->bounds().CenterPoint()); |
232 EXPECT_TRUE(HasPendingShow()); | 232 EXPECT_TRUE(HasPendingShow()); |
233 EXPECT_TRUE(IsShowing()); | 233 EXPECT_TRUE(IsShowing()); |
234 EXPECT_FALSE(HasPendingHide()); | 234 EXPECT_FALSE(HasPendingHide()); |
235 EXPECT_FALSE(HasTarget(w3.get())); | 235 EXPECT_FALSE(HasTarget(w3.get())); |
236 | 236 |
237 ShowNow(); | 237 ShowNow(); |
238 EXPECT_FALSE(HasPendingShow()); | 238 EXPECT_FALSE(HasPendingShow()); |
239 EXPECT_TRUE(IsShowing()); | 239 EXPECT_TRUE(IsShowing()); |
240 EXPECT_FALSE(HasPendingHide()); | 240 EXPECT_FALSE(HasPendingHide()); |
241 | 241 |
242 // w3 should be picked up when resize is started. | 242 // w3 should be picked up when resize is started. |
243 gfx::Rect bounds(resize_widget()->GetWindowBoundsInScreen()); | 243 gfx::Rect bounds(resize_widget()->GetWindowBoundsInScreen()); |
244 generator.MoveMouseTo(bounds.x() + 1, bounds.y() + 1); | 244 generator.MoveMouseTo(bounds.x() + 1, bounds.y() + 1); |
245 generator.PressLeftButton(); | 245 generator.PressLeftButton(); |
246 generator.MoveMouseTo(bounds.x() + 11, bounds.y() + 10); | 246 generator.MoveMouseTo(bounds.x() + 11, bounds.y() + 10); |
247 | 247 |
248 EXPECT_TRUE(HasTarget(w3.get())); | 248 EXPECT_TRUE(HasTarget(w3.get())); |
249 | 249 |
250 // Release the mouse. The resizer should still be visible and a subsequent | 250 // Release the mouse. The resizer should still be visible and a subsequent |
251 // press should not trigger a DCHECK. | 251 // press should not trigger a DCHECK. |
252 generator.ReleaseLeftButton(); | 252 generator.ReleaseLeftButton(); |
253 EXPECT_TRUE(IsShowing()); | 253 EXPECT_TRUE(IsShowing()); |
254 generator.PressLeftButton(); | 254 generator.PressLeftButton(); |
255 } | 255 } |
256 | 256 |
257 } // namespace ash | 257 } // namespace ash |
OLD | NEW |