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 "ash/wm/panels/panel_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_model.h" | 10 #include "ash/shelf/shelf_model.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
25 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
26 #include "ui/aura/window_event_dispatcher.h" | 26 #include "ui/aura/window_event_dispatcher.h" |
27 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/ui_base_types.h" | 29 #include "ui/base/ui_base_types.h" |
30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
31 #include "ui/wm/core/window_util.h" | 31 #include "ui/wm/core/window_util.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 namespace internal { | |
35 | 34 |
36 class PanelWindowResizerTest : public test::AshTestBase { | 35 class PanelWindowResizerTest : public test::AshTestBase { |
37 public: | 36 public: |
38 PanelWindowResizerTest() {} | 37 PanelWindowResizerTest() {} |
39 virtual ~PanelWindowResizerTest() {} | 38 virtual ~PanelWindowResizerTest() {} |
40 | 39 |
41 virtual void SetUp() OVERRIDE { | 40 virtual void SetUp() OVERRIDE { |
42 AshTestBase::SetUp(); | 41 AshTestBase::SetUp(); |
43 UpdateDisplay("600x400"); | 42 UpdateDisplay("600x400"); |
44 test::ShellTestApi test_api(Shell::GetInstance()); | 43 test::ShellTestApi test_api(Shell::GetInstance()); |
(...skipping 13 matching lines...) Expand all Loading... |
58 location.set_x(location.x() + delta_x); | 57 location.set_x(location.x() + delta_x); |
59 location.set_y(location.y() + delta_y); | 58 location.set_y(location.y() + delta_y); |
60 return location; | 59 return location; |
61 } | 60 } |
62 | 61 |
63 aura::Window* CreatePanelWindow(const gfx::Point& origin) { | 62 aura::Window* CreatePanelWindow(const gfx::Point& origin) { |
64 gfx::Rect bounds(origin, gfx::Size(101, 101)); | 63 gfx::Rect bounds(origin, gfx::Size(101, 101)); |
65 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 64 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
66 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); | 65 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); |
67 shelf_delegate_->AddShelfItem(window); | 66 shelf_delegate_->AddShelfItem(window); |
68 PanelLayoutManager* manager = | 67 PanelLayoutManager* manager = static_cast<PanelLayoutManager*>( |
69 static_cast<PanelLayoutManager*>( | 68 Shell::GetContainer(window->GetRootWindow(), |
70 Shell::GetContainer(window->GetRootWindow(), | 69 kShellWindowId_PanelContainer)->layout_manager()); |
71 internal::kShellWindowId_PanelContainer)-> | |
72 layout_manager()); | |
73 manager->Relayout(); | 70 manager->Relayout(); |
74 return window; | 71 return window; |
75 } | 72 } |
76 | 73 |
77 void DragStart(aura::Window* window) { | 74 void DragStart(aura::Window* window) { |
78 resizer_.reset(CreateWindowResizer( | 75 resizer_.reset(CreateWindowResizer( |
79 window, | 76 window, |
80 window->bounds().origin(), | 77 window->bounds().origin(), |
81 HTCAPTION, | 78 HTCAPTION, |
82 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); | 79 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); |
(...skipping 13 matching lines...) Expand all Loading... |
96 resizer_->RevertDrag(); | 93 resizer_->RevertDrag(); |
97 resizer_.reset(); | 94 resizer_.reset(); |
98 } | 95 } |
99 | 96 |
100 // Test dragging the panel slightly, then detaching, and then reattaching | 97 // Test dragging the panel slightly, then detaching, and then reattaching |
101 // dragging out by the vector (dx, dy). | 98 // dragging out by the vector (dx, dy). |
102 void DetachReattachTest(aura::Window* window, int dx, int dy) { | 99 void DetachReattachTest(aura::Window* window, int dx, int dy) { |
103 wm::WindowState* window_state = wm::GetWindowState(window); | 100 wm::WindowState* window_state = wm::GetWindowState(window); |
104 EXPECT_TRUE(window_state->panel_attached()); | 101 EXPECT_TRUE(window_state->panel_attached()); |
105 aura::Window* root_window = window->GetRootWindow(); | 102 aura::Window* root_window = window->GetRootWindow(); |
106 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 103 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
107 DragStart(window); | 104 DragStart(window); |
108 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 105 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
109 | 106 |
110 // Drag the panel slightly. The window should still be snapped to the | 107 // Drag the panel slightly. The window should still be snapped to the |
111 // launcher. | 108 // launcher. |
112 DragMove(dx * 5, dy * 5); | 109 DragMove(dx * 5, dy * 5); |
113 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 110 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
114 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y()); | 111 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y()); |
115 | 112 |
116 // Drag further out and the window should now move to the cursor. | 113 // Drag further out and the window should now move to the cursor. |
117 DragMove(dx * 100, dy * 100); | 114 DragMove(dx * 100, dy * 100); |
118 EXPECT_EQ(initial_bounds.x() + dx * 100, window->GetBoundsInScreen().x()); | 115 EXPECT_EQ(initial_bounds.x() + dx * 100, window->GetBoundsInScreen().x()); |
119 EXPECT_EQ(initial_bounds.y() + dy * 100, window->GetBoundsInScreen().y()); | 116 EXPECT_EQ(initial_bounds.y() + dy * 100, window->GetBoundsInScreen().y()); |
120 | 117 |
121 // The panel should be detached when the drag completes. | 118 // The panel should be detached when the drag completes. |
122 DragEnd(); | 119 DragEnd(); |
123 | 120 |
124 EXPECT_FALSE(window_state->panel_attached()); | 121 EXPECT_FALSE(window_state->panel_attached()); |
125 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 122 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
126 window->parent()->id()); | |
127 EXPECT_EQ(root_window, window->GetRootWindow()); | 123 EXPECT_EQ(root_window, window->GetRootWindow()); |
128 | 124 |
129 DragStart(window); | 125 DragStart(window); |
130 // Drag the panel down. | 126 // Drag the panel down. |
131 DragMove(dx * -95, dy * -95); | 127 DragMove(dx * -95, dy * -95); |
132 // Release the mouse and the panel should be reattached. | 128 // Release the mouse and the panel should be reattached. |
133 DragEnd(); | 129 DragEnd(); |
134 | 130 |
135 // The panel should be reattached and have snapped to the launcher. | 131 // The panel should be reattached and have snapped to the launcher. |
136 EXPECT_TRUE(window_state->panel_attached()); | 132 EXPECT_TRUE(window_state->panel_attached()); |
137 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 133 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
138 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y()); | 134 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y()); |
139 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 135 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
140 } | 136 } |
141 | 137 |
142 void TestWindowOrder(const std::vector<aura::Window*>& window_order) { | 138 void TestWindowOrder(const std::vector<aura::Window*>& window_order) { |
143 int panel_index = model_->FirstPanelIndex(); | 139 int panel_index = model_->FirstPanelIndex(); |
144 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count()); | 140 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count()); |
145 for (std::vector<aura::Window*>::const_iterator iter = | 141 for (std::vector<aura::Window*>::const_iterator iter = |
146 window_order.begin(); iter != window_order.end(); | 142 window_order.begin(); iter != window_order.end(); |
147 ++iter, ++panel_index) { | 143 ++iter, ++panel_index) { |
148 ShelfID id = GetShelfIDForWindow(*iter); | 144 ShelfID id = GetShelfIDForWindow(*iter); |
149 EXPECT_EQ(id, model_->items()[panel_index].id); | 145 EXPECT_EQ(id, model_->items()[panel_index].id); |
(...skipping 28 matching lines...) Expand all Loading... |
178 DragMove(-400 * dx, -400 * dy); | 174 DragMove(-400 * dx, -400 * dy); |
179 TestWindowOrder(window_order_original); | 175 TestWindowOrder(window_order_original); |
180 DragEnd(); | 176 DragEnd(); |
181 | 177 |
182 // Expect original order. | 178 // Expect original order. |
183 TestWindowOrder(window_order_original); | 179 TestWindowOrder(window_order_original); |
184 } | 180 } |
185 | 181 |
186 private: | 182 private: |
187 scoped_ptr<WindowResizer> resizer_; | 183 scoped_ptr<WindowResizer> resizer_; |
188 internal::PanelLayoutManager* panel_layout_manager_; | 184 PanelLayoutManager* panel_layout_manager_; |
189 ShelfModel* model_; | 185 ShelfModel* model_; |
190 test::TestShelfDelegate* shelf_delegate_; | 186 test::TestShelfDelegate* shelf_delegate_; |
191 | 187 |
192 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); | 188 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); |
193 }; | 189 }; |
194 | 190 |
195 class PanelWindowResizerTextDirectionTest | 191 class PanelWindowResizerTextDirectionTest |
196 : public PanelWindowResizerTest, | 192 : public PanelWindowResizerTest, |
197 public testing::WithParamInterface<bool> { | 193 public testing::WithParamInterface<bool> { |
198 public: | 194 public: |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 CreatePanelWindow(gfx::Point(0, 0))); | 299 CreatePanelWindow(gfx::Point(0, 0))); |
304 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 300 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
305 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 301 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
306 DragStart(window.get()); | 302 DragStart(window.get()); |
307 DragMove(0, -100); | 303 DragMove(0, -100); |
308 DragEnd(); | 304 DragEnd(); |
309 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 305 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
310 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 306 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
311 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 307 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
312 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); | 308 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); |
313 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 309 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
314 | 310 |
315 DragStart(window.get()); | 311 DragStart(window.get()); |
316 DragMove(500, 0); | 312 DragMove(500, 0); |
317 DragEnd(); | 313 DragEnd(); |
318 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 314 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
319 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 315 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
320 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 316 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
321 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); | 317 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); |
322 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 318 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
323 } | 319 } |
324 | 320 |
325 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { | 321 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { |
326 if (!SupportsMultipleDisplays()) | 322 if (!SupportsMultipleDisplays()) |
327 return; | 323 return; |
328 | 324 |
329 UpdateDisplay("600x400,600x400"); | 325 UpdateDisplay("600x400,600x400"); |
330 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 326 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
331 scoped_ptr<aura::Window> window( | 327 scoped_ptr<aura::Window> window( |
332 CreatePanelWindow(gfx::Point(0, 0))); | 328 CreatePanelWindow(gfx::Point(0, 0))); |
333 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 329 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
334 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 330 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
335 DragStart(window.get()); | 331 DragStart(window.get()); |
336 DragMove(500, -100); | 332 DragMove(500, -100); |
337 DragEnd(); | 333 DragEnd(); |
338 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 334 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
339 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 335 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
340 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 336 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
341 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); | 337 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); |
342 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 338 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
343 } | 339 } |
344 | 340 |
345 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { | 341 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { |
346 if (!SupportsMultipleDisplays()) | 342 if (!SupportsMultipleDisplays()) |
347 return; | 343 return; |
348 | 344 |
349 UpdateDisplay("600x400,600x600"); | 345 UpdateDisplay("600x400,600x600"); |
350 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 346 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
351 scoped_ptr<aura::Window> window( | 347 scoped_ptr<aura::Window> window( |
352 CreatePanelWindow(gfx::Point(0, 0))); | 348 CreatePanelWindow(gfx::Point(0, 0))); |
(...skipping 12 matching lines...) Expand all Loading... |
365 DragMove(500, 295); | 361 DragMove(500, 295); |
366 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 362 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
367 | 363 |
368 // Should stick to other launcher. | 364 // Should stick to other launcher. |
369 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 365 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
370 DragEnd(); | 366 DragEnd(); |
371 | 367 |
372 // When dropped should move to second display's panel container. | 368 // When dropped should move to second display's panel container. |
373 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 369 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
374 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 370 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
375 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 371 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
376 } | 372 } |
377 | 373 |
378 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { | 374 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { |
379 if (!SupportsMultipleDisplays()) | 375 if (!SupportsMultipleDisplays()) |
380 return; | 376 return; |
381 | 377 |
382 UpdateDisplay("600x400,600x600"); | 378 UpdateDisplay("600x400,600x600"); |
383 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 379 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
384 scoped_ptr<aura::Window> window( | 380 scoped_ptr<aura::Window> window( |
385 CreatePanelWindow(gfx::Point(0, 0))); | 381 CreatePanelWindow(gfx::Point(0, 0))); |
386 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 382 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
387 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 383 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
388 | 384 |
389 // Drag the window just above the other display's launcher. | 385 // Drag the window just above the other display's launcher. |
390 DragStart(window.get()); | 386 DragStart(window.get()); |
391 DragMove(500, 195); | 387 DragMove(500, 195); |
392 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 388 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
393 | 389 |
394 // Should stick to other launcher. | 390 // Should stick to other launcher. |
395 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 391 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
396 DragEnd(); | 392 DragEnd(); |
397 | 393 |
398 // When dropped should move to second display's panel container. | 394 // When dropped should move to second display's panel container. |
399 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 395 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
400 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 396 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
401 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 397 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
402 } | 398 } |
403 | 399 |
404 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { | 400 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { |
405 if (!SupportsMultipleDisplays()) | 401 if (!SupportsMultipleDisplays()) |
406 return; | 402 return; |
407 | 403 |
408 UpdateDisplay("600x400,600x600"); | 404 UpdateDisplay("600x400,600x600"); |
409 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 405 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
410 scoped_ptr<aura::Window> window( | 406 scoped_ptr<aura::Window> window( |
411 CreatePanelWindow(gfx::Point(0, 0))); | 407 CreatePanelWindow(gfx::Point(0, 0))); |
(...skipping 12 matching lines...) Expand all Loading... |
424 DragStart(window.get()); | 420 DragStart(window.get()); |
425 DragMove(500, 250); | 421 DragMove(500, 250); |
426 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 422 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
427 EXPECT_GT(window->GetBoundsInScreen().y(), | 423 EXPECT_GT(window->GetBoundsInScreen().y(), |
428 initial_bounds.y() + 200); | 424 initial_bounds.y() + 200); |
429 DragEnd(); | 425 DragEnd(); |
430 | 426 |
431 // When dropped should move to second display's panel container. | 427 // When dropped should move to second display's panel container. |
432 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 428 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
433 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 429 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
434 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 430 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
435 EXPECT_TRUE(window->IsVisible()); | 431 EXPECT_TRUE(window->IsVisible()); |
436 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive()); | 432 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive()); |
437 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 433 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
438 } | 434 } |
439 | 435 |
440 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { | 436 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { |
441 scoped_ptr<aura::Window> window( | 437 scoped_ptr<aura::Window> window( |
442 CreatePanelWindow(gfx::Point(0, 0))); | 438 CreatePanelWindow(gfx::Point(0, 0))); |
443 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 439 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
444 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 440 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
445 DragStart(window.get()); | 441 DragStart(window.get()); |
446 DragMove(0, -100); | 442 DragMove(0, -100); |
447 DragRevert(); | 443 DragRevert(); |
448 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 444 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
449 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 445 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
450 | 446 |
451 // Detach panel. | 447 // Detach panel. |
452 DragStart(window.get()); | 448 DragStart(window.get()); |
453 DragMove(0, -100); | 449 DragMove(0, -100); |
454 DragEnd(); | 450 DragEnd(); |
455 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); | 451 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); |
456 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 452 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
457 | 453 |
458 // Drag back to launcher. | 454 // Drag back to launcher. |
459 DragStart(window.get()); | 455 DragStart(window.get()); |
460 DragMove(0, 100); | 456 DragMove(0, 100); |
461 | 457 |
462 // When the drag is reverted it should remain detached. | 458 // When the drag is reverted it should remain detached. |
463 DragRevert(); | 459 DragRevert(); |
464 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); | 460 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); |
465 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 461 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
466 } | 462 } |
467 | 463 |
468 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) { | 464 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) { |
469 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 465 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
470 DragStart(window.get()); | 466 DragStart(window.get()); |
471 DragMove(0, -100); | 467 DragMove(0, -100); |
472 DragEnd(); | 468 DragEnd(); |
473 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 469 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
474 | 470 |
475 // While moving the panel window should be moved to the panel container. | 471 // While moving the panel window should be moved to the panel container. |
476 DragStart(window.get()); | 472 DragStart(window.get()); |
477 DragMove(20, 0); | 473 DragMove(20, 0); |
478 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 474 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
479 DragEnd(); | 475 DragEnd(); |
480 | 476 |
481 // When dropped it should return to the default container. | 477 // When dropped it should return to the default container. |
482 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 478 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
483 window->parent()->id()); | |
484 } | 479 } |
485 | 480 |
486 TEST_P(PanelWindowResizerTextDirectionTest, DragReordersPanelsHorizontal) { | 481 TEST_P(PanelWindowResizerTextDirectionTest, DragReordersPanelsHorizontal) { |
487 if (!SupportsHostWindowResize()) | 482 if (!SupportsHostWindowResize()) |
488 return; | 483 return; |
489 | 484 |
490 DragAlongShelfReorder(base::i18n::IsRTL() ? 1 : -1, 0); | 485 DragAlongShelfReorder(base::i18n::IsRTL() ? 1 : -1, 0); |
491 } | 486 } |
492 | 487 |
493 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { | 488 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { |
(...skipping 19 matching lines...) Expand all Loading... |
513 window->parent()->AddChild(child.get()); | 508 window->parent()->AddChild(child.get()); |
514 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 509 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
515 | 510 |
516 // Drag the child to the shelf. Its new position should not be overridden. | 511 // Drag the child to the shelf. Its new position should not be overridden. |
517 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); | 512 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); |
518 const int dy = window->GetBoundsInScreen().bottom() - | 513 const int dy = window->GetBoundsInScreen().bottom() - |
519 child->GetBoundsInScreen().bottom(); | 514 child->GetBoundsInScreen().bottom(); |
520 DragStart(child.get()); | 515 DragStart(child.get()); |
521 DragMove(50, dy); | 516 DragMove(50, dy); |
522 // While moving the transient child window should be in the panel container. | 517 // While moving the transient child window should be in the panel container. |
523 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); | 518 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); |
524 DragEnd(); | 519 DragEnd(); |
525 // Child should move, |window| should not. | 520 // Child should move, |window| should not. |
526 EXPECT_EQ(gfx::Point(20 + 50, 20 + dy).ToString(), | 521 EXPECT_EQ(gfx::Point(20 + 50, 20 + dy).ToString(), |
527 child->GetBoundsInScreen().origin().ToString()); | 522 child->GetBoundsInScreen().origin().ToString()); |
528 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 523 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
529 | 524 |
530 // Drag the child along the the shelf past the |window|. | 525 // Drag the child along the the shelf past the |window|. |
531 // Its new position should not be overridden. | 526 // Its new position should not be overridden. |
532 DragStart(child.get()); | 527 DragStart(child.get()); |
533 DragMove(350, 0); | 528 DragMove(350, 0); |
534 // While moving the transient child window should be in the panel container. | 529 // While moving the transient child window should be in the panel container. |
535 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); | 530 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); |
536 DragEnd(); | 531 DragEnd(); |
537 // |child| should move, |window| should not. | 532 // |child| should move, |window| should not. |
538 EXPECT_EQ(gfx::Point(20 + 50 + 350, 20 + dy).ToString(), | 533 EXPECT_EQ(gfx::Point(20 + 50 + 350, 20 + dy).ToString(), |
539 child->GetBoundsInScreen().origin().ToString()); | 534 child->GetBoundsInScreen().origin().ToString()); |
540 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 535 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
541 | 536 |
542 DragStart(window.get()); | 537 DragStart(window.get()); |
543 DragMove(0, -100); | 538 DragMove(0, -100); |
544 // While moving the windows should be in the panel container. | 539 // While moving the windows should be in the panel container. |
545 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 540 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
546 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); | 541 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); |
547 DragEnd(); | 542 DragEnd(); |
548 // When dropped they should return to the default container. | 543 // When dropped they should return to the default container. |
549 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 544 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
550 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); | 545 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id()); |
551 | 546 |
552 // While moving the window and child should be moved to the panel container. | 547 // While moving the window and child should be moved to the panel container. |
553 DragStart(window.get()); | 548 DragStart(window.get()); |
554 DragMove(20, 0); | 549 DragMove(20, 0); |
555 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 550 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
556 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); | 551 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); |
557 DragEnd(); | 552 DragEnd(); |
558 | 553 |
559 // When dropped they should return to the default container. | 554 // When dropped they should return to the default container. |
560 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 555 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
561 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); | 556 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id()); |
562 } | 557 } |
563 | 558 |
564 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 559 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
565 testing::Bool()); | 560 testing::Bool()); |
566 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 561 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
567 PanelWindowResizerTransientTest, | 562 PanelWindowResizerTransientTest, |
568 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 563 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
569 ui::wm::WINDOW_TYPE_PANEL, | 564 ui::wm::WINDOW_TYPE_PANEL, |
570 ui::wm::WINDOW_TYPE_POPUP)); | 565 ui::wm::WINDOW_TYPE_POPUP)); |
571 | 566 |
572 } // namespace internal | |
573 } // namespace ash | 567 } // namespace ash |
OLD | NEW |