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

Side by Side Diff: ash/wm/workspace/workspace_event_handler_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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/workspace/workspace_event_handler.h" 5 #include "ash/wm/workspace/workspace_event_handler.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 std::vector<const void*> properties_changed_; 96 std::vector<const void*> properties_changed_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver); 98 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver);
99 }; 99 };
100 100
101 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { 101 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
102 // Double clicking the vertical resize edge of a window should maximize it 102 // Double clicking the vertical resize edge of a window should maximize it
103 // vertically. 103 // vertically.
104 gfx::Rect restored_bounds(10, 10, 50, 50); 104 gfx::Rect restored_bounds(10, 10, 50, 50);
105 aura::test::TestWindowDelegate delegate; 105 aura::test::TestWindowDelegate delegate;
106 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); 106 std::unique_ptr<aura::Window> window(
107 CreateTestWindow(&delegate, restored_bounds));
107 108
108 wm::ActivateWindow(window.get()); 109 wm::ActivateWindow(window.get());
109 110
110 gfx::Rect work_area = gfx::Screen::GetScreen() 111 gfx::Rect work_area = gfx::Screen::GetScreen()
111 ->GetDisplayNearestWindow(window.get()) 112 ->GetDisplayNearestWindow(window.get())
112 .work_area(); 113 .work_area();
113 114
114 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 115 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
115 window.get()); 116 window.get());
116 117
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 // Restore. 207 // Restore.
207 generator2.DoubleClickLeftButton(); 208 generator2.DoubleClickLeftButton();
208 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); 209 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString());
209 } 210 }
210 211
211 // Tests the behavior when double clicking the border of a side snapped window. 212 // Tests the behavior when double clicking the border of a side snapped window.
212 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { 213 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) {
213 gfx::Rect restored_bounds(10, 10, 50, 50); 214 gfx::Rect restored_bounds(10, 10, 50, 50);
214 aura::test::TestWindowDelegate delegate; 215 aura::test::TestWindowDelegate delegate;
215 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); 216 std::unique_ptr<aura::Window> window(
217 CreateTestWindow(&delegate, restored_bounds));
216 218
217 gfx::Rect work_area_in_screen = gfx::Screen::GetScreen() 219 gfx::Rect work_area_in_screen = gfx::Screen::GetScreen()
218 ->GetDisplayNearestWindow(window.get()) 220 ->GetDisplayNearestWindow(window.get())
219 .work_area(); 221 .work_area();
220 222
221 wm::WindowState* window_state = wm::GetWindowState(window.get()); 223 wm::WindowState* window_state = wm::GetWindowState(window.get());
222 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); 224 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT);
223 window_state->OnWMEvent(&snap_event); 225 window_state->OnWMEvent(&snap_event);
224 226
225 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); 227 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen();
(...skipping 19 matching lines...) Expand all
245 generator.DoubleClickLeftButton(); 247 generator.DoubleClickLeftButton();
246 EXPECT_TRUE(window_state->IsNormalStateType()); 248 EXPECT_TRUE(window_state->IsNormalStateType());
247 EXPECT_EQ(work_area_in_screen.ToString(), 249 EXPECT_EQ(work_area_in_screen.ToString(),
248 window->GetBoundsInScreen().ToString()); 250 window->GetBoundsInScreen().ToString());
249 } 251 }
250 252
251 TEST_F(WorkspaceEventHandlerTest, 253 TEST_F(WorkspaceEventHandlerTest,
252 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { 254 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) {
253 gfx::Rect restored_bounds(10, 10, 50, 50); 255 gfx::Rect restored_bounds(10, 10, 50, 50);
254 aura::test::TestWindowDelegate delegate; 256 aura::test::TestWindowDelegate delegate;
255 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); 257 std::unique_ptr<aura::Window> window(
258 CreateTestWindow(&delegate, restored_bounds));
256 259
257 wm::ActivateWindow(window.get()); 260 wm::ActivateWindow(window.get());
258 261
259 gfx::Rect work_area = gfx::Screen::GetScreen() 262 gfx::Rect work_area = gfx::Screen::GetScreen()
260 ->GetDisplayNearestWindow(window.get()) 263 ->GetDisplayNearestWindow(window.get())
261 .work_area(); 264 .work_area();
262 265
263 delegate.set_maximum_size(gfx::Size(0, 100)); 266 delegate.set_maximum_size(gfx::Size(0, 100));
264 267
265 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 268 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
266 window.get()); 269 window.get());
267 // Double-click the top resize edge. 270 // Double-click the top resize edge.
268 delegate.set_window_component(HTTOP); 271 delegate.set_window_component(HTTOP);
269 generator.DoubleClickLeftButton(); 272 generator.DoubleClickLeftButton();
270 273
271 // The size of the window should be unchanged. 274 // The size of the window should be unchanged.
272 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); 275 EXPECT_EQ(restored_bounds.y(), window->bounds().y());
273 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); 276 EXPECT_EQ(restored_bounds.height(), window->bounds().height());
274 } 277 }
275 278
276 TEST_F(WorkspaceEventHandlerTest, 279 TEST_F(WorkspaceEventHandlerTest,
277 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { 280 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) {
278 gfx::Rect restored_bounds(10, 10, 50, 50); 281 gfx::Rect restored_bounds(10, 10, 50, 50);
279 aura::test::TestWindowDelegate delegate; 282 aura::test::TestWindowDelegate delegate;
280 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); 283 std::unique_ptr<aura::Window> window(
284 CreateTestWindow(&delegate, restored_bounds));
281 285
282 wm::ActivateWindow(window.get()); 286 wm::ActivateWindow(window.get());
283 287
284 gfx::Rect work_area = gfx::Screen::GetScreen() 288 gfx::Rect work_area = gfx::Screen::GetScreen()
285 ->GetDisplayNearestWindow(window.get()) 289 ->GetDisplayNearestWindow(window.get())
286 .work_area(); 290 .work_area();
287 291
288 delegate.set_maximum_size(gfx::Size(100, 0)); 292 delegate.set_maximum_size(gfx::Size(100, 0));
289 293
290 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 294 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
291 window.get()); 295 window.get());
292 // Double-click the top resize edge. 296 // Double-click the top resize edge.
293 delegate.set_window_component(HTRIGHT); 297 delegate.set_window_component(HTRIGHT);
294 generator.DoubleClickLeftButton(); 298 generator.DoubleClickLeftButton();
295 299
296 // The size of the window should be unchanged. 300 // The size of the window should be unchanged.
297 EXPECT_EQ(restored_bounds.x(), window->bounds().x()); 301 EXPECT_EQ(restored_bounds.x(), window->bounds().x());
298 EXPECT_EQ(restored_bounds.width(), window->bounds().width()); 302 EXPECT_EQ(restored_bounds.width(), window->bounds().width());
299 } 303 }
300 304
301 TEST_F(WorkspaceEventHandlerTest, 305 TEST_F(WorkspaceEventHandlerTest,
302 DoubleClickOrTapWithModalChildDoesntMaximize) { 306 DoubleClickOrTapWithModalChildDoesntMaximize) {
303 aura::test::TestWindowDelegate delegate1; 307 aura::test::TestWindowDelegate delegate1;
304 aura::test::TestWindowDelegate delegate2; 308 aura::test::TestWindowDelegate delegate2;
305 scoped_ptr<aura::Window> window( 309 std::unique_ptr<aura::Window> window(
306 CreateTestWindow(&delegate1, gfx::Rect(10, 20, 30, 40))); 310 CreateTestWindow(&delegate1, gfx::Rect(10, 20, 30, 40)));
307 scoped_ptr<aura::Window> child( 311 std::unique_ptr<aura::Window> child(
308 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 1, 1))); 312 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 1, 1)));
309 window->SetProperty(aura::client::kCanMaximizeKey, true); 313 window->SetProperty(aura::client::kCanMaximizeKey, true);
310 delegate1.set_window_component(HTCAPTION); 314 delegate1.set_window_component(HTCAPTION);
311 315
312 child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 316 child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
313 ::wm::AddTransientChild(window.get(), child.get()); 317 ::wm::AddTransientChild(window.get(), child.get());
314 318
315 wm::WindowState* window_state = wm::GetWindowState(window.get()); 319 wm::WindowState* window_state = wm::GetWindowState(window.get());
316 EXPECT_FALSE(window_state->IsMaximized()); 320 EXPECT_FALSE(window_state->IsMaximized());
317 aura::Window* root = Shell::GetPrimaryRootWindow(); 321 aura::Window* root = Shell::GetPrimaryRootWindow();
318 ui::test::EventGenerator generator(root, window.get()); 322 ui::test::EventGenerator generator(root, window.get());
319 generator.DoubleClickLeftButton(); 323 generator.DoubleClickLeftButton();
320 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); 324 EXPECT_EQ("10,20 30x40", window->bounds().ToString());
321 EXPECT_FALSE(window_state->IsMaximized()); 325 EXPECT_FALSE(window_state->IsMaximized());
322 326
323 generator.GestureTapAt(gfx::Point(25, 25)); 327 generator.GestureTapAt(gfx::Point(25, 25));
324 generator.GestureTapAt(gfx::Point(25, 25)); 328 generator.GestureTapAt(gfx::Point(25, 25));
325 RunAllPendingInMessageLoop(); 329 RunAllPendingInMessageLoop();
326 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); 330 EXPECT_EQ("10,20 30x40", window->bounds().ToString());
327 EXPECT_FALSE(window_state->IsMaximized()); 331 EXPECT_FALSE(window_state->IsMaximized());
328 } 332 }
329 333
330 // Test the behavior as a result of double clicking the window header. 334 // Test the behavior as a result of double clicking the window header.
331 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { 335 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
332 aura::test::TestWindowDelegate delegate; 336 aura::test::TestWindowDelegate delegate;
333 scoped_ptr<aura::Window> window( 337 std::unique_ptr<aura::Window> window(
334 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); 338 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
335 window->SetProperty(aura::client::kCanMaximizeKey, true); 339 window->SetProperty(aura::client::kCanMaximizeKey, true);
336 340
337 wm::WindowState* window_state = wm::GetWindowState(window.get()); 341 wm::WindowState* window_state = wm::GetWindowState(window.get());
338 gfx::Rect restore_bounds = window->bounds(); 342 gfx::Rect restore_bounds = window->bounds();
339 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 343 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
340 window.get()); 344 window.get());
341 345
342 EXPECT_FALSE(window_state->IsMaximized()); 346 EXPECT_FALSE(window_state->IsMaximized());
343 347
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 generator.DoubleClickLeftButton(); 385 generator.DoubleClickLeftButton();
382 EXPECT_TRUE(window_state->IsNormalStateType()); 386 EXPECT_TRUE(window_state->IsNormalStateType());
383 EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString()); 387 EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString());
384 } 388 }
385 389
386 // Test that double clicking the middle button on the window header does not 390 // Test that double clicking the middle button on the window header does not
387 // toggle the maximized state. 391 // toggle the maximized state.
388 TEST_F(WorkspaceEventHandlerTest, 392 TEST_F(WorkspaceEventHandlerTest,
389 DoubleClickMiddleButtonDoesNotToggleMaximize) { 393 DoubleClickMiddleButtonDoesNotToggleMaximize) {
390 aura::test::TestWindowDelegate delegate; 394 aura::test::TestWindowDelegate delegate;
391 scoped_ptr<aura::Window> window( 395 std::unique_ptr<aura::Window> window(
392 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); 396 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
393 window->SetProperty(aura::client::kCanMaximizeKey, true); 397 window->SetProperty(aura::client::kCanMaximizeKey, true);
394 delegate.set_window_component(HTCAPTION); 398 delegate.set_window_component(HTCAPTION);
395 aura::Window* root = Shell::GetPrimaryRootWindow(); 399 aura::Window* root = Shell::GetPrimaryRootWindow();
396 ui::test::EventGenerator generator(root, window.get()); 400 ui::test::EventGenerator generator(root, window.get());
397 401
398 WindowPropertyObserver observer(window.get()); 402 WindowPropertyObserver observer(window.get());
399 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_NONE); 403 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_NONE);
400 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON, 404 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON,
401 ui::EF_IS_DOUBLE_CLICK); 405 ui::EF_IS_DOUBLE_CLICK);
402 406
403 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 407 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
404 EXPECT_EQ("1,2 30x40", window->bounds().ToString()); 408 EXPECT_EQ("1,2 30x40", window->bounds().ToString());
405 EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey)); 409 EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey));
406 } 410 }
407 411
408 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) { 412 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) {
409 aura::test::TestWindowDelegate delegate; 413 aura::test::TestWindowDelegate delegate;
410 gfx::Rect bounds(10, 20, 30, 40); 414 gfx::Rect bounds(10, 20, 30, 40);
411 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); 415 std::unique_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
412 window->SetProperty(aura::client::kCanMaximizeKey, true); 416 window->SetProperty(aura::client::kCanMaximizeKey, true);
413 delegate.set_window_component(HTCAPTION); 417 delegate.set_window_component(HTCAPTION);
414 418
415 wm::WindowState* window_state = wm::GetWindowState(window.get()); 419 wm::WindowState* window_state = wm::GetWindowState(window.get());
416 EXPECT_FALSE(window_state->IsMaximized()); 420 EXPECT_FALSE(window_state->IsMaximized());
417 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 421 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
418 window.get()); 422 window.get());
419 generator.GestureTapAt(gfx::Point(25, 25)); 423 generator.GestureTapAt(gfx::Point(25, 25));
420 generator.GestureTapAt(gfx::Point(25, 25)); 424 generator.GestureTapAt(gfx::Point(25, 25));
421 RunAllPendingInMessageLoop(); 425 RunAllPendingInMessageLoop();
422 EXPECT_NE(bounds.ToString(), window->bounds().ToString()); 426 EXPECT_NE(bounds.ToString(), window->bounds().ToString());
423 EXPECT_TRUE(window_state->IsMaximized()); 427 EXPECT_TRUE(window_state->IsMaximized());
424 428
425 generator.GestureTapAt(gfx::Point(5, 5)); 429 generator.GestureTapAt(gfx::Point(5, 5));
426 generator.GestureTapAt(gfx::Point(10, 10)); 430 generator.GestureTapAt(gfx::Point(10, 10));
427 431
428 EXPECT_FALSE(window_state->IsMaximized()); 432 EXPECT_FALSE(window_state->IsMaximized());
429 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 433 EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
430 } 434 }
431 435
432 // Verifies deleting the window while dragging doesn't crash. 436 // Verifies deleting the window while dragging doesn't crash.
433 TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) { 437 TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) {
434 // Create a large window in the background. This is necessary so that when we 438 // Create a large window in the background. This is necessary so that when we
435 // delete |window| WorkspaceEventHandler is still the active event handler. 439 // delete |window| WorkspaceEventHandler is still the active event handler.
436 aura::test::TestWindowDelegate delegate2; 440 aura::test::TestWindowDelegate delegate2;
437 scoped_ptr<aura::Window> window2( 441 std::unique_ptr<aura::Window> window2(
438 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 500, 500))); 442 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 500, 500)));
439 443
440 aura::test::TestWindowDelegate delegate; 444 aura::test::TestWindowDelegate delegate;
441 const gfx::Rect bounds(10, 20, 30, 40); 445 const gfx::Rect bounds(10, 20, 30, 40);
442 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); 446 std::unique_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
443 delegate.set_window_component(HTCAPTION); 447 delegate.set_window_component(HTCAPTION);
444 ui::test::EventGenerator generator(window->GetRootWindow()); 448 ui::test::EventGenerator generator(window->GetRootWindow());
445 generator.MoveMouseToCenterOf(window.get()); 449 generator.MoveMouseToCenterOf(window.get());
446 generator.PressLeftButton(); 450 generator.PressLeftButton();
447 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); 451 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50));
448 DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString()); 452 DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString());
449 window.reset(); 453 window.reset();
450 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); 454 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50));
451 } 455 }
452 456
453 // Verifies deleting the window while in a run loop doesn't crash. 457 // Verifies deleting the window while in a run loop doesn't crash.
454 TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) { 458 TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) {
455 aura::test::TestWindowDelegate delegate; 459 aura::test::TestWindowDelegate delegate;
456 const gfx::Rect bounds(10, 20, 30, 40); 460 const gfx::Rect bounds(10, 20, 30, 40);
457 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); 461 std::unique_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
458 delegate.set_window_component(HTCAPTION); 462 delegate.set_window_component(HTCAPTION);
459 463
460 ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow())); 464 ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow()));
461 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window.get()); 465 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window.get());
462 aura::client::GetWindowMoveClient(window->GetRootWindow()) 466 aura::client::GetWindowMoveClient(window->GetRootWindow())
463 ->RunMoveLoop(window.release(), 467 ->RunMoveLoop(window.release(),
464 gfx::Vector2d(), 468 gfx::Vector2d(),
465 aura::client::WINDOW_MOVE_SOURCE_MOUSE); 469 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
466 } 470 }
467 471
468 // Verifies that double clicking in the header does not maximize if the target 472 // Verifies that double clicking in the header does not maximize if the target
469 // component has changed. 473 // component has changed.
470 TEST_F(WorkspaceEventHandlerTest, 474 TEST_F(WorkspaceEventHandlerTest,
471 DoubleClickTwoDifferentTargetsDoesntMaximize) { 475 DoubleClickTwoDifferentTargetsDoesntMaximize) {
472 aura::test::TestWindowDelegate delegate; 476 aura::test::TestWindowDelegate delegate;
473 scoped_ptr<aura::Window> window( 477 std::unique_ptr<aura::Window> window(
474 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); 478 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
475 window->SetProperty(aura::client::kCanMaximizeKey, true); 479 window->SetProperty(aura::client::kCanMaximizeKey, true);
476 480
477 wm::WindowState* window_state = wm::GetWindowState(window.get()); 481 wm::WindowState* window_state = wm::GetWindowState(window.get());
478 gfx::Rect restore_bounds = window->bounds(); 482 gfx::Rect restore_bounds = window->bounds();
479 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 483 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
480 window.get()); 484 window.get());
481 485
482 EXPECT_FALSE(window_state->IsMaximized()); 486 EXPECT_FALSE(window_state->IsMaximized());
483 487
484 // First click will go to a client 488 // First click will go to a client
485 delegate.set_window_component(HTCLIENT); 489 delegate.set_window_component(HTCLIENT);
486 aura::Window* root = Shell::GetPrimaryRootWindow(); 490 aura::Window* root = Shell::GetPrimaryRootWindow();
487 ui::test::EventGenerator generator(root, window.get()); 491 ui::test::EventGenerator generator(root, window.get());
488 generator.ClickLeftButton(); 492 generator.ClickLeftButton();
489 EXPECT_FALSE(window_state->IsMaximized()); 493 EXPECT_FALSE(window_state->IsMaximized());
490 494
491 // Second click will go to the header 495 // Second click will go to the header
492 delegate.set_window_component(HTCAPTION); 496 delegate.set_window_component(HTCAPTION);
493 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, 497 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON,
494 ui::EF_IS_DOUBLE_CLICK); 498 ui::EF_IS_DOUBLE_CLICK);
495 EXPECT_FALSE(window_state->IsMaximized()); 499 EXPECT_FALSE(window_state->IsMaximized());
496 } 500 }
497 501
498 // Verifies that double tapping in the header does not maximize if the target 502 // Verifies that double tapping in the header does not maximize if the target
499 // component has changed. 503 // component has changed.
500 TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) { 504 TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) {
501 aura::test::TestWindowDelegate delegate; 505 aura::test::TestWindowDelegate delegate;
502 scoped_ptr<aura::Window> window( 506 std::unique_ptr<aura::Window> window(
503 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); 507 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
504 window->SetProperty(aura::client::kCanMaximizeKey, true); 508 window->SetProperty(aura::client::kCanMaximizeKey, true);
505 509
506 wm::WindowState* window_state = wm::GetWindowState(window.get()); 510 wm::WindowState* window_state = wm::GetWindowState(window.get());
507 gfx::Rect restore_bounds = window->bounds(); 511 gfx::Rect restore_bounds = window->bounds();
508 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 512 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
509 window.get()); 513 window.get());
510 514
511 EXPECT_FALSE(window_state->IsMaximized()); 515 EXPECT_FALSE(window_state->IsMaximized());
512 516
513 // First tap will go to a client 517 // First tap will go to a client
514 delegate.set_window_component(HTCLIENT); 518 delegate.set_window_component(HTCLIENT);
515 aura::Window* root = Shell::GetPrimaryRootWindow(); 519 aura::Window* root = Shell::GetPrimaryRootWindow();
516 ui::test::EventGenerator generator(root, window.get()); 520 ui::test::EventGenerator generator(root, window.get());
517 generator.GestureTapAt(gfx::Point(25, 25)); 521 generator.GestureTapAt(gfx::Point(25, 25));
518 EXPECT_FALSE(window_state->IsMaximized()); 522 EXPECT_FALSE(window_state->IsMaximized());
519 523
520 // Second tap will go to the header 524 // Second tap will go to the header
521 delegate.set_window_component(HTCAPTION); 525 delegate.set_window_component(HTCAPTION);
522 generator.GestureTapAt(gfx::Point(25, 25)); 526 generator.GestureTapAt(gfx::Point(25, 25));
523 EXPECT_FALSE(window_state->IsMaximized()); 527 EXPECT_FALSE(window_state->IsMaximized());
524 } 528 }
525 529
526 TEST_F(WorkspaceEventHandlerTest, 530 TEST_F(WorkspaceEventHandlerTest,
527 RightClickDuringDoubleClickDoesntMaximize) { 531 RightClickDuringDoubleClickDoesntMaximize) {
528 aura::test::TestWindowDelegate delegate; 532 aura::test::TestWindowDelegate delegate;
529 scoped_ptr<aura::Window> window( 533 std::unique_ptr<aura::Window> window(
530 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); 534 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
531 window->SetProperty(aura::client::kCanMaximizeKey, true); 535 window->SetProperty(aura::client::kCanMaximizeKey, true);
532 536
533 wm::WindowState* window_state = wm::GetWindowState(window.get()); 537 wm::WindowState* window_state = wm::GetWindowState(window.get());
534 gfx::Rect restore_bounds = window->bounds(); 538 gfx::Rect restore_bounds = window->bounds();
535 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 539 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
536 window.get()); 540 window.get());
537 541
538 EXPECT_FALSE(window_state->IsMaximized()); 542 EXPECT_FALSE(window_state->IsMaximized());
539 543
540 // First click will go to a client 544 // First click will go to a client
541 delegate.set_window_component(HTCLIENT); 545 delegate.set_window_component(HTCLIENT);
542 aura::Window* root = Shell::GetPrimaryRootWindow(); 546 aura::Window* root = Shell::GetPrimaryRootWindow();
543 ui::test::EventGenerator generator(root, window.get()); 547 ui::test::EventGenerator generator(root, window.get());
544 generator.ClickLeftButton(); 548 generator.ClickLeftButton();
545 EXPECT_FALSE(window_state->IsMaximized()); 549 EXPECT_FALSE(window_state->IsMaximized());
546 550
547 // Second click will go to the header 551 // Second click will go to the header
548 delegate.set_window_component(HTCAPTION); 552 delegate.set_window_component(HTCAPTION);
549 generator.PressRightButton(); 553 generator.PressRightButton();
550 generator.ReleaseRightButton(); 554 generator.ReleaseRightButton();
551 EXPECT_FALSE(window_state->IsMaximized()); 555 EXPECT_FALSE(window_state->IsMaximized());
552 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, 556 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON,
553 ui::EF_IS_DOUBLE_CLICK); 557 ui::EF_IS_DOUBLE_CLICK);
554 EXPECT_FALSE(window_state->IsMaximized()); 558 EXPECT_FALSE(window_state->IsMaximized());
555 } 559 }
556 560
557 } // namespace ash 561 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/phantom_window_controller.cc ('k') | ash/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698