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

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: Get workspace event handler from workspace controller. 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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_types.h" 9 #include "ash/shelf/shelf_types.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void DragEnd() { 97 void DragEnd() {
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 EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey)); 105 EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey));
106 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
106 DragStart(); 107 DragStart();
107 gfx::Rect initial_bounds = window_->bounds(); 108 gfx::Rect initial_bounds = window_->bounds();
108 109
109 // Drag the panel slightly. The window should still be snapped to the 110 // Drag the panel slightly. The window should still be snapped to the
110 // launcher. 111 // launcher.
111 DragMove(dx * 5, dy * 5); 112 DragMove(dx * 5, dy * 5);
112 EXPECT_EQ(initial_bounds.x(), window_->bounds().x()); 113 EXPECT_EQ(initial_bounds.x(), window_->bounds().x());
113 EXPECT_EQ(initial_bounds.y(), window_->bounds().y()); 114 EXPECT_EQ(initial_bounds.y(), window_->bounds().y());
114 115
115 // Drag further out and the window should now move to the cursor. 116 // Drag further out and the window should now move to the cursor.
116 DragMove(dx * 100, dy * 100); 117 DragMove(dx * 100, dy * 100);
117 EXPECT_EQ(initial_bounds.x() + dx * 100, window_->bounds().x()); 118 EXPECT_EQ(initial_bounds.x() + dx * 100, window_->bounds().x());
118 EXPECT_EQ(initial_bounds.y() + dy * 100, window_->bounds().y()); 119 EXPECT_EQ(initial_bounds.y() + dy * 100, window_->bounds().y());
119 120
120 // The panel should be detached when the drag completes. 121 // The panel should be detached when the drag completes.
121 DragEnd(); 122 DragEnd();
122 EXPECT_FALSE(window_->GetProperty(kPanelAttachedKey)); 123 EXPECT_FALSE(window_->GetProperty(kPanelAttachedKey));
124 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
125 window_->parent()->id());
123 126
124 DragStart(); 127 DragStart();
125 // Drag the panel down. 128 // Drag the panel down.
126 DragMove(dx * -95, dy * -95); 129 DragMove(dx * -95, dy * -95);
127 // Release the mouse and the panel should be reattached. 130 // Release the mouse and the panel should be reattached.
128 DragEnd(); 131 DragEnd();
129 132
130 // The panel should be reattached and have snapped to the launcher. 133 // The panel should be reattached and have snapped to the launcher.
131 EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey)); 134 EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey));
132 EXPECT_EQ(initial_bounds.x(), window_->bounds().x()); 135 EXPECT_EQ(initial_bounds.x(), window_->bounds().x());
133 EXPECT_EQ(initial_bounds.y(), window_->bounds().y()); 136 EXPECT_EQ(initial_bounds.y(), window_->bounds().y());
137 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
134 } 138 }
135 139
136 aura::test::TestWindowDelegate delegate_; 140 aura::test::TestWindowDelegate delegate_;
137 scoped_ptr<aura::Window> window_; 141 scoped_ptr<aura::Window> window_;
138 scoped_ptr<PanelWindowResizer> resizer_; 142 scoped_ptr<PanelWindowResizer> resizer_;
139 aura::Window* panel_container_; 143 aura::Window* panel_container_;
140 internal::PanelLayoutManager* panel_layout_manager_; 144 internal::PanelLayoutManager* panel_layout_manager_;
141 gfx::Rect launcher_bounds_; 145 gfx::Rect launcher_bounds_;
142 146
143 private: 147 private:
(...skipping 26 matching lines...) Expand all
170 shell->GetPrimaryRootWindow()); 174 shell->GetPrimaryRootWindow());
171 DetachReattachTest(-1, 0); 175 DetachReattachTest(-1, 0);
172 } 176 }
173 177
174 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) { 178 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) {
175 ash::Shell* shell = ash::Shell::GetInstance(); 179 ash::Shell* shell = ash::Shell::GetInstance();
176 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); 180 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow());
177 DetachReattachTest(0, 1); 181 DetachReattachTest(0, 1);
178 } 182 }
179 183
184 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) {
185 DragStart();
186 DragMove(0, -100);
187 DragEnd();
188 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
189 window_->parent()->id());
190
191 // While moving the panel window should be moved to the panel container.
192 DragStart();
193 DragMove(20, 0);
194 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
195 DragEnd();
196
197 // When dropped it should return to the default container.
198 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
199 window_->parent()->id());
200 }
201
180 } // namespace internal 202 } // namespace internal
181 } // namespace ash 203 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698