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

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

Issue 101573006: Changes MouseEvent constructor to take changed_button_flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test; needs updated expectations as mouse entered wasnt sent before because of env::mouse_butto… Created 7 years 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/shell.h" 5 #include "ash/shell.h"
6 #include "ash/shell_window_ids.h" 6 #include "ash/shell_window_ids.h"
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ash/test/shell_test_api.h" 8 #include "ash/test/shell_test_api.h"
9 #include "ash/test/test_activation_delegate.h" 9 #include "ash/test/test_activation_delegate.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); 502 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2);
503 503
504 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 504 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
505 505
506 // Cursor starts as a pointer (set during Shell::Init()). 506 // Cursor starts as a pointer (set during Shell::Init()).
507 EXPECT_EQ(ui::kCursorPointer, dispatcher->last_cursor().native_type()); 507 EXPECT_EQ(ui::kCursorPointer, dispatcher->last_cursor().native_type());
508 508
509 { 509 {
510 // Resize edges and corners show proper cursors. 510 // Resize edges and corners show proper cursors.
511 window_delegate.set_hittest_code(HTBOTTOM); 511 window_delegate.set_hittest_code(HTBOTTOM);
512 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); 512 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
513 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); 513 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
514 EXPECT_EQ(ui::kCursorSouthResize, dispatcher->last_cursor().native_type()); 514 EXPECT_EQ(ui::kCursorSouthResize, dispatcher->last_cursor().native_type());
515 } 515 }
516 516
517 { 517 {
518 window_delegate.set_hittest_code(HTBOTTOMLEFT); 518 window_delegate.set_hittest_code(HTBOTTOMLEFT);
519 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); 519 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0);
520 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); 520 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
521 EXPECT_EQ(ui::kCursorSouthWestResize, 521 EXPECT_EQ(ui::kCursorSouthWestResize,
522 dispatcher->last_cursor().native_type()); 522 dispatcher->last_cursor().native_type());
523 } 523 }
524 524
525 { 525 {
526 window_delegate.set_hittest_code(HTBOTTOMRIGHT); 526 window_delegate.set_hittest_code(HTBOTTOMRIGHT);
527 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); 527 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
528 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); 528 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
529 EXPECT_EQ(ui::kCursorSouthEastResize, 529 EXPECT_EQ(ui::kCursorSouthEastResize,
530 dispatcher->last_cursor().native_type()); 530 dispatcher->last_cursor().native_type());
531 } 531 }
532 532
533 { 533 {
534 window_delegate.set_hittest_code(HTLEFT); 534 window_delegate.set_hittest_code(HTLEFT);
535 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); 535 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0);
536 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); 536 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
537 EXPECT_EQ(ui::kCursorWestResize, dispatcher->last_cursor().native_type()); 537 EXPECT_EQ(ui::kCursorWestResize, dispatcher->last_cursor().native_type());
538 } 538 }
539 539
540 { 540 {
541 window_delegate.set_hittest_code(HTRIGHT); 541 window_delegate.set_hittest_code(HTRIGHT);
542 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); 542 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
543 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); 543 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
544 EXPECT_EQ(ui::kCursorEastResize, dispatcher->last_cursor().native_type()); 544 EXPECT_EQ(ui::kCursorEastResize, dispatcher->last_cursor().native_type());
545 } 545 }
546 546
547 { 547 {
548 window_delegate.set_hittest_code(HTTOP); 548 window_delegate.set_hittest_code(HTTOP);
549 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); 549 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0);
550 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); 550 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
551 EXPECT_EQ(ui::kCursorNorthResize, dispatcher->last_cursor().native_type()); 551 EXPECT_EQ(ui::kCursorNorthResize, dispatcher->last_cursor().native_type());
552 } 552 }
553 553
554 { 554 {
555 window_delegate.set_hittest_code(HTTOPLEFT); 555 window_delegate.set_hittest_code(HTTOPLEFT);
556 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); 556 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
557 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); 557 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
558 EXPECT_EQ(ui::kCursorNorthWestResize, 558 EXPECT_EQ(ui::kCursorNorthWestResize,
559 dispatcher->last_cursor().native_type()); 559 dispatcher->last_cursor().native_type());
560 } 560 }
561 561
562 { 562 {
563 window_delegate.set_hittest_code(HTTOPRIGHT); 563 window_delegate.set_hittest_code(HTTOPRIGHT);
564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); 564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0);
565 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); 565 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
566 EXPECT_EQ(ui::kCursorNorthEastResize, 566 EXPECT_EQ(ui::kCursorNorthEastResize,
567 dispatcher->last_cursor().native_type()); 567 dispatcher->last_cursor().native_type());
568 } 568 }
569 569
570 { 570 {
571 // Client area uses null cursor. 571 // Client area uses null cursor.
572 window_delegate.set_hittest_code(HTCLIENT); 572 window_delegate.set_hittest_code(HTCLIENT);
573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); 573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
574 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); 574 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
575 EXPECT_EQ(ui::kCursorNull, dispatcher->last_cursor().native_type()); 575 EXPECT_EQ(ui::kCursorNull, dispatcher->last_cursor().native_type());
576 } 576 }
577 } 577 }
578 578
579 #if defined(OS_WIN) 579 #if defined(OS_WIN)
580 #define MAYBE_TransformActivate DISABLED_TransformActivate 580 #define MAYBE_TransformActivate DISABLED_TransformActivate
581 #else 581 #else
582 #define MAYBE_TransformActivate TransformActivate 582 #define MAYBE_TransformActivate TransformActivate
583 #endif 583 #endif
(...skipping 15 matching lines...) Expand all
599 scoped_ptr<aura::Window> w1( 599 scoped_ptr<aura::Window> w1(
600 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50))); 600 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50)));
601 d1.SetWindow(w1.get()); 601 d1.SetWindow(w1.get());
602 w1->Show(); 602 w1->Show();
603 603
604 gfx::Point miss_point(5, 5); 604 gfx::Point miss_point(5, 5);
605 transform.TransformPoint(&miss_point); 605 transform.TransformPoint(&miss_point);
606 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, 606 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED,
607 miss_point, 607 miss_point,
608 miss_point, 608 miss_point,
609 ui::EF_LEFT_MOUSE_BUTTON,
609 ui::EF_LEFT_MOUSE_BUTTON); 610 ui::EF_LEFT_MOUSE_BUTTON);
610 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 611 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
611 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); 612 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1);
612 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 613 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
613 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, 614 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED,
614 miss_point, 615 miss_point,
615 miss_point, 616 miss_point,
617 ui::EF_LEFT_MOUSE_BUTTON,
616 ui::EF_LEFT_MOUSE_BUTTON); 618 ui::EF_LEFT_MOUSE_BUTTON);
617 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); 619 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup);
618 620
619 gfx::Point hit_point(5, 15); 621 gfx::Point hit_point(5, 15);
620 transform.TransformPoint(&hit_point); 622 transform.TransformPoint(&hit_point);
621 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, 623 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED,
622 hit_point, 624 hit_point,
623 hit_point, 625 hit_point,
626 ui::EF_LEFT_MOUSE_BUTTON,
624 ui::EF_LEFT_MOUSE_BUTTON); 627 ui::EF_LEFT_MOUSE_BUTTON);
625 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); 628 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2);
626 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 629 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
627 EXPECT_EQ(w1.get(), 630 EXPECT_EQ(w1.get(),
628 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 631 aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
629 } 632 }
630 633
631 TEST_F(WindowManagerTest, AdditionalFilters) { 634 TEST_F(WindowManagerTest, AdditionalFilters) {
632 // The IME event filter interferes with the basic key event propagation we 635 // The IME event filter interferes with the basic key event propagation we
633 // attempt to do here, so we remove it. 636 // attempt to do here, so we remove it.
(...skipping 16 matching lines...) Expand all
650 views::corewm::CompoundEventFilter* env_filter = 653 views::corewm::CompoundEventFilter* env_filter =
651 Shell::GetInstance()->env_filter(); 654 Shell::GetInstance()->env_filter();
652 env_filter->AddHandler(f1.get()); 655 env_filter->AddHandler(f1.get());
653 env_filter->AddHandler(f2.get()); 656 env_filter->AddHandler(f2.get());
654 657
655 // Dispatches mouse and keyboard events. 658 // Dispatches mouse and keyboard events.
656 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); 659 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
657 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 660 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
658 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); 661 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
659 ui::MouseEvent mouse_pressed( 662 ui::MouseEvent mouse_pressed(
660 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); 663 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0);
661 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); 664 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed);
662 665
663 // Both filters should get the events. 666 // Both filters should get the events.
664 EXPECT_EQ(1, f1->num_key_events()); 667 EXPECT_EQ(1, f1->num_key_events());
665 EXPECT_EQ(1, f1->num_mouse_events()); 668 EXPECT_EQ(1, f1->num_mouse_events());
666 EXPECT_EQ(1, f2->num_key_events()); 669 EXPECT_EQ(1, f2->num_key_events());
667 EXPECT_EQ(1, f2->num_mouse_events()); 670 EXPECT_EQ(1, f2->num_mouse_events());
668 671
669 f1->Reset(); 672 f1->Reset();
670 f2->Reset(); 673 f2->Reset();
671 674
672 // Makes f1 consume events. 675 // Makes f1 consume events.
673 f1->set_key_event_handling_result(ui::ER_CONSUMED); 676 f1->set_key_event_handling_result(ui::ER_CONSUMED);
674 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); 677 f1->set_mouse_event_handling_result(ui::ER_CONSUMED);
675 678
676 // Dispatches events. 679 // Dispatches events.
677 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); 680 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
678 ui::MouseEvent mouse_released( 681 ui::MouseEvent mouse_released(
679 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); 682 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0);
680 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); 683 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released);
681 684
682 // f1 should still get the events but f2 no longer gets them. 685 // f1 should still get the events but f2 no longer gets them.
683 EXPECT_EQ(1, f1->num_key_events()); 686 EXPECT_EQ(1, f1->num_key_events());
684 EXPECT_EQ(1, f1->num_mouse_events()); 687 EXPECT_EQ(1, f1->num_mouse_events());
685 EXPECT_EQ(0, f2->num_key_events()); 688 EXPECT_EQ(0, f2->num_key_events());
686 EXPECT_EQ(0, f2->num_mouse_events()); 689 EXPECT_EQ(0, f2->num_mouse_events());
687 690
688 f1->Reset(); 691 f1->Reset();
689 f2->Reset(); 692 f2->Reset();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 observer_a.reset(); 813 observer_a.reset();
811 observer_b.reset(); 814 observer_b.reset();
812 generator.MoveMouseTo(50, 50); 815 generator.MoveMouseTo(50, 50);
813 EXPECT_TRUE(observer_a.did_visibility_change()); 816 EXPECT_TRUE(observer_a.did_visibility_change());
814 EXPECT_FALSE(observer_b.did_visibility_change()); 817 EXPECT_FALSE(observer_b.did_visibility_change());
815 EXPECT_TRUE(observer_a.is_cursor_visible()); 818 EXPECT_TRUE(observer_a.is_cursor_visible());
816 } 819 }
817 #endif // defined(OS_CHROMEOS) 820 #endif // defined(OS_CHROMEOS)
818 821
819 } // namespace ash 822 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/user_activity_detector_unittest.cc ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698