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

Side by Side Diff: trunk/src/ash/wm/toplevel_window_event_handler_unittest.cc

Issue 413983006: Revert 285209 "Cleanups for aura/test/event_generator.h (resolve..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/wm/lock_state_controller.h" 11 #include "ash/wm/lock_state_controller.h"
12 #include "ash/wm/resize_shadow.h" 12 #include "ash/wm/resize_shadow.h"
13 #include "ash/wm/resize_shadow_controller.h" 13 #include "ash/wm/resize_shadow_controller.h"
14 #include "ash/wm/window_state.h" 14 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_util.h" 15 #include "ash/wm/window_util.h"
16 #include "ash/wm/workspace_controller.h" 16 #include "ash/wm/workspace_controller.h"
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/aura/client/aura_constants.h" 21 #include "ui/aura/client/aura_constants.h"
22 #include "ui/aura/test/aura_test_base.h" 22 #include "ui/aura/test/aura_test_base.h"
23 #include "ui/aura/test/event_generator.h"
23 #include "ui/aura/test/test_window_delegate.h" 24 #include "ui/aura/test/test_window_delegate.h"
24 #include "ui/aura/window_event_dispatcher.h" 25 #include "ui/aura/window_event_dispatcher.h"
25 #include "ui/base/hit_test.h" 26 #include "ui/base/hit_test.h"
26 #include "ui/events/event.h" 27 #include "ui/events/event.h"
27 #include "ui/events/test/event_generator.h"
28 #include "ui/gfx/screen.h" 28 #include "ui/gfx/screen.h"
29 #include "ui/wm/core/window_util.h" 29 #include "ui/wm/core/window_util.h"
30 #include "ui/wm/public/window_move_client.h" 30 #include "ui/wm/public/window_move_client.h"
31 31
32 #if defined(OS_WIN) 32 #if defined(OS_WIN)
33 // Windows headers define macros for these function names which screw with us. 33 // Windows headers define macros for these function names which screw with us.
34 #if defined(CreateWindow) 34 #if defined(CreateWindow)
35 #undef CreateWindow 35 #undef CreateWindow
36 #endif 36 #endif
37 #endif 37 #endif
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 w1->Init(aura::WINDOW_LAYER_TEXTURED); 73 w1->Init(aura::WINDOW_LAYER_TEXTURED);
74 aura::Window* parent = Shell::GetContainer( 74 aura::Window* parent = Shell::GetContainer(
75 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); 75 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer);
76 parent->AddChild(w1); 76 parent->AddChild(w1);
77 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); 77 w1->SetBounds(gfx::Rect(0, 0, 100, 100));
78 w1->Show(); 78 w1->Show();
79 return w1; 79 return w1;
80 } 80 }
81 81
82 void DragFromCenterBy(aura::Window* window, int dx, int dy) { 82 void DragFromCenterBy(aura::Window* window, int dx, int dy) {
83 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), window); 83 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), window);
84 generator.DragMouseBy(dx, dy); 84 generator.DragMouseBy(dx, dy);
85 } 85 }
86 86
87 void TouchDragFromCenterBy(aura::Window* window, int dx, int dy) { 87 void TouchDragFromCenterBy(aura::Window* window, int dx, int dy) {
88 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), window); 88 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), window);
89 generator.PressMoveAndReleaseTouchBy(dx, dy); 89 generator.PressMoveAndReleaseTouchBy(dx, dy);
90 } 90 }
91 91
92 scoped_ptr<ToplevelWindowEventHandler> handler_; 92 scoped_ptr<ToplevelWindowEventHandler> handler_;
93 93
94 private: 94 private:
95 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandlerTest); 95 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandlerTest);
96 }; 96 };
97 97
98 } 98 }
(...skipping 24 matching lines...) Expand all
123 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString()); 123 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString());
124 } 124 }
125 125
126 TEST_F(ToplevelWindowEventHandlerTest, GrowBox) { 126 TEST_F(ToplevelWindowEventHandlerTest, GrowBox) {
127 scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX)); 127 scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX));
128 TestWindowDelegate* window_delegate = 128 TestWindowDelegate* window_delegate =
129 static_cast<TestWindowDelegate*>(w1->delegate()); 129 static_cast<TestWindowDelegate*>(w1->delegate());
130 window_delegate->set_minimum_size(gfx::Size(40, 40)); 130 window_delegate->set_minimum_size(gfx::Size(40, 40));
131 131
132 gfx::Point position = w1->bounds().origin(); 132 gfx::Point position = w1->bounds().origin();
133 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 133 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
134 generator.MoveMouseToCenterOf(w1.get()); 134 generator.MoveMouseToCenterOf(w1.get());
135 generator.DragMouseBy(100, 100); 135 generator.DragMouseBy(100, 100);
136 // Position should not have changed. 136 // Position should not have changed.
137 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString()); 137 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString());
138 // Size should have increased by 100,100. 138 // Size should have increased by 100,100.
139 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString()); 139 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString());
140 140
141 // Shrink the wnidow by (-100, -100). 141 // Shrink the wnidow by (-100, -100).
142 generator.DragMouseBy(-100, -100); 142 generator.DragMouseBy(-100, -100);
143 // Position should not have changed. 143 // Position should not have changed.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString()); 367 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
368 368
369 TouchDragFromCenterBy(w1.get(), 100, 100); 369 TouchDragFromCenterBy(w1.get(), 100, 100);
370 EXPECT_EQ("0,0", w1->bounds().origin().ToString()); 370 EXPECT_EQ("0,0", w1->bounds().origin().ToString());
371 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString()); 371 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
372 } 372 }
373 373
374 // Verifies we don't let windows drag to a -y location. 374 // Verifies we don't let windows drag to a -y location.
375 TEST_F(ToplevelWindowEventHandlerTest, DontDragToNegativeY) { 375 TEST_F(ToplevelWindowEventHandlerTest, DontDragToNegativeY) {
376 scoped_ptr<aura::Window> target(CreateWindow(HTTOP)); 376 scoped_ptr<aura::Window> target(CreateWindow(HTTOP));
377 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 377 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
378 target.get()); 378 target.get());
379 generator.MoveMouseTo(0, 5); 379 generator.MoveMouseTo(0, 5);
380 generator.DragMouseBy(0, -5); 380 generator.DragMouseBy(0, -5);
381 // The y location and height should not have changed. 381 // The y location and height should not have changed.
382 EXPECT_EQ(0, target->bounds().y()); 382 EXPECT_EQ(0, target->bounds().y());
383 EXPECT_EQ(100, target->bounds().height()); 383 EXPECT_EQ(100, target->bounds().height());
384 } 384 }
385 385
386 // Verifies we don't let windows go bigger than the display width. 386 // Verifies we don't let windows go bigger than the display width.
387 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) { 387 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) {
388 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT)); 388 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT));
389 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( 389 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
390 target.get()).bounds(); 390 target.get()).bounds();
391 DragFromCenterBy(target.get(), work_area.width() * 2, 0); 391 DragFromCenterBy(target.get(), work_area.width() * 2, 0);
392 // The y location and height should not have changed. 392 // The y location and height should not have changed.
393 EXPECT_EQ(work_area.width(), target->bounds().width()); 393 EXPECT_EQ(work_area.width(), target->bounds().width());
394 } 394 }
395 395
396 // Verifies that touch-gestures drag the window correctly. 396 // Verifies that touch-gestures drag the window correctly.
397 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { 397 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) {
398 scoped_ptr<aura::Window> target( 398 scoped_ptr<aura::Window> target(
399 CreateTestWindowInShellWithDelegate( 399 CreateTestWindowInShellWithDelegate(
400 new TestWindowDelegate(HTCAPTION), 400 new TestWindowDelegate(HTCAPTION),
401 0, 401 0,
402 gfx::Rect(0, 0, 100, 100))); 402 gfx::Rect(0, 0, 100, 100)));
403 wm::WindowState* window_state = wm::GetWindowState(target.get()); 403 wm::WindowState* window_state = wm::GetWindowState(target.get());
404 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 404 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
405 target.get()); 405 target.get());
406 gfx::Rect old_bounds = target->bounds(); 406 gfx::Rect old_bounds = target->bounds();
407 gfx::Point location(5, 5); 407 gfx::Point location(5, 5);
408 target->SetProperty(aura::client::kCanMaximizeKey, true); 408 target->SetProperty(aura::client::kCanMaximizeKey, true);
409 409
410 gfx::Point end = location; 410 gfx::Point end = location;
411 411
412 // Snap right; 412 // Snap right;
413 end.Offset(100, 0); 413 end.Offset(100, 0);
414 generator.GestureScrollSequence(location, end, 414 generator.GestureScrollSequence(location, end,
415 base::TimeDelta::FromMilliseconds(5), 415 base::TimeDelta::FromMilliseconds(5),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 Shell::GetInstance()->lock_state_controller(); 474 Shell::GetInstance()->lock_state_controller();
475 state_controller->OnLoginStateChanged(user::LOGGED_IN_NONE); 475 state_controller->OnLoginStateChanged(user::LOGGED_IN_NONE);
476 state_controller->OnLockStateChanged(false); 476 state_controller->OnLockStateChanged(false);
477 SetUserLoggedIn(false); 477 SetUserLoggedIn(false);
478 478
479 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); 479 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION));
480 aura::Window* lock = 480 aura::Window* lock =
481 RootWindowController::ForWindow(target.get()) 481 RootWindowController::ForWindow(target.get())
482 ->GetContainer(kShellWindowId_LockSystemModalContainer); 482 ->GetContainer(kShellWindowId_LockSystemModalContainer);
483 lock->AddChild(target.get()); 483 lock->AddChild(target.get());
484 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 484 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
485 target.get()); 485 target.get());
486 gfx::Rect old_bounds = target->bounds(); 486 gfx::Rect old_bounds = target->bounds();
487 gfx::Point location(5, 5); 487 gfx::Point location(5, 5);
488 target->SetProperty(aura::client::kCanMaximizeKey, true); 488 target->SetProperty(aura::client::kCanMaximizeKey, true);
489 489
490 gfx::Point end = location; 490 gfx::Point end = location;
491 end.Offset(0, 100); 491 end.Offset(0, 100);
492 generator.GestureScrollSequence(location, end, 492 generator.GestureScrollSequence(location, end,
493 base::TimeDelta::FromMilliseconds(5), 493 base::TimeDelta::FromMilliseconds(5),
494 10); 494 10);
495 RunAllPendingInMessageLoop(); 495 RunAllPendingInMessageLoop();
496 EXPECT_FALSE(wm::GetWindowState(target.get())->IsMinimized()); 496 EXPECT_FALSE(wm::GetWindowState(target.get())->IsMinimized());
497 } 497 }
498 498
499 TEST_F(ToplevelWindowEventHandlerTest, GestureDragToRestore) { 499 TEST_F(ToplevelWindowEventHandlerTest, GestureDragToRestore) {
500 scoped_ptr<aura::Window> window( 500 scoped_ptr<aura::Window> window(
501 CreateTestWindowInShellWithDelegate( 501 CreateTestWindowInShellWithDelegate(
502 new TestWindowDelegate(HTCAPTION), 502 new TestWindowDelegate(HTCAPTION),
503 0, 503 0,
504 gfx::Rect(10, 20, 30, 40))); 504 gfx::Rect(10, 20, 30, 40)));
505 window->Show(); 505 window->Show();
506 wm::WindowState* window_state = wm::GetWindowState(window.get()); 506 wm::WindowState* window_state = wm::GetWindowState(window.get());
507 window_state->Activate(); 507 window_state->Activate();
508 508
509 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 509 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
510 window.get()); 510 window.get());
511 gfx::Rect old_bounds = window->bounds(); 511 gfx::Rect old_bounds = window->bounds();
512 gfx::Point location, end; 512 gfx::Point location, end;
513 end = location = window->GetBoundsInRootWindow().CenterPoint(); 513 end = location = window->GetBoundsInRootWindow().CenterPoint();
514 end.Offset(0, 100); 514 end.Offset(0, 100);
515 generator.GestureScrollSequence(location, end, 515 generator.GestureScrollSequence(location, end,
516 base::TimeDelta::FromMilliseconds(5), 516 base::TimeDelta::FromMilliseconds(5),
517 10); 517 10);
518 RunAllPendingInMessageLoop(); 518 RunAllPendingInMessageLoop();
519 EXPECT_NE(old_bounds.ToString(), window->bounds().ToString()); 519 EXPECT_NE(old_bounds.ToString(), window->bounds().ToString());
520 EXPECT_TRUE(window_state->IsMinimized()); 520 EXPECT_TRUE(window_state->IsMinimized());
521 EXPECT_TRUE(window_state->unminimize_to_restore_bounds()); 521 EXPECT_TRUE(window_state->unminimize_to_restore_bounds());
522 EXPECT_EQ(old_bounds.ToString(), 522 EXPECT_EQ(old_bounds.ToString(),
523 window_state->GetRestoreBoundsInScreen().ToString()); 523 window_state->GetRestoreBoundsInScreen().ToString());
524 } 524 }
525 525
526 // Tests that an unresizable window cannot be dragged or snapped using gestures. 526 // Tests that an unresizable window cannot be dragged or snapped using gestures.
527 TEST_F(ToplevelWindowEventHandlerTest, GestureDragForUnresizableWindow) { 527 TEST_F(ToplevelWindowEventHandlerTest, GestureDragForUnresizableWindow) {
528 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); 528 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION));
529 wm::WindowState* window_state = wm::GetWindowState(target.get()); 529 wm::WindowState* window_state = wm::GetWindowState(target.get());
530 530
531 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 531 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
532 target.get()); 532 target.get());
533 gfx::Rect old_bounds = target->bounds(); 533 gfx::Rect old_bounds = target->bounds();
534 gfx::Point location(5, 5); 534 gfx::Point location(5, 5);
535 535
536 target->SetProperty(aura::client::kCanResizeKey, false); 536 target->SetProperty(aura::client::kCanResizeKey, false);
537 537
538 gfx::Point end = location; 538 gfx::Point end = location;
539 539
540 // Try to snap right. The window is not resizable. So it should not snap. 540 // Try to snap right. The window is not resizable. So it should not snap.
541 end.Offset(100, 0); 541 end.Offset(100, 0);
542 generator.GestureScrollSequence(location, end, 542 generator.GestureScrollSequence(location, end,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 scoped_ptr<aura::Window> target( 576 scoped_ptr<aura::Window> target(
577 CreateTestWindowInShellWithDelegate( 577 CreateTestWindowInShellWithDelegate(
578 new TestWindowDelegate(HTCAPTION), 578 new TestWindowDelegate(HTCAPTION),
579 0, 579 0,
580 gfx::Rect(0, 0, 100, 100))); 580 gfx::Rect(0, 0, 100, 100)));
581 scoped_ptr<aura::Window> notmoved( 581 scoped_ptr<aura::Window> notmoved(
582 CreateTestWindowInShellWithDelegate( 582 CreateTestWindowInShellWithDelegate(
583 new TestWindowDelegate(HTCAPTION), 583 new TestWindowDelegate(HTCAPTION),
584 1, gfx::Rect(100, 0, 100, 100))); 584 1, gfx::Rect(100, 0, 100, 100)));
585 585
586 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 586 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
587 target.get()); 587 target.get());
588 gfx::Rect old_bounds = target->bounds(); 588 gfx::Rect old_bounds = target->bounds();
589 gfx::Point location(5, 5); 589 gfx::Point location(5, 5);
590 target->SetProperty(aura::client::kCanMaximizeKey, true); 590 target->SetProperty(aura::client::kCanMaximizeKey, true);
591 591
592 // Send some touch events to start dragging |target|. 592 // Send some touch events to start dragging |target|.
593 generator.MoveTouch(location); 593 generator.MoveTouch(location);
594 generator.PressTouch(); 594 generator.PressTouch();
595 location.Offset(40, 5); 595 location.Offset(40, 5);
596 generator.MoveTouch(location); 596 generator.MoveTouch(location);
597 597
598 // Try to drag |notmoved| window. This should not move the window. 598 // Try to drag |notmoved| window. This should not move the window.
599 { 599 {
600 gfx::Rect bounds = notmoved->bounds(); 600 gfx::Rect bounds = notmoved->bounds();
601 ui::test::EventGenerator gen(Shell::GetPrimaryRootWindow(), notmoved.get()); 601 aura::test::EventGenerator gen(Shell::GetPrimaryRootWindow(),
602 notmoved.get());
602 gfx::Point start = notmoved->bounds().origin() + gfx::Vector2d(10, 10); 603 gfx::Point start = notmoved->bounds().origin() + gfx::Vector2d(10, 10);
603 gfx::Point end = start + gfx::Vector2d(100, 10); 604 gfx::Point end = start + gfx::Vector2d(100, 10);
604 gen.GestureScrollSequence(start, end, 605 gen.GestureScrollSequence(start, end,
605 base::TimeDelta::FromMilliseconds(10), 606 base::TimeDelta::FromMilliseconds(10),
606 10); 607 10);
607 EXPECT_EQ(bounds.ToString(), notmoved->bounds().ToString()); 608 EXPECT_EQ(bounds.ToString(), notmoved->bounds().ToString());
608 } 609 }
609 } 610 }
610 611
611 // Verifies pressing escape resets the bounds to the original bounds. 612 // Verifies pressing escape resets the bounds to the original bounds.
612 // Disabled crbug.com/166219. 613 // Disabled crbug.com/166219.
613 #if defined(OS_WIN) 614 #if defined(OS_WIN)
614 #define MAYBE_EscapeReverts DISABLED_EscapeReverts 615 #define MAYBE_EscapeReverts DISABLED_EscapeReverts
615 #else 616 #else
616 #define MAYBE_EscapeReverts EscapeReverts 617 #define MAYBE_EscapeReverts EscapeReverts
617 #endif 618 #endif
618 TEST_F(ToplevelWindowEventHandlerTest, MAYBE_EscapeReverts) { 619 TEST_F(ToplevelWindowEventHandlerTest, MAYBE_EscapeReverts) {
619 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT)); 620 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT));
620 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 621 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
621 target.get()); 622 target.get());
622 generator.PressLeftButton(); 623 generator.PressLeftButton();
623 generator.MoveMouseBy(10, 11); 624 generator.MoveMouseBy(10, 11);
624 625
625 // Execute any scheduled draws so that pending mouse events are processed. 626 // Execute any scheduled draws so that pending mouse events are processed.
626 RunAllPendingInMessageLoop(); 627 RunAllPendingInMessageLoop();
627 628
628 EXPECT_EQ("0,0 110x111", target->bounds().ToString()); 629 EXPECT_EQ("0,0 110x111", target->bounds().ToString());
629 generator.PressKey(ui::VKEY_ESCAPE, 0); 630 generator.PressKey(ui::VKEY_ESCAPE, 0);
630 generator.ReleaseKey(ui::VKEY_ESCAPE, 0); 631 generator.ReleaseKey(ui::VKEY_ESCAPE, 0);
631 EXPECT_EQ("0,0 100x100", target->bounds().ToString()); 632 EXPECT_EQ("0,0 100x100", target->bounds().ToString());
632 } 633 }
633 634
634 // Verifies window minimization/maximization completes drag. 635 // Verifies window minimization/maximization completes drag.
635 // Disabled crbug.com/166219. 636 // Disabled crbug.com/166219.
636 #if defined(OS_WIN) 637 #if defined(OS_WIN)
637 #define MAYBE_MinimizeMaximizeCompletes DISABLED_MinimizeMaximizeCompletes 638 #define MAYBE_MinimizeMaximizeCompletes DISABLED_MinimizeMaximizeCompletes
638 #else 639 #else
639 #define MAYBE_MinimizeMaximizeCompletes MinimizeMaximizeCompletes 640 #define MAYBE_MinimizeMaximizeCompletes MinimizeMaximizeCompletes
640 #endif 641 #endif
641 TEST_F(ToplevelWindowEventHandlerTest, MAYBE_MinimizeMaximizeCompletes) { 642 TEST_F(ToplevelWindowEventHandlerTest, MAYBE_MinimizeMaximizeCompletes) {
642 // Once window is minimized, window dragging completes. 643 // Once window is minimized, window dragging completes.
643 { 644 {
644 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); 645 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION));
645 target->Focus(); 646 target->Focus();
646 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 647 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
647 target.get()); 648 target.get());
648 generator.PressLeftButton(); 649 generator.PressLeftButton();
649 generator.MoveMouseBy(10, 11); 650 generator.MoveMouseBy(10, 11);
650 RunAllPendingInMessageLoop(); 651 RunAllPendingInMessageLoop();
651 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); 652 EXPECT_EQ("10,11 100x100", target->bounds().ToString());
652 wm::WindowState* window_state = wm::GetWindowState(target.get()); 653 wm::WindowState* window_state = wm::GetWindowState(target.get());
653 window_state->Minimize(); 654 window_state->Minimize();
654 window_state->Restore(); 655 window_state->Restore();
655 656
656 generator.PressLeftButton(); 657 generator.PressLeftButton();
657 generator.MoveMouseBy(10, 11); 658 generator.MoveMouseBy(10, 11);
658 RunAllPendingInMessageLoop(); 659 RunAllPendingInMessageLoop();
659 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); 660 EXPECT_EQ("10,11 100x100", target->bounds().ToString());
660 } 661 }
661 662
662 // Once window is maximized, window dragging completes. 663 // Once window is maximized, window dragging completes.
663 { 664 {
664 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); 665 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION));
665 target->Focus(); 666 target->Focus();
666 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 667 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
667 target.get()); 668 target.get());
668 generator.PressLeftButton(); 669 generator.PressLeftButton();
669 generator.MoveMouseBy(10, 11); 670 generator.MoveMouseBy(10, 11);
670 RunAllPendingInMessageLoop(); 671 RunAllPendingInMessageLoop();
671 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); 672 EXPECT_EQ("10,11 100x100", target->bounds().ToString());
672 wm::WindowState* window_state = wm::GetWindowState(target.get()); 673 wm::WindowState* window_state = wm::GetWindowState(target.get());
673 window_state->Maximize(); 674 window_state->Maximize();
674 window_state->Restore(); 675 window_state->Restore();
675 676
676 generator.PressLeftButton(); 677 generator.PressLeftButton();
677 generator.MoveMouseBy(10, 11); 678 generator.MoveMouseBy(10, 11);
678 RunAllPendingInMessageLoop(); 679 RunAllPendingInMessageLoop();
679 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); 680 EXPECT_EQ("10,11 100x100", target->bounds().ToString());
680 } 681 }
681 } 682 }
682 683
683 // Verifies that a drag cannot be started via 684 // Verifies that a drag cannot be started via
684 // aura::client::WindowMoveClient::RunMoveLoop() while another drag is already 685 // aura::client::WindowMoveClient::RunMoveLoop() while another drag is already
685 // in progress. 686 // in progress.
686 TEST_F(ToplevelWindowEventHandlerTest, RunMoveLoopFailsDuringInProgressDrag) { 687 TEST_F(ToplevelWindowEventHandlerTest, RunMoveLoopFailsDuringInProgressDrag) {
687 scoped_ptr<aura::Window> window1(CreateWindow(HTCAPTION)); 688 scoped_ptr<aura::Window> window1(CreateWindow(HTCAPTION));
688 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); 689 EXPECT_EQ("0,0 100x100", window1->bounds().ToString());
689 scoped_ptr<aura::Window> window2(CreateWindow(HTCAPTION)); 690 scoped_ptr<aura::Window> window2(CreateWindow(HTCAPTION));
690 691
691 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 692 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
692 window1.get()); 693 window1.get());
693 window1->Focus(); 694 window1->Focus();
694 generator.PressLeftButton(); 695 generator.PressLeftButton();
695 generator.MoveMouseBy(10, 11); 696 generator.MoveMouseBy(10, 11);
696 EXPECT_EQ("10,11 100x100", window1->bounds().ToString()); 697 EXPECT_EQ("10,11 100x100", window1->bounds().ToString());
697 698
698 aura::client::WindowMoveClient* move_client = 699 aura::client::WindowMoveClient* move_client =
699 aura::client::GetWindowMoveClient(window2->GetRootWindow()); 700 aura::client::GetWindowMoveClient(window2->GetRootWindow());
700 EXPECT_EQ(aura::client::MOVE_CANCELED, 701 EXPECT_EQ(aura::client::MOVE_CANCELED,
701 move_client->RunMoveLoop(window2.get(), gfx::Vector2d(), 702 move_client->RunMoveLoop(window2.get(), gfx::Vector2d(),
702 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 703 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
703 704
704 generator.ReleaseLeftButton(); 705 generator.ReleaseLeftButton();
705 EXPECT_EQ("10,11 100x100", window1->bounds().ToString()); 706 EXPECT_EQ("10,11 100x100", window1->bounds().ToString());
706 } 707 }
707 708
708 namespace { 709 namespace {
709 710
710 void SendMouseReleaseAndReleaseCapture(ui::test::EventGenerator* generator, 711 void SendMouseReleaseAndReleaseCapture(aura::test::EventGenerator* generator,
711 aura::Window* window) { 712 aura::Window* window) {
712 generator->ReleaseLeftButton(); 713 generator->ReleaseLeftButton();
713 window->ReleaseCapture(); 714 window->ReleaseCapture();
714 } 715 }
715 716
716 } // namespace 717 } // namespace
717 718
718 // Test that a drag is successful even if ET_MOUSE_CAPTURE_CHANGED is sent 719 // Test that a drag is successful even if ET_MOUSE_CAPTURE_CHANGED is sent
719 // immediately after the mouse release. views::Widget has this behavior. 720 // immediately after the mouse release. views::Widget has this behavior.
720 TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) { 721 TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) {
721 scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE)); 722 scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE));
722 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 723 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
723 window.get()); 724 window.get());
724 generator.PressLeftButton(); 725 generator.PressLeftButton();
725 window->SetCapture(); 726 window->SetCapture();
726 727
727 aura::client::WindowMoveClient* move_client = 728 aura::client::WindowMoveClient* move_client =
728 aura::client::GetWindowMoveClient(window->GetRootWindow()); 729 aura::client::GetWindowMoveClient(window->GetRootWindow());
729 base::MessageLoopForUI::current()->PostTask( 730 base::MessageLoopForUI::current()->PostTask(
730 FROM_HERE, 731 FROM_HERE,
731 base::Bind(&SendMouseReleaseAndReleaseCapture, 732 base::Bind(&SendMouseReleaseAndReleaseCapture,
732 base::Unretained(&generator), 733 base::Unretained(&generator),
733 base::Unretained(window.get()))); 734 base::Unretained(window.get())));
734 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, 735 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
735 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), 736 move_client->RunMoveLoop(window.get(), gfx::Vector2d(),
736 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 737 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
737 } 738 }
738 739
739 // Showing the resize shadows when the mouse is over the window edges is tested 740 // Showing the resize shadows when the mouse is over the window edges is tested
740 // in resize_shadow_and_cursor_test.cc 741 // in resize_shadow_and_cursor_test.cc
741 742
742 } // namespace test 743 } // namespace test
743 } // namespace ash 744 } // namespace ash
OLDNEW
« no previous file with comments | « trunk/src/ash/wm/system_modal_container_layout_manager_unittest.cc ('k') | trunk/src/ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698