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

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 (comments on unit tests) 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 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
243 window_.get(), gfx::Point(), HTCAPTION)); 235 window_.get(), gfx::Point(), HTCAPTION));
244 ASSERT_TRUE(resizer.get()); 236 ASSERT_TRUE(resizer.get());
245 EXPECT_FALSE(resizer->drag_window_controller_.get()); 237 internal::DragWindowResizer* drag_resizer = DragWindowResizer::instance();
238 ASSERT_TRUE(drag_resizer);
239 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
246 240
247 // The pointer is inside the primary root. The drag window controller 241 // The pointer is inside the primary root. The drag window controller
248 // should be NULL. 242 // should be NULL.
249 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); 243 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
250 EXPECT_FALSE(resizer->drag_window_controller_.get()); 244 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
251 245
252 // The window spans both root windows. 246 // The window spans both root windows.
253 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0); 247 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0);
254 DragWindowController* controller = 248 DragWindowController* controller =
255 resizer->drag_window_controller_.get(); 249 drag_resizer->drag_window_controller_.get();
256 ASSERT_TRUE(controller); 250 ASSERT_TRUE(controller);
257 251
258 ASSERT_TRUE(controller->drag_widget_); 252 ASSERT_TRUE(controller->drag_widget_);
259 ui::Layer* drag_layer = 253 ui::Layer* drag_layer =
260 controller->drag_widget_->GetNativeWindow()->layer(); 254 controller->drag_widget_->GetNativeWindow()->layer();
261 ASSERT_TRUE(drag_layer); 255 ASSERT_TRUE(drag_layer);
262 // Check if |resizer->layer_| is properly set to the drag widget. 256 // Check if |resizer->layer_| is properly set to the drag widget.
263 const std::vector<ui::Layer*>& layers = drag_layer->children(); 257 const std::vector<ui::Layer*>& layers = drag_layer->children();
264 EXPECT_FALSE(layers.empty()); 258 EXPECT_FALSE(layers.empty());
265 EXPECT_EQ(controller->layer_, layers.back()); 259 EXPECT_EQ(controller->layer_, layers.back());
266 260
267 // |window_| should be opaque since the pointer is still on the primary 261 // |window_| should be opaque since the pointer is still on the primary
268 // root window. The drag window should be semi-transparent. 262 // root window. The drag window should be semi-transparent.
269 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 263 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
270 ASSERT_TRUE(controller->drag_widget_); 264 ASSERT_TRUE(controller->drag_widget_);
271 EXPECT_GT(1.0f, drag_layer->opacity()); 265 EXPECT_GT(1.0f, drag_layer->opacity());
272 266
273 // Enter the pointer to the secondary display. 267 // Enter the pointer to the secondary display.
274 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 268 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
275 controller = resizer->drag_window_controller_.get(); 269 controller = drag_resizer->drag_window_controller_.get();
276 ASSERT_TRUE(controller); 270 ASSERT_TRUE(controller);
277 // |window_| should be transparent, and the drag window should be opaque. 271 // |window_| should be transparent, and the drag window should be opaque.
278 EXPECT_GT(1.0f, window_->layer()->opacity()); 272 EXPECT_GT(1.0f, window_->layer()->opacity());
279 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); 273 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity());
280 274
281 resizer->CompleteDrag(0); 275 resizer->CompleteDrag(0);
282 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 276 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
283 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 277 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
284 } 278 }
285 279
286 // Do the same test with RevertDrag(). 280 // Do the same test with RevertDrag().
287 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 281 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
288 Shell::GetScreen()->GetPrimaryDisplay()); 282 Shell::GetScreen()->GetPrimaryDisplay());
289 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 283 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
290 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 284 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
291 { 285 {
292 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 286 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
293 window_.get(), gfx::Point(), HTCAPTION)); 287 window_.get(), gfx::Point(), HTCAPTION));
294 ASSERT_TRUE(resizer.get()); 288 ASSERT_TRUE(resizer.get());
295 EXPECT_FALSE(resizer->drag_window_controller_.get()); 289 internal::DragWindowResizer* drag_resizer = DragWindowResizer::instance();
290 ASSERT_TRUE(drag_resizer);
291 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
296 292
297 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 293 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
298 resizer->RevertDrag(); 294 resizer->RevertDrag();
299 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 295 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
300 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 296 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
301 } 297 }
302 } 298 }
303 299
304 // Verifies if the resizer sets and resets 300 // Verifies if the resizer sets and resets
305 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 301 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
306 TEST_F(DragWindowResizerTest, WarpMousePointer) { 302 TEST_F(DragWindowResizerTest, WarpMousePointer) {
307 MouseCursorEventFilter* event_filter = 303 MouseCursorEventFilter* event_filter =
308 Shell::GetInstance()->mouse_cursor_filter(); 304 Shell::GetInstance()->mouse_cursor_filter();
309 ASSERT_TRUE(event_filter); 305 ASSERT_TRUE(event_filter);
310 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); 306 window_->SetBounds(gfx::Rect(0, 0, 50, 60));
311 307
312 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 308 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
313 event_filter->mouse_warp_mode_); 309 event_filter->mouse_warp_mode_);
314 { 310 {
315 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 311 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
316 window_.get(), gfx::Point(), HTCAPTION)); 312 window_.get(), gfx::Point(), HTCAPTION));
317 // While dragging a window, warp should be allowed. 313 // While dragging a window, warp should be allowed.
318 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, 314 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG,
319 event_filter->mouse_warp_mode_); 315 event_filter->mouse_warp_mode_);
320 resizer->CompleteDrag(0); 316 resizer->CompleteDrag(0);
321 } 317 }
322 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 318 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
323 event_filter->mouse_warp_mode_); 319 event_filter->mouse_warp_mode_);
324 320
325 { 321 {
326 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 322 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
327 window_.get(), gfx::Point(), HTCAPTION)); 323 window_.get(), gfx::Point(), HTCAPTION));
328 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, 324 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG,
329 event_filter->mouse_warp_mode_); 325 event_filter->mouse_warp_mode_);
330 resizer->RevertDrag(); 326 resizer->RevertDrag();
331 } 327 }
332 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 328 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
333 event_filter->mouse_warp_mode_); 329 event_filter->mouse_warp_mode_);
334 330
335 { 331 {
336 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 332 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
337 window_.get(), gfx::Point(), HTRIGHT)); 333 window_.get(), gfx::Point(), HTRIGHT));
338 // While resizing a window, warp should NOT be allowed. 334 // While resizing a window, warp should NOT be allowed.
339 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, 335 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE,
340 event_filter->mouse_warp_mode_); 336 event_filter->mouse_warp_mode_);
341 resizer->CompleteDrag(0); 337 resizer->CompleteDrag(0);
342 } 338 }
343 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 339 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
344 event_filter->mouse_warp_mode_); 340 event_filter->mouse_warp_mode_);
345 341
346 { 342 {
347 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 343 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
348 window_.get(), gfx::Point(), HTRIGHT)); 344 window_.get(), gfx::Point(), HTRIGHT));
349 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, 345 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE,
350 event_filter->mouse_warp_mode_); 346 event_filter->mouse_warp_mode_);
351 resizer->RevertDrag(); 347 resizer->RevertDrag();
352 } 348 }
353 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, 349 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS,
354 event_filter->mouse_warp_mode_); 350 event_filter->mouse_warp_mode_);
355 } 351 }
356 352
357 // Verifies cursor's device scale factor is updated whe a window is moved across 353 // 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()); 367 Shell::GetInstance()->cursor_manager());
372 MouseCursorEventFilter* event_filter = 368 MouseCursorEventFilter* event_filter =
373 Shell::GetInstance()->mouse_cursor_filter(); 369 Shell::GetInstance()->mouse_cursor_filter();
374 // Move window from the root window with 1.0 device scale factor to the root 370 // Move window from the root window with 1.0 device scale factor to the root
375 // window with 2.0 device scale factor. 371 // window with 2.0 device scale factor.
376 { 372 {
377 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 373 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
378 Shell::GetScreen()->GetPrimaryDisplay()); 374 Shell::GetScreen()->GetPrimaryDisplay());
379 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 375 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
380 // Grab (0, 0) of the window. 376 // Grab (0, 0) of the window.
381 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 377 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
382 window_.get(), gfx::Point(), HTCAPTION)); 378 window_.get(), gfx::Point(), HTCAPTION));
383 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 379 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
384 ASSERT_TRUE(resizer.get()); 380 ASSERT_TRUE(resizer.get());
385 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 381 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
386 event_filter->WarpMouseCursorIfNecessary(root_windows[0], 382 event_filter->WarpMouseCursorIfNecessary(root_windows[0],
387 gfx::Point(399, 200)); 383 gfx::Point(399, 200));
388 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 384 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
389 resizer->CompleteDrag(0); 385 resizer->CompleteDrag(0);
390 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 386 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
391 } 387 }
392 388
393 // Move window from the root window with 2.0 device scale factor to the root 389 // Move window from the root window with 2.0 device scale factor to the root
394 // window with 1.0 device scale factor. 390 // window with 1.0 device scale factor.
395 { 391 {
396 window_->SetBoundsInScreen( 392 window_->SetBoundsInScreen(
397 gfx::Rect(600, 0, 50, 60), 393 gfx::Rect(600, 0, 50, 60),
398 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 394 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
399 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 395 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
400 // Grab (0, 0) of the window. 396 // Grab (0, 0) of the window.
401 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 397 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
402 window_.get(), gfx::Point(), HTCAPTION)); 398 window_.get(), gfx::Point(), HTCAPTION));
403 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor()); 399 EXPECT_EQ(2.0f, cursor_test_api.GetDisplay().device_scale_factor());
404 ASSERT_TRUE(resizer.get()); 400 ASSERT_TRUE(resizer.get());
405 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 401 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
406 event_filter->WarpMouseCursorIfNecessary(root_windows[1], 402 event_filter->WarpMouseCursorIfNecessary(root_windows[1],
407 gfx::Point(400, 200)); 403 gfx::Point(400, 200));
408 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 404 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
409 resizer->CompleteDrag(0); 405 resizer->CompleteDrag(0);
410 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor()); 406 EXPECT_EQ(1.0f, cursor_test_api.GetDisplay().device_scale_factor());
411 } 407 }
(...skipping 13 matching lines...) Expand all
425 ASSERT_EQ(2U, root_windows.size()); 421 ASSERT_EQ(2U, root_windows.size());
426 MouseCursorEventFilter* event_filter = 422 MouseCursorEventFilter* event_filter =
427 Shell::GetInstance()->mouse_cursor_filter(); 423 Shell::GetInstance()->mouse_cursor_filter();
428 424
429 // Normal window can be moved across display. 425 // Normal window can be moved across display.
430 { 426 {
431 aura::Window* window = window_.get(); 427 aura::Window* window = window_.get();
432 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 428 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
433 Shell::GetScreen()->GetPrimaryDisplay()); 429 Shell::GetScreen()->GetPrimaryDisplay());
434 // Grab (0, 0) of the window. 430 // Grab (0, 0) of the window.
435 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 431 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
436 window, gfx::Point(), HTCAPTION)); 432 window, gfx::Point(), HTCAPTION));
437 ASSERT_TRUE(resizer.get()); 433 ASSERT_TRUE(resizer.get());
438 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 434 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
439 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 435 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
440 gfx::Point(399, 200))); 436 gfx::Point(399, 200)));
441 resizer->CompleteDrag(0); 437 resizer->CompleteDrag(0);
442 } 438 }
443 439
444 // Always on top window can be moved across display. 440 // Always on top window can be moved across display.
445 { 441 {
446 aura::Window* window = always_on_top_window_.get(); 442 aura::Window* window = always_on_top_window_.get();
447 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 443 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
448 Shell::GetScreen()->GetPrimaryDisplay()); 444 Shell::GetScreen()->GetPrimaryDisplay());
449 // Grab (0, 0) of the window. 445 // Grab (0, 0) of the window.
450 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 446 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
451 window, gfx::Point(), HTCAPTION)); 447 window, gfx::Point(), HTCAPTION));
452 ASSERT_TRUE(resizer.get()); 448 ASSERT_TRUE(resizer.get());
453 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 449 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
454 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 450 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
455 gfx::Point(399, 200))); 451 gfx::Point(399, 200)));
456 resizer->CompleteDrag(0); 452 resizer->CompleteDrag(0);
457 } 453 }
458 454
459 // System modal window can be moved across display. 455 // System modal window can be moved across display.
460 { 456 {
461 aura::Window* window = system_modal_window_.get(); 457 aura::Window* window = system_modal_window_.get();
462 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 458 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
463 Shell::GetScreen()->GetPrimaryDisplay()); 459 Shell::GetScreen()->GetPrimaryDisplay());
464 // Grab (0, 0) of the window. 460 // Grab (0, 0) of the window.
465 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 461 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
466 window, gfx::Point(), HTCAPTION)); 462 window, gfx::Point(), HTCAPTION));
467 ASSERT_TRUE(resizer.get()); 463 ASSERT_TRUE(resizer.get());
468 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 464 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
469 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 465 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
470 gfx::Point(399, 200))); 466 gfx::Point(399, 200)));
471 resizer->CompleteDrag(0); 467 resizer->CompleteDrag(0);
472 } 468 }
473 469
474 // Transient window cannot be moved across display. 470 // Transient window cannot be moved across display.
475 { 471 {
476 aura::Window* window = transient_child_; 472 aura::Window* window = transient_child_;
477 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 473 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
478 Shell::GetScreen()->GetPrimaryDisplay()); 474 Shell::GetScreen()->GetPrimaryDisplay());
479 // Grab (0, 0) of the window. 475 // Grab (0, 0) of the window.
480 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 476 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
481 window, gfx::Point(), HTCAPTION)); 477 window, gfx::Point(), HTCAPTION));
482 ASSERT_TRUE(resizer.get()); 478 ASSERT_TRUE(resizer.get());
483 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 479 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
484 EXPECT_FALSE(event_filter->WarpMouseCursorIfNecessary( 480 EXPECT_FALSE(event_filter->WarpMouseCursorIfNecessary(
485 root_windows[0], 481 root_windows[0],
486 gfx::Point(399, 200))); 482 gfx::Point(399, 200)));
487 resizer->CompleteDrag(0); 483 resizer->CompleteDrag(0);
488 } 484 }
489 485
490 // The parent of transient window can be moved across display. 486 // The parent of transient window can be moved across display.
491 { 487 {
492 aura::Window* window = transient_parent_.get(); 488 aura::Window* window = transient_parent_.get();
493 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 489 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
494 Shell::GetScreen()->GetPrimaryDisplay()); 490 Shell::GetScreen()->GetPrimaryDisplay());
495 // Grab (0, 0) of the window. 491 // Grab (0, 0) of the window.
496 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 492 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
497 window, gfx::Point(), HTCAPTION)); 493 window, gfx::Point(), HTCAPTION));
498 ASSERT_TRUE(resizer.get()); 494 ASSERT_TRUE(resizer.get());
499 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 495 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
500 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 496 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
501 gfx::Point(399, 200))); 497 gfx::Point(399, 200)));
502 resizer->CompleteDrag(0); 498 resizer->CompleteDrag(0);
503 } 499 }
504 500
505 // Panel window can be moved across display. 501 // Panel window can be moved across display.
506 { 502 {
507 aura::Window* window = panel_window_.get(); 503 aura::Window* window = panel_window_.get();
508 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 504 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
509 Shell::GetScreen()->GetPrimaryDisplay()); 505 Shell::GetScreen()->GetPrimaryDisplay());
510 // Grab (0, 0) of the window. 506 // Grab (0, 0) of the window.
511 scoped_ptr<DragWindowResizer> resizer(CreateDragWindowResizer( 507 scoped_ptr<WindowResizer> resizer(CreateWindowResizer(
512 window, gfx::Point(), HTCAPTION)); 508 window, gfx::Point(), HTCAPTION));
513 ASSERT_TRUE(resizer.get()); 509 ASSERT_TRUE(resizer.get());
514 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 510 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
515 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0], 511 EXPECT_TRUE(event_filter->WarpMouseCursorIfNecessary(root_windows[0],
516 gfx::Point(399, 200))); 512 gfx::Point(399, 200)));
517 resizer->CompleteDrag(0); 513 resizer->CompleteDrag(0);
518 } 514 }
519 } 515 }
520 516
521 } // namespace internal 517 } // namespace internal
522 } // namespace ash 518 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698