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

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

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed. Created 5 years, 6 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/shell_test_api.h"
9 #include "ash/test/test_activation_delegate.h" 8 #include "ash/test/test_activation_delegate.h"
10 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
11 #include "ui/aura/client/cursor_client_observer.h" 10 #include "ui/aura/client/cursor_client_observer.h"
12 #include "ui/aura/client/focus_client.h" 11 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
14 #include "ui/aura/test/aura_test_base.h" 13 #include "ui/aura/test/aura_test_base.h"
15 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/test/test_windows.h" 15 #include "ui/aura/test/test_windows.h"
17 #include "ui/base/cursor/cursor.h" 16 #include "ui/base/cursor/cursor.h"
18 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
19 #include "ui/events/event.h" 18 #include "ui/events/event.h"
20 #include "ui/events/event_processor.h" 19 #include "ui/events/event_processor.h"
21 #include "ui/events/event_utils.h" 20 #include "ui/events/event_utils.h"
22 #include "ui/events/test/event_generator.h" 21 #include "ui/events/test/event_generator.h"
23 #include "ui/events/test/test_event_handler.h" 22 #include "ui/events/test/test_event_handler.h"
24 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
25 #include "ui/wm/core/compound_event_filter.h" 24 #include "ui/wm/core/compound_event_filter.h"
26 #include "ui/wm/core/input_method_event_filter.h"
27 #include "ui/wm/public/activation_client.h" 25 #include "ui/wm/public/activation_client.h"
28 #include "ui/wm/public/activation_delegate.h" 26 #include "ui/wm/public/activation_delegate.h"
29 27
30 namespace { 28 namespace {
31 29
32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { 30 class TestingCursorClientObserver : public aura::client::CursorClientObserver {
33 public: 31 public:
34 TestingCursorClientObserver() 32 TestingCursorClientObserver()
35 : cursor_visibility_(false), 33 : cursor_visibility_(false),
36 did_visibility_change_(false) {} 34 did_visibility_change_(false) {}
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 int GetNonClientComponent(const gfx::Point& point) const override { 125 int GetNonClientComponent(const gfx::Point& point) const override {
128 return hittest_code_; 126 return hittest_code_;
129 } 127 }
130 128
131 int hittest_code_; 129 int hittest_code_;
132 130
133 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); 131 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate);
134 }; 132 };
135 133
136 TEST_F(WindowManagerTest, Focus) { 134 TEST_F(WindowManagerTest, Focus) {
137 // The IME event filter interferes with the basic key event propagation we
138 // attempt to do here, so we remove it.
139 test::ShellTestApi shell_test(Shell::GetInstance());
140 Shell::GetInstance()->RemovePreTargetHandler(
141 shell_test.input_method_event_filter());
142
143 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 135 aura::Window* root_window = Shell::GetPrimaryRootWindow();
144 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); 136 root_window->SetBounds(gfx::Rect(0, 0, 510, 510));
145 137
146 // Supplied ids are negative so as not to collide with shell ids. 138 // Supplied ids are negative so as not to collide with shell ids.
147 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe 139 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe
148 // id beyond shell id max? 140 // id beyond shell id max?
149 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( 141 scoped_ptr<aura::Window> w1(CreateTestWindowInShell(
150 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); 142 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500)));
151 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow( 143 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow(
152 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get())); 144 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get()));
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 636 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
645 ui::EF_LEFT_MOUSE_BUTTON); 637 ui::EF_LEFT_MOUSE_BUTTON);
646 details = dispatcher->OnEventFromSource(&mouseev2); 638 details = dispatcher->OnEventFromSource(&mouseev2);
647 ASSERT_FALSE(details.dispatcher_destroyed); 639 ASSERT_FALSE(details.dispatcher_destroyed);
648 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 640 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
649 EXPECT_EQ(w1.get(), 641 EXPECT_EQ(w1.get(),
650 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 642 aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
651 } 643 }
652 644
653 TEST_F(WindowManagerTest, AdditionalFilters) { 645 TEST_F(WindowManagerTest, AdditionalFilters) {
654 // The IME event filter interferes with the basic key event propagation we
655 // attempt to do here, so we remove it.
656 test::ShellTestApi shell_test(Shell::GetInstance());
657 Shell::GetInstance()->RemovePreTargetHandler(
658 shell_test.input_method_event_filter());
659
660 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 646 aura::Window* root_window = Shell::GetPrimaryRootWindow();
661 647
662 // Creates a window and make it active 648 // Creates a window and make it active
663 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( 649 scoped_ptr<aura::Window> w1(CreateTestWindowInShell(
664 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); 650 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100)));
665 wm::ActivateWindow(w1.get()); 651 wm::ActivateWindow(w1.get());
666 652
667 // Creates two addition filters 653 // Creates two addition filters
668 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler); 654 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler);
669 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler); 655 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 generator.MoveMouseTo(50, 50); 843 generator.MoveMouseTo(50, 50);
858 EXPECT_TRUE(observer_a.did_visibility_change()); 844 EXPECT_TRUE(observer_a.did_visibility_change());
859 EXPECT_FALSE(observer_b.did_visibility_change()); 845 EXPECT_FALSE(observer_b.did_visibility_change());
860 EXPECT_TRUE(observer_a.is_cursor_visible()); 846 EXPECT_TRUE(observer_a.is_cursor_visible());
861 847
862 cursor_manager->RemoveObserver(&observer_a); 848 cursor_manager->RemoveObserver(&observer_a);
863 } 849 }
864 #endif // defined(OS_CHROMEOS) 850 #endif // defined(OS_CHROMEOS)
865 851
866 } // namespace ash 852 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698