| OLD | NEW |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 int GetNonClientComponent(const gfx::Point& point) const override { | 125 int GetNonClientComponent(const gfx::Point& point) const override { |
| 126 return hittest_code_; | 126 return hittest_code_; |
| 127 } | 127 } |
| 128 | 128 |
| 129 int hittest_code_; | 129 int hittest_code_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); | 131 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 TEST_F(WindowManagerTest, Focus) { | 134 TEST_F(WindowManagerTest, Focus) { |
| 135 // The IME event filter interferes with the basic key event propagation we |
| 136 // attempt to do here, so we disable it. |
| 137 // |
| 138 DisableIME(); |
| 135 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 139 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 136 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); | 140 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); |
| 137 | 141 |
| 138 // Supplied ids are negative so as not to collide with shell ids. | 142 // Supplied ids are negative so as not to collide with shell ids. |
| 139 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe | 143 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe |
| 140 // id beyond shell id max? | 144 // id beyond shell id max? |
| 141 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 145 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( |
| 142 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); | 146 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); |
| 143 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow( | 147 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow( |
| 144 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get())); | 148 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get())); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 640 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 637 ui::EF_LEFT_MOUSE_BUTTON); | 641 ui::EF_LEFT_MOUSE_BUTTON); |
| 638 details = dispatcher->OnEventFromSource(&mouseev2); | 642 details = dispatcher->OnEventFromSource(&mouseev2); |
| 639 ASSERT_FALSE(details.dispatcher_destroyed); | 643 ASSERT_FALSE(details.dispatcher_destroyed); |
| 640 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 644 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 641 EXPECT_EQ(w1.get(), | 645 EXPECT_EQ(w1.get(), |
| 642 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 646 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
| 643 } | 647 } |
| 644 | 648 |
| 645 TEST_F(WindowManagerTest, AdditionalFilters) { | 649 TEST_F(WindowManagerTest, AdditionalFilters) { |
| 650 // The IME event filter interferes with the basic key event propagation we |
| 651 // attempt to do here, so we disable it. |
| 652 DisableIME(); |
| 646 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 653 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 647 | 654 |
| 648 // Creates a window and make it active | 655 // Creates a window and make it active |
| 649 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 656 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( |
| 650 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); | 657 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); |
| 651 wm::ActivateWindow(w1.get()); | 658 wm::ActivateWindow(w1.get()); |
| 652 | 659 |
| 653 // Creates two addition filters | 660 // Creates two addition filters |
| 654 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler); | 661 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler); |
| 655 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler); | 662 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 generator.MoveMouseTo(50, 50); | 850 generator.MoveMouseTo(50, 50); |
| 844 EXPECT_TRUE(observer_a.did_visibility_change()); | 851 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 845 EXPECT_FALSE(observer_b.did_visibility_change()); | 852 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 846 EXPECT_TRUE(observer_a.is_cursor_visible()); | 853 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 847 | 854 |
| 848 cursor_manager->RemoveObserver(&observer_a); | 855 cursor_manager->RemoveObserver(&observer_a); |
| 849 } | 856 } |
| 850 #endif // defined(OS_CHROMEOS) | 857 #endif // defined(OS_CHROMEOS) |
| 851 | 858 |
| 852 } // namespace ash | 859 } // namespace ash |
| OLD | NEW |