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

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

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 // Click on a sub-window (w121) to focus it. 177 // Click on a sub-window (w121) to focus it.
178 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 178 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
179 w121.get()); 179 w121.get());
180 generator.ClickLeftButton(); 180 generator.ClickLeftButton();
181 181
182 aura::client::FocusClient* focus_client = 182 aura::client::FocusClient* focus_client =
183 aura::client::GetFocusClient(w121.get()); 183 aura::client::GetFocusClient(w121.get());
184 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); 184 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow());
185 185
186 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 186 aura::WindowEventDispatcher* dispatcher =
187 root_window->GetHost()->dispatcher();
187 188
188 // The key press should be sent to the focused sub-window. 189 // The key press should be sent to the focused sub-window.
189 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); 190 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false);
190 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&keyev); 191 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&keyev);
191 ASSERT_FALSE(details.dispatcher_destroyed); 192 ASSERT_FALSE(details.dispatcher_destroyed);
192 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); 193 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code());
193 194
194 // Touch on a sub-window (w122) to focus it. 195 // Touch on a sub-window (w122) to focus it.
195 gfx::Point click_point = w122->bounds().CenterPoint(); 196 gfx::Point click_point = w122->bounds().CenterPoint();
196 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); 197 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); 440 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow());
440 EXPECT_EQ(1, d1.activated_count()); 441 EXPECT_EQ(1, d1.activated_count());
441 EXPECT_EQ(0, d1.lost_active_count()); 442 EXPECT_EQ(0, d1.lost_active_count());
442 d1.Clear(); 443 d1.Clear();
443 444
444 // Touch window2. 445 // Touch window2.
445 gfx::Point press_point = w2->bounds().CenterPoint(); 446 gfx::Point press_point = w2->bounds().CenterPoint();
446 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); 447 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point);
447 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); 448 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime());
448 449
449 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 450 aura::WindowEventDispatcher* dispatcher =
451 root_window->GetHost()->dispatcher();
450 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&touchev1); 452 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&touchev1);
451 ASSERT_FALSE(details.dispatcher_destroyed); 453 ASSERT_FALSE(details.dispatcher_destroyed);
452 454
453 // Window2 should have become active. 455 // Window2 should have become active.
454 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 456 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
455 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); 457 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow());
456 EXPECT_EQ(0, d1.activated_count()); 458 EXPECT_EQ(0, d1.activated_count());
457 EXPECT_EQ(1, d1.lost_active_count()); 459 EXPECT_EQ(1, d1.lost_active_count());
458 EXPECT_EQ(1, d2.activated_count()); 460 EXPECT_EQ(1, d2.activated_count());
459 EXPECT_EQ(0, d2.lost_active_count()); 461 EXPECT_EQ(0, d2.lost_active_count());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 -1, 503 -1,
502 gfx::Rect(kWindowLeft, kWindowTop, 640, 480))); 504 gfx::Rect(kWindowLeft, kWindowTop, 640, 480)));
503 505
504 // Create two mouse movement events we can switch between. 506 // Create two mouse movement events we can switch between.
505 gfx::Point point1(kWindowLeft, kWindowTop); 507 gfx::Point point1(kWindowLeft, kWindowTop);
506 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point1); 508 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point1);
507 509
508 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); 510 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1);
509 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); 511 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2);
510 512
511 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 513 aura::WindowEventDispatcher* dispatcher =
514 root_window->GetHost()->dispatcher();
512 515
513 // Cursor starts as a pointer (set during Shell::Init()). 516 // Cursor starts as a pointer (set during Shell::Init()).
514 EXPECT_EQ(ui::kCursorPointer, 517 EXPECT_EQ(ui::kCursorPointer,
515 dispatcher->host()->last_cursor().native_type()); 518 dispatcher->host()->last_cursor().native_type());
516 519
517 { 520 {
518 // Resize edges and corners show proper cursors. 521 // Resize edges and corners show proper cursors.
519 window_delegate.set_hittest_code(HTBOTTOM); 522 window_delegate.set_hittest_code(HTBOTTOM);
520 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); 523 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0);
521 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); 524 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 609 aura::Window* root_window = Shell::GetPrimaryRootWindow();
607 gfx::Size size = root_window->bounds().size(); 610 gfx::Size size = root_window->bounds().size();
608 EXPECT_EQ(gfx::Rect(size).ToString(), 611 EXPECT_EQ(gfx::Rect(size).ToString(),
609 Shell::GetScreen()->GetDisplayNearestPoint( 612 Shell::GetScreen()->GetDisplayNearestPoint(
610 gfx::Point()).bounds().ToString()); 613 gfx::Point()).bounds().ToString());
611 614
612 // Rotate it clock-wise 90 degrees. 615 // Rotate it clock-wise 90 degrees.
613 gfx::Transform transform; 616 gfx::Transform transform;
614 transform.Translate(size.width(), 0); 617 transform.Translate(size.width(), 0);
615 transform.Rotate(90.0f); 618 transform.Rotate(90.0f);
616 root_window->GetDispatcher()->host()->SetTransform(transform); 619 root_window->GetHost()->SetTransform(transform);
617 620
618 test::TestActivationDelegate d1; 621 test::TestActivationDelegate d1;
619 aura::test::TestWindowDelegate wd; 622 aura::test::TestWindowDelegate wd;
620 scoped_ptr<aura::Window> w1( 623 scoped_ptr<aura::Window> w1(
621 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); 624 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50)));
622 d1.SetWindow(w1.get()); 625 d1.SetWindow(w1.get());
623 w1->Show(); 626 w1->Show();
624 627
625 gfx::Point miss_point(5, 5); 628 gfx::Point miss_point(5, 5);
626 transform.TransformPoint(&miss_point); 629 transform.TransformPoint(&miss_point);
627 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, 630 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED,
628 miss_point, 631 miss_point,
629 miss_point, 632 miss_point,
630 ui::EF_LEFT_MOUSE_BUTTON, 633 ui::EF_LEFT_MOUSE_BUTTON,
631 ui::EF_LEFT_MOUSE_BUTTON); 634 ui::EF_LEFT_MOUSE_BUTTON);
632 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 635 aura::WindowEventDispatcher* dispatcher =
636 root_window->GetHost()->dispatcher();
633 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1); 637 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1);
634 ASSERT_FALSE(details.dispatcher_destroyed); 638 ASSERT_FALSE(details.dispatcher_destroyed);
635 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 639 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
636 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, 640 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED,
637 miss_point, 641 miss_point,
638 miss_point, 642 miss_point,
639 ui::EF_LEFT_MOUSE_BUTTON, 643 ui::EF_LEFT_MOUSE_BUTTON,
640 ui::EF_LEFT_MOUSE_BUTTON); 644 ui::EF_LEFT_MOUSE_BUTTON);
641 details = dispatcher->OnEventFromSource(&mouseup); 645 details = dispatcher->OnEventFromSource(&mouseup);
642 ASSERT_FALSE(details.dispatcher_destroyed); 646 ASSERT_FALSE(details.dispatcher_destroyed);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler); 678 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler);
675 679
676 // Adds them to root window event filter. 680 // Adds them to root window event filter.
677 views::corewm::CompoundEventFilter* env_filter = 681 views::corewm::CompoundEventFilter* env_filter =
678 Shell::GetInstance()->env_filter(); 682 Shell::GetInstance()->env_filter();
679 env_filter->AddHandler(f1.get()); 683 env_filter->AddHandler(f1.get());
680 env_filter->AddHandler(f2.get()); 684 env_filter->AddHandler(f2.get());
681 685
682 // Dispatches mouse and keyboard events. 686 // Dispatches mouse and keyboard events.
683 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); 687 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
684 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); 688 aura::WindowEventDispatcher* dispatcher =
689 root_window->GetHost()->dispatcher();
685 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event); 690 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event);
686 ASSERT_FALSE(details.dispatcher_destroyed); 691 ASSERT_FALSE(details.dispatcher_destroyed);
687 ui::MouseEvent mouse_pressed( 692 ui::MouseEvent mouse_pressed(
688 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); 693 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0);
689 details = dispatcher->OnEventFromSource(&mouse_pressed); 694 details = dispatcher->OnEventFromSource(&mouse_pressed);
690 ASSERT_FALSE(details.dispatcher_destroyed); 695 ASSERT_FALSE(details.dispatcher_destroyed);
691 696
692 // Both filters should get the events. 697 // Both filters should get the events.
693 EXPECT_EQ(1, f1->num_key_events()); 698 EXPECT_EQ(1, f1->num_key_events());
694 EXPECT_EQ(1, f1->num_mouse_events()); 699 EXPECT_EQ(1, f1->num_mouse_events());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 observer_a.reset(); 845 observer_a.reset();
841 observer_b.reset(); 846 observer_b.reset();
842 generator.MoveMouseTo(50, 50); 847 generator.MoveMouseTo(50, 50);
843 EXPECT_TRUE(observer_a.did_visibility_change()); 848 EXPECT_TRUE(observer_a.did_visibility_change());
844 EXPECT_FALSE(observer_b.did_visibility_change()); 849 EXPECT_FALSE(observer_b.did_visibility_change());
845 EXPECT_TRUE(observer_a.is_cursor_visible()); 850 EXPECT_TRUE(observer_a.is_cursor_visible());
846 } 851 }
847 #endif // defined(OS_CHROMEOS) 852 #endif // defined(OS_CHROMEOS)
848 853
849 } // namespace ash 854 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/toplevel_window_event_handler.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