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

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: pls be green! 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" 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"
11 #include "ui/aura/client/cursor_client_observer.h" 11 #include "ui/aura/client/cursor_client_observer.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/test/aura_test_base.h" 14 #include "ui/aura/test/aura_test_base.h"
15 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/test/test_windows.h" 16 #include "ui/aura/test/test_windows.h"
17 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
18 #include "ui/base/hit_test.h" 18 #include "ui/base/hit_test.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/events/event_processor.h" 20 #include "ui/events/event_processor.h"
21 #include "ui/events/event_utils.h" 21 #include "ui/events/event_utils.h"
22 #include "ui/events/test/event_generator.h" 22 #include "ui/events/test/event_generator.h"
23 #include "ui/events/test/test_event_handler.h" 23 #include "ui/events/test/test_event_handler.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/wm/core/compound_event_filter.h" 25 #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" 26 #include "ui/wm/public/activation_client.h"
28 #include "ui/wm/public/activation_delegate.h" 27 #include "ui/wm/public/activation_delegate.h"
29 28
30 namespace { 29 namespace {
31 30
32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { 31 class TestingCursorClientObserver : public aura::client::CursorClientObserver {
33 public: 32 public:
34 TestingCursorClientObserver() 33 TestingCursorClientObserver()
35 : cursor_visibility_(false), 34 : cursor_visibility_(false),
36 did_visibility_change_(false) {} 35 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 { 126 int GetNonClientComponent(const gfx::Point& point) const override {
128 return hittest_code_; 127 return hittest_code_;
129 } 128 }
130 129
131 int hittest_code_; 130 int hittest_code_;
132 131
133 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate); 132 DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate);
134 }; 133 };
135 134
136 TEST_F(WindowManagerTest, Focus) { 135 TEST_F(WindowManagerTest, Focus) {
137 // The IME event filter interferes with the basic key event propagation we 136 // The IME event filter interferes with the basic key event propagation we
James Cook 2015/06/01 22:21:00 Remove this comment.
Shu Chen 2015/06/02 04:11:16 Done.
138 // attempt to do here, so we remove it. 137 // attempt to do here, so we remove it.
139 test::ShellTestApi shell_test(Shell::GetInstance()); 138 test::ShellTestApi shell_test(Shell::GetInstance());
James Cook 2015/06/01 22:21:00 Do you still need this variable?
Shu Chen 2015/06/02 04:11:16 Done.
140 Shell::GetInstance()->RemovePreTargetHandler(
141 shell_test.input_method_event_filter());
142 139
143 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 140 aura::Window* root_window = Shell::GetPrimaryRootWindow();
144 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); 141 root_window->SetBounds(gfx::Rect(0, 0, 510, 510));
145 142
146 // Supplied ids are negative so as not to collide with shell ids. 143 // 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 144 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe
148 // id beyond shell id max? 145 // id beyond shell id max?
149 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( 146 scoped_ptr<aura::Window> w1(CreateTestWindowInShell(
150 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); 147 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500)));
151 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow( 148 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow(
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 details = dispatcher->OnEventFromSource(&mouseev2); 643 details = dispatcher->OnEventFromSource(&mouseev2);
647 ASSERT_FALSE(details.dispatcher_destroyed); 644 ASSERT_FALSE(details.dispatcher_destroyed);
648 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 645 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
649 EXPECT_EQ(w1.get(), 646 EXPECT_EQ(w1.get(),
650 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); 647 aura::client::GetFocusClient(w1.get())->GetFocusedWindow());
651 } 648 }
652 649
653 TEST_F(WindowManagerTest, AdditionalFilters) { 650 TEST_F(WindowManagerTest, AdditionalFilters) {
654 // The IME event filter interferes with the basic key event propagation we 651 // The IME event filter interferes with the basic key event propagation we
655 // attempt to do here, so we remove it. 652 // attempt to do here, so we remove it.
656 test::ShellTestApi shell_test(Shell::GetInstance()); 653 test::ShellTestApi shell_test(Shell::GetInstance());
James Cook 2015/06/01 22:21:00 same comments
Shu Chen 2015/06/02 04:11:16 Done.
657 Shell::GetInstance()->RemovePreTargetHandler(
658 shell_test.input_method_event_filter());
659 654
660 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 655 aura::Window* root_window = Shell::GetPrimaryRootWindow();
661 656
662 // Creates a window and make it active 657 // Creates a window and make it active
663 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( 658 scoped_ptr<aura::Window> w1(CreateTestWindowInShell(
664 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); 659 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100)));
665 wm::ActivateWindow(w1.get()); 660 wm::ActivateWindow(w1.get());
666 661
667 // Creates two addition filters 662 // Creates two addition filters
668 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler); 663 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 generator.MoveMouseTo(50, 50); 852 generator.MoveMouseTo(50, 50);
858 EXPECT_TRUE(observer_a.did_visibility_change()); 853 EXPECT_TRUE(observer_a.did_visibility_change());
859 EXPECT_FALSE(observer_b.did_visibility_change()); 854 EXPECT_FALSE(observer_b.did_visibility_change());
860 EXPECT_TRUE(observer_a.is_cursor_visible()); 855 EXPECT_TRUE(observer_a.is_cursor_visible());
861 856
862 cursor_manager->RemoveObserver(&observer_a); 857 cursor_manager->RemoveObserver(&observer_a);
863 } 858 }
864 #endif // defined(OS_CHROMEOS) 859 #endif // defined(OS_CHROMEOS)
865 860
866 } // namespace ash 861 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698