Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/wm/panels/panel_window_resizer_unittest.cc

Issue 12441010: Attach panel while dragging to bring it in front of other panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_types.h" 10 #include "ash/shelf/shelf_types.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 resizer_->CompleteDrag(0); 98 resizer_->CompleteDrag(0);
99 resizer_.reset(); 99 resizer_.reset();
100 } 100 }
101 101
102 // Test dragging the panel slightly, then detaching, and then reattaching 102 // Test dragging the panel slightly, then detaching, and then reattaching
103 // dragging out by the vector (dx, dy). 103 // dragging out by the vector (dx, dy).
104 void DetachReattachTest(int dx, int dy) { 104 void DetachReattachTest(int dx, int dy) {
105 scoped_ptr<aura::Window> window( 105 scoped_ptr<aura::Window> window(
106 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); 106 CreatePanelWindow(gfx::Rect(0, 0, 201, 201)));
107 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); 107 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
108 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
108 DragStart(window.get()); 109 DragStart(window.get());
109 gfx::Rect initial_bounds = window->bounds(); 110 gfx::Rect initial_bounds = window->bounds();
110 111
111 // Drag the panel slightly. The window should still be snapped to the 112 // Drag the panel slightly. The window should still be snapped to the
112 // launcher. 113 // launcher.
113 DragMove(dx * 5, dy * 5); 114 DragMove(dx * 5, dy * 5);
114 EXPECT_EQ(initial_bounds.x(), window->bounds().x()); 115 EXPECT_EQ(initial_bounds.x(), window->bounds().x());
115 EXPECT_EQ(initial_bounds.y(), window->bounds().y()); 116 EXPECT_EQ(initial_bounds.y(), window->bounds().y());
116 117
117 // Drag further out and the window should now move to the cursor. 118 // Drag further out and the window should now move to the cursor.
118 DragMove(dx * 100, dy * 100); 119 DragMove(dx * 100, dy * 100);
119 EXPECT_EQ(initial_bounds.x() + dx * 100, window->bounds().x()); 120 EXPECT_EQ(initial_bounds.x() + dx * 100, window->bounds().x());
120 EXPECT_EQ(initial_bounds.y() + dy * 100, window->bounds().y()); 121 EXPECT_EQ(initial_bounds.y() + dy * 100, window->bounds().y());
121 122
122 // The panel should be detached when the drag completes. 123 // The panel should be detached when the drag completes.
123 DragEnd(); 124 DragEnd();
124 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 125 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
126 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
127 window->parent()->id());
125 128
126 DragStart(window.get()); 129 DragStart(window.get());
127 // Drag the panel down. 130 // Drag the panel down.
128 DragMove(dx * -95, dy * -95); 131 DragMove(dx * -95, dy * -95);
129 // Release the mouse and the panel should be reattached. 132 // Release the mouse and the panel should be reattached.
130 DragEnd(); 133 DragEnd();
131 134
132 // The panel should be reattached and have snapped to the launcher. 135 // The panel should be reattached and have snapped to the launcher.
133 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); 136 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
134 EXPECT_EQ(initial_bounds.x(), window->bounds().x()); 137 EXPECT_EQ(initial_bounds.x(), window->bounds().x());
135 EXPECT_EQ(initial_bounds.y(), window->bounds().y()); 138 EXPECT_EQ(initial_bounds.y(), window->bounds().y());
139 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
136 } 140 }
137 141
138 void TestWindowOrder(const std::vector<aura::Window*>& window_order) { 142 void TestWindowOrder(const std::vector<aura::Window*>& window_order) {
139 Launcher* launcher = Launcher::ForPrimaryDisplay(); 143 Launcher* launcher = Launcher::ForPrimaryDisplay();
140 int panel_index = model_->FirstPanelIndex(); 144 int panel_index = model_->FirstPanelIndex();
141 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count()); 145 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count());
142 for (std::vector<aura::Window*>::const_iterator iter = 146 for (std::vector<aura::Window*>::const_iterator iter =
143 window_order.begin(); iter != window_order.end(); 147 window_order.begin(); iter != window_order.end();
144 ++iter, ++panel_index) { 148 ++iter, ++panel_index) {
145 LauncherID id = launcher->delegate()->GetIDByWindow(*iter); 149 LauncherID id = launcher->delegate()->GetIDByWindow(*iter);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 shell->GetPrimaryRootWindow()); 218 shell->GetPrimaryRootWindow());
215 DetachReattachTest(-1, 0); 219 DetachReattachTest(-1, 0);
216 } 220 }
217 221
218 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) { 222 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) {
219 ash::Shell* shell = ash::Shell::GetInstance(); 223 ash::Shell* shell = ash::Shell::GetInstance();
220 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); 224 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow());
221 DetachReattachTest(0, 1); 225 DetachReattachTest(0, 1);
222 } 226 }
223 227
228 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) {
229 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Rect(0, 0, 201, 201)));
230 DragStart(window.get());
231 DragMove(0, -100);
232 DragEnd();
233 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
234 window->parent()->id());
235
236 // While moving the panel window should be moved to the panel container.
237 DragStart(window.get());
238 DragMove(20, 0);
239 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
240 DragEnd();
241
242 // When dropped it should return to the default container.
243 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
244 window->parent()->id());
245 }
246
224 TEST_F(PanelWindowResizerTest, DragReordersPanelsHorizontal) { 247 TEST_F(PanelWindowResizerTest, DragReordersPanelsHorizontal) {
225 DragAlongShelfReorder(-1, 0); 248 DragAlongShelfReorder(-1, 0);
226 } 249 }
227 250
228 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { 251 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) {
229 ash::Shell* shell = ash::Shell::GetInstance(); 252 ash::Shell* shell = ash::Shell::GetInstance();
230 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); 253 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow());
231 DragAlongShelfReorder(0, -1); 254 DragAlongShelfReorder(0, -1);
232 } 255 }
233 256
234 } // namespace internal 257 } // namespace internal
235 } // namespace ash 258 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698