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

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

Powered by Google App Engine
This is Rietveld 408576698