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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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/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/test_activation_delegate.h" 8 #include "ash/test/test_activation_delegate.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ui/aura/client/cursor_client_observer.h" 10 #include "ui/aura/client/cursor_client_observer.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 // The key press should be sent to the focused sub-window. 180 // The key press should be sent to the focused sub-window.
181 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE); 181 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE);
182 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&keyev); 182 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&keyev);
183 ASSERT_FALSE(details.dispatcher_destroyed); 183 ASSERT_FALSE(details.dispatcher_destroyed);
184 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); 184 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code());
185 185
186 // Touch on a sub-window (w122) to focus it. 186 // Touch on a sub-window (w122) to focus it.
187 gfx::Point click_point = w122->bounds().CenterPoint(); 187 gfx::Point click_point = w122->bounds().CenterPoint();
188 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); 188 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point);
189 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); 189 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::PointF(click_point), 0,
190 getTime());
190 details = dispatcher->OnEventFromSource(&touchev); 191 details = dispatcher->OnEventFromSource(&touchev);
191 ASSERT_FALSE(details.dispatcher_destroyed); 192 ASSERT_FALSE(details.dispatcher_destroyed);
192 focus_client = aura::client::GetFocusClient(w122.get()); 193 focus_client = aura::client::GetFocusClient(w122.get());
193 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); 194 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow());
194 195
195 // The key press should be sent to the focused sub-window. 196 // The key press should be sent to the focused sub-window.
196 keyev = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE); 197 keyev = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE);
197 details = dispatcher->OnEventFromSource(&keyev); 198 details = dispatcher->OnEventFromSource(&keyev);
198 ASSERT_FALSE(details.dispatcher_destroyed); 199 ASSERT_FALSE(details.dispatcher_destroyed);
199 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); 200 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code());
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 wm::ActivateWindow(w1.get()); 434 wm::ActivateWindow(w1.get());
434 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 435 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
435 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); 436 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow());
436 EXPECT_EQ(1, d1.activated_count()); 437 EXPECT_EQ(1, d1.activated_count());
437 EXPECT_EQ(0, d1.lost_active_count()); 438 EXPECT_EQ(0, d1.lost_active_count());
438 d1.Clear(); 439 d1.Clear();
439 440
440 // Touch window2. 441 // Touch window2.
441 gfx::Point press_point = w2->bounds().CenterPoint(); 442 gfx::Point press_point = w2->bounds().CenterPoint();
442 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); 443 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point);
443 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); 444 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, gfx::PointF(press_point), 0,
445 getTime());
444 446
445 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); 447 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
446 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&touchev1); 448 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&touchev1);
447 ASSERT_FALSE(details.dispatcher_destroyed); 449 ASSERT_FALSE(details.dispatcher_destroyed);
448 450
449 // Window2 should have become active. 451 // Window2 should have become active.
450 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 452 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
451 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); 453 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow());
452 EXPECT_EQ(0, d1.activated_count()); 454 EXPECT_EQ(0, d1.activated_count());
453 EXPECT_EQ(1, d1.lost_active_count()); 455 EXPECT_EQ(1, d1.lost_active_count());
454 EXPECT_EQ(1, d2.activated_count()); 456 EXPECT_EQ(1, d2.activated_count());
455 EXPECT_EQ(0, d2.lost_active_count()); 457 EXPECT_EQ(0, d2.lost_active_count());
456 d1.Clear(); 458 d1.Clear();
457 d2.Clear(); 459 d2.Clear();
458 460
459 // Touch window1, but set it up so w1 doesn't activate on touch. 461 // Touch window1, but set it up so w1 doesn't activate on touch.
460 press_point = w1->bounds().CenterPoint(); 462 press_point = w1->bounds().CenterPoint();
461 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point); 463 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point);
462 d1.set_activate(false); 464 d1.set_activate(false);
463 ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); 465 ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::PointF(press_point), 1,
466 getTime());
464 details = dispatcher->OnEventFromSource(&touchev2); 467 details = dispatcher->OnEventFromSource(&touchev2);
465 ASSERT_FALSE(details.dispatcher_destroyed); 468 ASSERT_FALSE(details.dispatcher_destroyed);
466 469
467 // Window2 should still be active and focused. 470 // Window2 should still be active and focused.
468 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 471 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
469 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); 472 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow());
470 EXPECT_EQ(0, d1.activated_count()); 473 EXPECT_EQ(0, d1.activated_count());
471 EXPECT_EQ(0, d1.lost_active_count()); 474 EXPECT_EQ(0, d1.lost_active_count());
472 EXPECT_EQ(0, d2.activated_count()); 475 EXPECT_EQ(0, d2.activated_count());
473 EXPECT_EQ(0, d2.lost_active_count()); 476 EXPECT_EQ(0, d2.lost_active_count());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 509
507 aura::WindowTreeHost* host = root_window->GetHost(); 510 aura::WindowTreeHost* host = root_window->GetHost();
508 ui::EventProcessor* dispatcher = host->event_processor(); 511 ui::EventProcessor* dispatcher = host->event_processor();
509 512
510 // Cursor starts as a pointer (set during Shell::Init()). 513 // Cursor starts as a pointer (set during Shell::Init()).
511 EXPECT_EQ(ui::kCursorPointer, host->last_cursor().native_type()); 514 EXPECT_EQ(ui::kCursorPointer, host->last_cursor().native_type());
512 515
513 { 516 {
514 // Resize edges and corners show proper cursors. 517 // Resize edges and corners show proper cursors.
515 window_delegate.set_hittest_code(HTBOTTOM); 518 window_delegate.set_hittest_code(HTBOTTOM);
516 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 519 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, gfx::PointF(point1),
517 ui::EventTimeForNow(), 0, 0); 520 gfx::PointF(point1), ui::EventTimeForNow(), 0, 0);
518 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 521 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
519 ASSERT_FALSE(details.dispatcher_destroyed); 522 ASSERT_FALSE(details.dispatcher_destroyed);
520 EXPECT_EQ(ui::kCursorSouthResize, host->last_cursor().native_type()); 523 EXPECT_EQ(ui::kCursorSouthResize, host->last_cursor().native_type());
521 } 524 }
522 525
523 { 526 {
524 window_delegate.set_hittest_code(HTBOTTOMLEFT); 527 window_delegate.set_hittest_code(HTBOTTOMLEFT);
525 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 528 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, gfx::PointF(point2),
526 ui::EventTimeForNow(), 0, 0); 529 gfx::PointF(point2), ui::EventTimeForNow(), 0, 0);
527 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); 530 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2);
528 ASSERT_FALSE(details.dispatcher_destroyed); 531 ASSERT_FALSE(details.dispatcher_destroyed);
529 EXPECT_EQ(ui::kCursorSouthWestResize, host->last_cursor().native_type()); 532 EXPECT_EQ(ui::kCursorSouthWestResize, host->last_cursor().native_type());
530 } 533 }
531 534
532 { 535 {
533 window_delegate.set_hittest_code(HTBOTTOMRIGHT); 536 window_delegate.set_hittest_code(HTBOTTOMRIGHT);
534 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 537 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, gfx::PointF(point1),
535 ui::EventTimeForNow(), 0, 0); 538 gfx::PointF(point1), ui::EventTimeForNow(), 0, 0);
536 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 539 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
537 ASSERT_FALSE(details.dispatcher_destroyed); 540 ASSERT_FALSE(details.dispatcher_destroyed);
538 EXPECT_EQ(ui::kCursorSouthEastResize, host->last_cursor().native_type()); 541 EXPECT_EQ(ui::kCursorSouthEastResize, host->last_cursor().native_type());
539 } 542 }
540 543
541 { 544 {
542 window_delegate.set_hittest_code(HTLEFT); 545 window_delegate.set_hittest_code(HTLEFT);
543 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 546 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, gfx::PointF(point2),
544 ui::EventTimeForNow(), 0, 0); 547 gfx::PointF(point2), ui::EventTimeForNow(), 0, 0);
545 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); 548 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2);
546 ASSERT_FALSE(details.dispatcher_destroyed); 549 ASSERT_FALSE(details.dispatcher_destroyed);
547 EXPECT_EQ(ui::kCursorWestResize, host->last_cursor().native_type()); 550 EXPECT_EQ(ui::kCursorWestResize, host->last_cursor().native_type());
548 } 551 }
549 552
550 { 553 {
551 window_delegate.set_hittest_code(HTRIGHT); 554 window_delegate.set_hittest_code(HTRIGHT);
552 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 555 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, gfx::PointF(point1),
553 ui::EventTimeForNow(), 0, 0); 556 gfx::PointF(point1), ui::EventTimeForNow(), 0, 0);
554 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 557 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
555 ASSERT_FALSE(details.dispatcher_destroyed); 558 ASSERT_FALSE(details.dispatcher_destroyed);
556 EXPECT_EQ(ui::kCursorEastResize, host->last_cursor().native_type()); 559 EXPECT_EQ(ui::kCursorEastResize, host->last_cursor().native_type());
557 } 560 }
558 561
559 { 562 {
560 window_delegate.set_hittest_code(HTTOP); 563 window_delegate.set_hittest_code(HTTOP);
561 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, gfx::PointF(point2),
562 ui::EventTimeForNow(), 0, 0); 565 gfx::PointF(point2), ui::EventTimeForNow(), 0, 0);
563 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); 566 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2);
564 ASSERT_FALSE(details.dispatcher_destroyed); 567 ASSERT_FALSE(details.dispatcher_destroyed);
565 EXPECT_EQ(ui::kCursorNorthResize, host->last_cursor().native_type()); 568 EXPECT_EQ(ui::kCursorNorthResize, host->last_cursor().native_type());
566 } 569 }
567 570
568 { 571 {
569 window_delegate.set_hittest_code(HTTOPLEFT); 572 window_delegate.set_hittest_code(HTTOPLEFT);
570 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, gfx::PointF(point1),
571 ui::EventTimeForNow(), 0, 0); 574 gfx::PointF(point1), ui::EventTimeForNow(), 0, 0);
572 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 575 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
573 ASSERT_FALSE(details.dispatcher_destroyed); 576 ASSERT_FALSE(details.dispatcher_destroyed);
574 EXPECT_EQ(ui::kCursorNorthWestResize, host->last_cursor().native_type()); 577 EXPECT_EQ(ui::kCursorNorthWestResize, host->last_cursor().native_type());
575 } 578 }
576 579
577 { 580 {
578 window_delegate.set_hittest_code(HTTOPRIGHT); 581 window_delegate.set_hittest_code(HTTOPRIGHT);
579 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 582 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, gfx::PointF(point2),
580 ui::EventTimeForNow(), 0, 0); 583 gfx::PointF(point2), ui::EventTimeForNow(), 0, 0);
581 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); 584 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2);
582 ASSERT_FALSE(details.dispatcher_destroyed); 585 ASSERT_FALSE(details.dispatcher_destroyed);
583 EXPECT_EQ(ui::kCursorNorthEastResize, host->last_cursor().native_type()); 586 EXPECT_EQ(ui::kCursorNorthEastResize, host->last_cursor().native_type());
584 } 587 }
585 588
586 { 589 {
587 // Client area uses null cursor. 590 // Client area uses null cursor.
588 window_delegate.set_hittest_code(HTCLIENT); 591 window_delegate.set_hittest_code(HTCLIENT);
589 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 592 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, gfx::PointF(point1),
590 ui::EventTimeForNow(), 0, 0); 593 gfx::PointF(point1), ui::EventTimeForNow(), 0, 0);
591 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 594 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
592 ASSERT_FALSE(details.dispatcher_destroyed); 595 ASSERT_FALSE(details.dispatcher_destroyed);
593 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); 596 EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type());
594 } 597 }
595 } 598 }
596 599
597 #if defined(OS_WIN) 600 #if defined(OS_WIN)
598 #define MAYBE_TransformActivate DISABLED_TransformActivate 601 #define MAYBE_TransformActivate DISABLED_TransformActivate
599 #else 602 #else
600 #define MAYBE_TransformActivate TransformActivate 603 #define MAYBE_TransformActivate TransformActivate
(...skipping 11 matching lines...) Expand all
612 transform.Rotate(90.0f); 615 transform.Rotate(90.0f);
613 root_window->GetHost()->SetRootTransform(transform); 616 root_window->GetHost()->SetRootTransform(transform);
614 617
615 test::TestActivationDelegate d1; 618 test::TestActivationDelegate d1;
616 aura::test::TestWindowDelegate wd; 619 aura::test::TestWindowDelegate wd;
617 scoped_ptr<aura::Window> w1( 620 scoped_ptr<aura::Window> w1(
618 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); 621 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50)));
619 d1.SetWindow(w1.get()); 622 d1.SetWindow(w1.get());
620 w1->Show(); 623 w1->Show();
621 624
622 gfx::Point miss_point(5, 5); 625 gfx::Point3F miss_point(5.f, 5.f, 0.f);
623 transform.TransformPoint(&miss_point); 626 transform.TransformPoint(&miss_point);
624 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point, miss_point, 627 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point.AsPointF(),
625 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 628 miss_point.AsPointF(), ui::EventTimeForNow(),
626 ui::EF_LEFT_MOUSE_BUTTON); 629 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
627 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); 630 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
628 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1); 631 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1);
629 ASSERT_FALSE(details.dispatcher_destroyed); 632 ASSERT_FALSE(details.dispatcher_destroyed);
630 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 633 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
631 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, miss_point, miss_point, 634 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, miss_point.AsPointF(),
632 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 635 miss_point.AsPointF(), ui::EventTimeForNow(),
633 ui::EF_LEFT_MOUSE_BUTTON); 636 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
634 details = dispatcher->OnEventFromSource(&mouseup); 637 details = dispatcher->OnEventFromSource(&mouseup);
635 ASSERT_FALSE(details.dispatcher_destroyed); 638 ASSERT_FALSE(details.dispatcher_destroyed);
636 639
637 gfx::Point hit_point(5, 15); 640 gfx::Point3F hit_point(5.f, 15.f, 0.f);
638 transform.TransformPoint(&hit_point); 641 transform.TransformPoint(&hit_point);
639 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, hit_point, hit_point, 642 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, hit_point.AsPointF(),
640 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 643 hit_point.AsPointF(), ui::EventTimeForNow(),
641 ui::EF_LEFT_MOUSE_BUTTON); 644 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
642 details = dispatcher->OnEventFromSource(&mouseev2); 645 details = dispatcher->OnEventFromSource(&mouseev2);
643 ASSERT_FALSE(details.dispatcher_destroyed); 646 ASSERT_FALSE(details.dispatcher_destroyed);
644 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 647 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
645 EXPECT_EQ(w1.get(), 648 EXPECT_EQ(w1.get(),
646 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 649 aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
647 } 650 }
648 651
649 TEST_F(WindowManagerTest, AdditionalFilters) { 652 TEST_F(WindowManagerTest, AdditionalFilters) {
650 // The IME event filter interferes with the basic key event propagation we 653 // The IME event filter interferes with the basic key event propagation we
651 // attempt to do here, so we disable it. 654 // attempt to do here, so we disable it.
(...skipping 13 matching lines...) Expand all
665 ::wm::CompoundEventFilter* env_filter = 668 ::wm::CompoundEventFilter* env_filter =
666 Shell::GetInstance()->env_filter(); 669 Shell::GetInstance()->env_filter();
667 env_filter->AddHandler(f1.get()); 670 env_filter->AddHandler(f1.get());
668 env_filter->AddHandler(f2.get()); 671 env_filter->AddHandler(f2.get());
669 672
670 // Dispatches mouse and keyboard events. 673 // Dispatches mouse and keyboard events.
671 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); 674 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
672 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); 675 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
673 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event); 676 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event);
674 ASSERT_FALSE(details.dispatcher_destroyed); 677 ASSERT_FALSE(details.dispatcher_destroyed);
675 ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), 678 ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(),
676 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); 679 gfx::PointF(), ui::EventTimeForNow(), 0, 0);
677 details = dispatcher->OnEventFromSource(&mouse_pressed); 680 details = dispatcher->OnEventFromSource(&mouse_pressed);
678 ASSERT_FALSE(details.dispatcher_destroyed); 681 ASSERT_FALSE(details.dispatcher_destroyed);
679 682
680 // Both filters should get the events. 683 // Both filters should get the events.
681 EXPECT_EQ(1, f1->num_key_events()); 684 EXPECT_EQ(1, f1->num_key_events());
682 EXPECT_EQ(1, f1->num_mouse_events()); 685 EXPECT_EQ(1, f1->num_mouse_events());
683 EXPECT_EQ(1, f2->num_key_events()); 686 EXPECT_EQ(1, f2->num_key_events());
684 EXPECT_EQ(1, f2->num_mouse_events()); 687 EXPECT_EQ(1, f2->num_mouse_events());
685 688
686 f1->Reset(); 689 f1->Reset();
687 f2->Reset(); 690 f2->Reset();
688 691
689 // Makes f1 consume events. 692 // Makes f1 consume events.
690 f1->set_key_event_handling_result(ui::ER_CONSUMED); 693 f1->set_key_event_handling_result(ui::ER_CONSUMED);
691 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); 694 f1->set_mouse_event_handling_result(ui::ER_CONSUMED);
692 695
693 // Dispatches events. 696 // Dispatches events.
694 details = dispatcher->OnEventFromSource(&key_event); 697 details = dispatcher->OnEventFromSource(&key_event);
695 ASSERT_FALSE(details.dispatcher_destroyed); 698 ASSERT_FALSE(details.dispatcher_destroyed);
696 ui::MouseEvent mouse_released(ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), 699 ui::MouseEvent mouse_released(ui::ET_MOUSE_RELEASED, gfx::PointF(),
697 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); 700 gfx::PointF(), ui::EventTimeForNow(), 0, 0);
698 details = dispatcher->OnEventFromSource(&mouse_released); 701 details = dispatcher->OnEventFromSource(&mouse_released);
699 ASSERT_FALSE(details.dispatcher_destroyed); 702 ASSERT_FALSE(details.dispatcher_destroyed);
700 703
701 // f1 should still get the events but f2 no longer gets them. 704 // f1 should still get the events but f2 no longer gets them.
702 EXPECT_EQ(1, f1->num_key_events()); 705 EXPECT_EQ(1, f1->num_key_events());
703 EXPECT_EQ(1, f1->num_mouse_events()); 706 EXPECT_EQ(1, f1->num_mouse_events());
704 EXPECT_EQ(0, f2->num_key_events()); 707 EXPECT_EQ(0, f2->num_key_events());
705 EXPECT_EQ(0, f2->num_mouse_events()); 708 EXPECT_EQ(0, f2->num_mouse_events());
706 709
707 f1->Reset(); 710 f1->Reset();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 generator.MoveMouseTo(50, 50); 853 generator.MoveMouseTo(50, 50);
851 EXPECT_TRUE(observer_a.did_visibility_change()); 854 EXPECT_TRUE(observer_a.did_visibility_change());
852 EXPECT_FALSE(observer_b.did_visibility_change()); 855 EXPECT_FALSE(observer_b.did_visibility_change());
853 EXPECT_TRUE(observer_a.is_cursor_visible()); 856 EXPECT_TRUE(observer_a.is_cursor_visible());
854 857
855 cursor_manager->RemoveObserver(&observer_a); 858 cursor_manager->RemoveObserver(&observer_a);
856 } 859 }
857 #endif // defined(OS_CHROMEOS) 860 #endif // defined(OS_CHROMEOS)
858 861
859 } // namespace ash 862 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698