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

Side by Side Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (rebase) Created 7 years, 6 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
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ash/wm/panels/panel_layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual void TearDown() OVERRIDE { 87 virtual void TearDown() OVERRIDE {
88 window_.reset(); 88 window_.reset();
89 always_on_top_window_.reset(); 89 always_on_top_window_.reset();
90 system_modal_window_.reset(); 90 system_modal_window_.reset();
91 transient_parent_.reset(); 91 transient_parent_.reset();
92 panel_window_.reset(); 92 panel_window_.reset();
93 AshTestBase::TearDown(); 93 AshTestBase::TearDown();
94 } 94 }
95 95
96 protected: 96 protected:
97 gfx::Point CalculateDragPoint(const DragWindowResizer& resizer, 97 gfx::Point CalculateDragPoint(const WindowResizer& resizer,
98 int delta_x, 98 int delta_x,
99 int delta_y) const { 99 int delta_y) const {
100 gfx::Point location = resizer.GetInitialLocationInParentForTest(); 100 gfx::Point location = resizer.GetInitialLocation();
101 location.set_x(location.x() + delta_x); 101 location.set_x(location.x() + delta_x);
102 location.set_y(location.y() + delta_y); 102 location.set_y(location.y() + delta_y);
103 return location; 103 return location;
104 } 104 }
105 105
106 internal::ShelfLayoutManager* shelf_layout_manager() { 106 internal::ShelfLayoutManager* shelf_layout_manager() {
107 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 107 return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
108 } 108 }
109 109
110 static DragWindowResizer* CreateDragWindowResizer( 110 static WindowResizer* CreateDragWindowResizer(
111 aura::Window* window, 111 aura::Window* window,
112 const gfx::Point& point_in_parent, 112 const gfx::Point& point_in_parent,
113 int window_component) { 113 int window_component) {
114 return static_cast<DragWindowResizer*>(CreateWindowResizer( 114 return CreateWindowResizer(
115 window, point_in_parent, window_component, 115 window,
116 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); 116 point_in_parent,
117 window_component,
118 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
117 } 119 }
118 120
119 aura::test::TestWindowDelegate delegate_; 121 aura::test::TestWindowDelegate delegate_;
120 aura::test::TestWindowDelegate delegate2_; 122 aura::test::TestWindowDelegate delegate2_;
121 aura::test::TestWindowDelegate delegate3_; 123 aura::test::TestWindowDelegate delegate3_;
122 aura::test::TestWindowDelegate delegate4_; 124 aura::test::TestWindowDelegate delegate4_;
123 aura::test::TestWindowDelegate delegate5_; 125 aura::test::TestWindowDelegate delegate5_;
124 aura::test::TestWindowDelegate delegate6_; 126 aura::test::TestWindowDelegate delegate6_;
125 127
126 scoped_ptr<aura::Window> window_; 128 scoped_ptr<aura::Window> window_;
(...skipping 17 matching lines...) Expand all
144 UpdateDisplay("800x600,800x600"); 146 UpdateDisplay("800x600,800x600");
145 shelf_layout_manager()->LayoutShelf(); 147 shelf_layout_manager()->LayoutShelf();
146 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 148 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
147 ASSERT_EQ(2U, root_windows.size()); 149 ASSERT_EQ(2U, root_windows.size());
148 150
149 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 151 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
150 Shell::GetScreen()->GetPrimaryDisplay()); 152 Shell::GetScreen()->GetPrimaryDisplay());
151 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 153 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
152 { 154 {
153 // Grab (0, 0) of the window. 155 // Grab (0, 0) of the window.
154 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 156 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
155 window_.get(), gfx::Point(), HTCAPTION)); 157 window_.get(), gfx::Point(), HTCAPTION));
156 ASSERT_TRUE(resizer.get()); 158 ASSERT_TRUE(resizer.get());
157 // Drag the pointer to the right. Once it reaches the right edge of the 159 // Drag the pointer to the right. Once it reaches the right edge of the
158 // primary display, it warps to the secondary. 160 // primary display, it warps to the secondary.
159 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 161 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
160 resizer->CompleteDrag(0); 162 resizer->CompleteDrag(0);
161 // The whole window is on the secondary display now. The parent should be 163 // The whole window is on the secondary display now. The parent should be
162 // changed. 164 // changed.
163 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 165 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
164 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); 166 EXPECT_EQ("0,10 50x60", window_->bounds().ToString());
165 } 167 }
166 168
167 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 169 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
168 Shell::GetScreen()->GetPrimaryDisplay()); 170 Shell::GetScreen()->GetPrimaryDisplay());
169 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 171 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
170 { 172 {
171 // Grab (0, 0) of the window and move the pointer to (790, 10). 173 // Grab (0, 0) of the window and move the pointer to (790, 10).
172 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 174 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
173 window_.get(), gfx::Point(), HTCAPTION)); 175 window_.get(), gfx::Point(), HTCAPTION));
174 ASSERT_TRUE(resizer.get()); 176 ASSERT_TRUE(resizer.get());
175 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0); 177 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0);
176 resizer->CompleteDrag(0); 178 resizer->CompleteDrag(0);
177 // Since the pointer is still on the primary root window, the parent should 179 // Since the pointer is still on the primary root window, the parent should
178 // not be changed. 180 // not be changed.
179 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 181 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
180 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); 182 EXPECT_EQ("790,10 50x60", window_->bounds().ToString());
181 } 183 }
182 184
183 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 185 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
184 Shell::GetScreen()->GetPrimaryDisplay()); 186 Shell::GetScreen()->GetPrimaryDisplay());
185 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 187 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
186 { 188 {
187 // Grab the top-right edge of the window and move the pointer to (0, 10) 189 // Grab the top-right edge of the window and move the pointer to (0, 10)
188 // in the secondary root window's coordinates. 190 // in the secondary root window's coordinates.
189 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 191 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
190 window_.get(), gfx::Point(49, 0), HTCAPTION)); 192 window_.get(), gfx::Point(49, 0), HTCAPTION));
191 ASSERT_TRUE(resizer.get()); 193 ASSERT_TRUE(resizer.get());
192 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); 194 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN);
193 resizer->CompleteDrag(0); 195 resizer->CompleteDrag(0);
194 // Since the pointer is on the secondary, the parent should be changed 196 // Since the pointer is on the secondary, the parent should be changed
195 // even though only small fraction of the window is within the secondary 197 // even though only small fraction of the window is within the secondary
196 // root window's bounds. 198 // root window's bounds.
197 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 199 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
198 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); 200 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString());
199 } 201 }
200 } 202 }
201 203
202 // Verifies a window can be moved from the secondary display to primary. 204 // Verifies a window can be moved from the secondary display to primary.
203 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 205 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
204 if (!SupportsMultipleDisplays()) 206 if (!SupportsMultipleDisplays())
205 return; 207 return;
206 208
207 UpdateDisplay("800x600,800x600"); 209 UpdateDisplay("800x600,800x600");
208 shelf_layout_manager()->LayoutShelf(); 210 shelf_layout_manager()->LayoutShelf();
209 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 211 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
210 ASSERT_EQ(2U, root_windows.size()); 212 ASSERT_EQ(2U, root_windows.size());
211 213
212 window_->SetBoundsInScreen( 214 window_->SetBoundsInScreen(
213 gfx::Rect(800, 00, 50, 60), 215 gfx::Rect(800, 00, 50, 60),
214 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 216 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
215 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 217 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
216 { 218 {
217 // Grab (0, 0) of the window. 219 // Grab (0, 0) of the window.
218 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 220 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
219 window_.get(), gfx::Point(), HTCAPTION)); 221 window_.get(), gfx::Point(), HTCAPTION));
220 ASSERT_TRUE(resizer.get()); 222 ASSERT_TRUE(resizer.get());
221 // Move the mouse near the right edge, (798, 0), of the primary display. 223 // Move the mouse near the right edge, (798, 0), of the primary display.
222 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 224 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
223 resizer->CompleteDrag(0); 225 resizer->CompleteDrag(0);
224 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 226 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
225 EXPECT_EQ("798,0 50x60", window_->bounds().ToString()); 227 EXPECT_EQ("798,0 50x60", window_->bounds().ToString());
226 } 228 }
227 } 229 }
228 230
229 // Verifies the drag window is shown correctly. 231 // Verifies the drag window is shown correctly.
230 TEST_F(DragWindowResizerTest, DragWindowController) { 232 TEST_F(DragWindowResizerTest, DragWindowController) {
231 if (!SupportsMultipleDisplays()) 233 if (!SupportsMultipleDisplays())
232 return; 234 return;
233 235
234 UpdateDisplay("800x600,800x600"); 236 UpdateDisplay("800x600,800x600");
235 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 237 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
236 ASSERT_EQ(2U, root_windows.size()); 238 ASSERT_EQ(2U, root_windows.size());
237 239
238 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 240 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
239 Shell::GetScreen()->GetPrimaryDisplay()); 241 Shell::GetScreen()->GetPrimaryDisplay());
240 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 242 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
241 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 243 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
242 { 244 {
243 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 245 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
244 window_.get(), gfx::Point(), HTCAPTION)); 246 window_.get(), gfx::Point(), HTCAPTION));
245 ASSERT_TRUE(resizer.get()); 247 ASSERT_TRUE(resizer.get());
246 EXPECT_FALSE(resizer->drag_window_controller_.get()); 248 internal::DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
249 ASSERT_TRUE(drag_resizer);
250 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
247 251
248 // The pointer is inside the primary root. The drag window controller 252 // The pointer is inside the primary root. The drag window controller
249 // should be NULL. 253 // should be NULL.
250 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); 254 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
251 EXPECT_FALSE(resizer->drag_window_controller_.get()); 255 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
252 256
253 // The window spans both root windows. 257 // The window spans both root windows.
254 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0); 258 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0);
255 DragWindowController* controller = 259 DragWindowController* controller =
256 resizer->drag_window_controller_.get(); 260 drag_resizer->drag_window_controller_.get();
257 ASSERT_TRUE(controller); 261 ASSERT_TRUE(controller);
258 262
259 ASSERT_TRUE(controller->drag_widget_); 263 ASSERT_TRUE(controller->drag_widget_);
260 ui::Layer* drag_layer = 264 ui::Layer* drag_layer =
261 controller->drag_widget_->GetNativeWindow()->layer(); 265 controller->drag_widget_->GetNativeWindow()->layer();
262 ASSERT_TRUE(drag_layer); 266 ASSERT_TRUE(drag_layer);
263 // Check if |resizer->layer_| is properly set to the drag widget. 267 // Check if |resizer->layer_| is properly set to the drag widget.
264 const std::vector<ui::Layer*>& layers = drag_layer->children(); 268 const std::vector<ui::Layer*>& layers = drag_layer->children();
265 EXPECT_FALSE(layers.empty()); 269 EXPECT_FALSE(layers.empty());
266 EXPECT_EQ(controller->layer_, layers.back()); 270 EXPECT_EQ(controller->layer_, layers.back());
267 271
268 // |window_| should be opaque since the pointer is still on the primary 272 // |window_| should be opaque since the pointer is still on the primary
269 // root window. The drag window should be semi-transparent. 273 // root window. The drag window should be semi-transparent.
270 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 274 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
271 ASSERT_TRUE(controller->drag_widget_); 275 ASSERT_TRUE(controller->drag_widget_);
272 EXPECT_GT(1.0f, drag_layer->opacity()); 276 EXPECT_GT(1.0f, drag_layer->opacity());
273 277
274 // Enter the pointer to the secondary display. 278 // Enter the pointer to the secondary display.
275 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 279 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
276 controller = resizer->drag_window_controller_.get(); 280 controller = drag_resizer->drag_window_controller_.get();
277 ASSERT_TRUE(controller); 281 ASSERT_TRUE(controller);
278 // |window_| should be transparent, and the drag window should be opaque. 282 // |window_| should be transparent, and the drag window should be opaque.
279 EXPECT_GT(1.0f, window_->layer()->opacity()); 283 EXPECT_GT(1.0f, window_->layer()->opacity());
280 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); 284 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity());
281 285
282 resizer->CompleteDrag(0); 286 resizer->CompleteDrag(0);
283 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 287 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
284 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 288 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
285 } 289 }
286 290
287 // Do the same test with RevertDrag(). 291 // Do the same test with RevertDrag().
288 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 292 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
289 Shell::GetScreen()->GetPrimaryDisplay()); 293 Shell::GetScreen()->GetPrimaryDisplay());
290 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 294 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
291 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 295 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
292 { 296 {
293 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 297 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
294 window_.get(), gfx::Point(), HTCAPTION)); 298 window_.get(), gfx::Point(), HTCAPTION));
295 ASSERT_TRUE(resizer.get()); 299 ASSERT_TRUE(resizer.get());
296 EXPECT_FALSE(resizer->drag_window_controller_.get()); 300 internal::DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
301 ASSERT_TRUE(drag_resizer);
302 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
297 303
298 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 304 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
299 resizer->RevertDrag(); 305 resizer->RevertDrag();
300 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 306 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
301 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 307 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
302 } 308 }
303 } 309 }
304 310
305 // Verifies if the resizer sets and resets 311 // Verifies if the resizer sets and resets
306 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 312 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
307 TEST_F(DragWindowResizerTest, WarpMousePointer) { 313 TEST_F(DragWindowResizerTest, WarpMousePointer) {
308 MouseCursorEventFilter* event_filter = 314 MouseCursorEventFilter* event_filter =
309 Shell::GetInstance()->mouse_cursor_filter(); 315 Shell::GetInstance()->mouse_cursor_filter();
310 ASSERT_TRUE(event_filter); 316 ASSERT_TRUE(event_filter);
311 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); 317 window_->SetBounds(gfx::Rect(0, 0, 50, 60));
312 318
313 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 319 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
314 event_filter->mouse_warp_mode_); 320 event_filter->mouse_warp_mode_);
315 { 321 {
316 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 322 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
317 window_.get(), gfx::Point(), HTCAPTION)); 323 window_.get(), gfx::Point(), HTCAPTION));
318 // While dragging a window, warp should be allowed. 324 // While dragging a window, warp should be allowed.
319 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, 325 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG,
320 event_filter->mouse_warp_mode_); 326 event_filter->mouse_warp_mode_);
321 resizer->CompleteDrag(0); 327 resizer->CompleteDrag(0);
322 } 328 }
323 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 329 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
324 event_filter->mouse_warp_mode_); 330 event_filter->mouse_warp_mode_);
325 331
326 { 332 {
327 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 333 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
328 window_.get(), gfx::Point(), HTCAPTION)); 334 window_.get(), gfx::Point(), HTCAPTION));
329 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, 335 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG,
330 event_filter->mouse_warp_mode_); 336 event_filter->mouse_warp_mode_);
331 resizer->RevertDrag(); 337 resizer->RevertDrag();
332 } 338 }
333 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 339 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
334 event_filter->mouse_warp_mode_); 340 event_filter->mouse_warp_mode_);
335 341
336 { 342 {
337 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 343 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
338 window_.get(), gfx::Point(), HTRIGHT)); 344 window_.get(), gfx::Point(), HTRIGHT));
339 // While resizing a window, warp should NOT be allowed. 345 // While resizing a window, warp should NOT be allowed.
340 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, 346 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE,
341 event_filter->mouse_warp_mode_); 347 event_filter->mouse_warp_mode_);
342 resizer->CompleteDrag(0); 348 resizer->CompleteDrag(0);
343 } 349 }
344 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 350 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
345 event_filter->mouse_warp_mode_); 351 event_filter->mouse_warp_mode_);
346 352
347 { 353 {
348 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 354 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
349 window_.get(), gfx::Point(), HTRIGHT)); 355 window_.get(), gfx::Point(), HTRIGHT));
350 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, 356 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE,
351 event_filter->mouse_warp_mode_); 357 event_filter->mouse_warp_mode_);
352 resizer->RevertDrag(); 358 resizer->RevertDrag();
353 } 359 }
354 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 360 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
355 event_filter->mouse_warp_mode_); 361 event_filter->mouse_warp_mode_);
356 } 362 }
357 363
358 // Verifies cursor's device scale factor is updated whe a window is moved across 364 // Verifies cursor's device scale factor is updated whe a window is moved across
(...skipping 13 matching lines...) Expand all
372 Shell::GetInstance()->cursor_manager()); 378 Shell::GetInstance()->cursor_manager());
373 MouseCursorEventFilter* event_filter = 379 MouseCursorEventFilter* event_filter =
374 Shell::GetInstance()->mouse_cursor_filter(); 380 Shell::GetInstance()->mouse_cursor_filter();
375 // Move window from the root window with 1.0 device scale factor to the root 381 // Move window from the root window with 1.0 device scale factor to the root
376 // window with 2.0 device scale factor. 382 // window with 2.0 device scale factor.
377 { 383 {
378 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 384 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
379 Shell::GetScreen()->GetPrimaryDisplay()); 385 Shell::GetScreen()->GetPrimaryDisplay());
380 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 386 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
381 // Grab (0, 0) of the window. 387 // Grab (0, 0) of the window.
382 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 388 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
383 window_.get(), gfx::Point(), HTCAPTION)); 389 window_.get(), gfx::Point(), HTCAPTION));
384 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 390 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
385 ASSERT_TRUE(resizer.get()); 391 ASSERT_TRUE(resizer.get());
386 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 392 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
387 event_filter->WarpMouseCursorIfNecessary(root_windows[0], 393 event_filter->WarpMouseCursorIfNecessary(root_windows[0],
388 gfx::Point(399, 200)); 394 gfx::Point(399, 200));
389 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 395 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
390 resizer->CompleteDrag(0); 396 resizer->CompleteDrag(0);
391 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 397 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
392 } 398 }
393 399
394 // Move window from the root window with 2.0 device scale factor to the root 400 // Move window from the root window with 2.0 device scale factor to the root
395 // window with 1.0 device scale factor. 401 // window with 1.0 device scale factor.
396 { 402 {
397 window_->SetBoundsInScreen( 403 window_->SetBoundsInScreen(
398 gfx::Rect(600, 0, 50, 60), 404 gfx::Rect(600, 0, 50, 60),
399 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 405 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
400 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 406 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
401 // Grab (0, 0) of the window. 407 // Grab (0, 0) of the window.
402 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 408 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
403 window_.get(), gfx::Point(), HTCAPTION)); 409 window_.get(), gfx::Point(), HTCAPTION));
404 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 410 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
405 ASSERT_TRUE(resizer.get()); 411 ASSERT_TRUE(resizer.get());
406 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 412 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
407 event_filter->WarpMouseCursorIfNecessary(root_windows[1], 413 event_filter->WarpMouseCursorIfNecessary(root_windows[1],
408 gfx::Point(400, 200)); 414 gfx::Point(400, 200));
409 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 415 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
410 resizer->CompleteDrag(0); 416 resizer->CompleteDrag(0);
411 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 417 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
412 } 418 }
(...skipping 13 matching lines...) Expand all
426 ASSERT_EQ(2U, root_windows.size()); 432 ASSERT_EQ(2U, root_windows.size());
427 MouseCursorEventFilter* event_filter = 433 MouseCursorEventFilter* event_filter =
428 Shell::GetInstance()->mouse_cursor_filter(); 434 Shell::GetInstance()->mouse_cursor_filter();
429 435
430 // Normal window can be moved across display. 436 // Normal window can be moved across display.
431 { 437 {
432 aura::Window* window = window_.get(); 438 aura::Window* window = window_.get();
433 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 439 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
434 Shell::GetScreen()->GetPrimaryDisplay()); 440 Shell::GetScreen()->GetPrimaryDisplay());
435 // Grab (0, 0) of the window. 441 // Grab (0, 0) of the window.
436 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 442 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
437 window, gfx::Point(), HTCAPTION)); 443 window, gfx::Point(), HTCAPTION));
438 ASSERT_TRUE(resizer.get()); 444 ASSERT_TRUE(resizer.get());
439 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 445 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
440 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 446 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
441 gfx::Point(399, 200))); 447 gfx::Point(399, 200)));
442 resizer->CompleteDrag(0); 448 resizer->CompleteDrag(0);
443 } 449 }
444 450
445 // Always on top window can be moved across display. 451 // Always on top window can be moved across display.
446 { 452 {
447 aura::Window* window = always_on_top_window_.get(); 453 aura::Window* window = always_on_top_window_.get();
448 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 454 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
449 Shell::GetScreen()->GetPrimaryDisplay()); 455 Shell::GetScreen()->GetPrimaryDisplay());
450 // Grab (0, 0) of the window. 456 // Grab (0, 0) of the window.
451 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 457 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
452 window, gfx::Point(), HTCAPTION)); 458 window, gfx::Point(), HTCAPTION));
453 ASSERT_TRUE(resizer.get()); 459 ASSERT_TRUE(resizer.get());
454 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 460 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
455 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 461 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
456 gfx::Point(399, 200))); 462 gfx::Point(399, 200)));
457 resizer->CompleteDrag(0); 463 resizer->CompleteDrag(0);
458 } 464 }
459 465
460 // System modal window can be moved across display. 466 // System modal window can be moved across display.
461 { 467 {
462 aura::Window* window = system_modal_window_.get(); 468 aura::Window* window = system_modal_window_.get();
463 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 469 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
464 Shell::GetScreen()->GetPrimaryDisplay()); 470 Shell::GetScreen()->GetPrimaryDisplay());
465 // Grab (0, 0) of the window. 471 // Grab (0, 0) of the window.
466 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 472 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
467 window, gfx::Point(), HTCAPTION)); 473 window, gfx::Point(), HTCAPTION));
468 ASSERT_TRUE(resizer.get()); 474 ASSERT_TRUE(resizer.get());
469 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 475 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
470 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 476 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
471 gfx::Point(399, 200))); 477 gfx::Point(399, 200)));
472 resizer->CompleteDrag(0); 478 resizer->CompleteDrag(0);
473 } 479 }
474 480
475 // Transient window cannot be moved across display. 481 // Transient window cannot be moved across display.
476 { 482 {
477 aura::Window* window = transient_child_; 483 aura::Window* window = transient_child_;
478 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 484 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
479 Shell::GetScreen()->GetPrimaryDisplay()); 485 Shell::GetScreen()->GetPrimaryDisplay());
480 // Grab (0, 0) of the window. 486 // Grab (0, 0) of the window.
481 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 487 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
482 window, gfx::Point(), HTCAPTION)); 488 window, gfx::Point(), HTCAPTION));
483 ASSERT_TRUE(resizer.get()); 489 ASSERT_TRUE(resizer.get());
484 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 490 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
485 EXPECT_FALSE(event_filter->WarpMouseCursorIfNecessary( 491 EXPECT_FALSE(event_filter->WarpMouseCursorIfNecessary(
486 root_windows[0], 492 root_windows[0],
487 gfx::Point(399, 200))); 493 gfx::Point(399, 200)));
488 resizer->CompleteDrag(0); 494 resizer->CompleteDrag(0);
489 } 495 }
490 496
491 // The parent of transient window can be moved across display. 497 // The parent of transient window can be moved across display.
492 { 498 {
493 aura::Window* window = transient_parent_.get(); 499 aura::Window* window = transient_parent_.get();
494 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 500 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
495 Shell::GetScreen()->GetPrimaryDisplay()); 501 Shell::GetScreen()->GetPrimaryDisplay());
496 // Grab (0, 0) of the window. 502 // Grab (0, 0) of the window.
497 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 503 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
498 window, gfx::Point(), HTCAPTION)); 504 window, gfx::Point(), HTCAPTION));
499 ASSERT_TRUE(resizer.get()); 505 ASSERT_TRUE(resizer.get());
500 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 506 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
501 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 507 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
502 gfx::Point(399, 200))); 508 gfx::Point(399, 200)));
503 resizer->CompleteDrag(0); 509 resizer->CompleteDrag(0);
504 } 510 }
505 511
506 // Panel window can be moved across display. 512 // Panel window can be moved across display.
507 { 513 {
508 aura::Window* window = panel_window_.get(); 514 aura::Window* window = panel_window_.get();
509 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 515 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
510 Shell::GetScreen()->GetPrimaryDisplay()); 516 Shell::GetScreen()->GetPrimaryDisplay());
511 // Grab (0, 0) of the window. 517 // Grab (0, 0) of the window.
512 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 518 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
513 window, gfx::Point(), HTCAPTION)); 519 window, gfx::Point(), HTCAPTION));
514 ASSERT_TRUE(resizer.get()); 520 ASSERT_TRUE(resizer.get());
515 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 521 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
516 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 522 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
517 gfx::Point(399, 200))); 523 gfx::Point(399, 200)));
518 resizer->CompleteDrag(0); 524 resizer->CompleteDrag(0);
519 } 525 }
520 } 526 }
521 527
522 } // namespace internal 528 } // namespace internal
523 } // namespace ash 529 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ash/wm/panels/panel_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698