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 "ui/wm/core/input_method_event_filter.h" | 5 #include "ui/wm/core/input_method_event_filter.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
10 #include "ui/aura/test/test_windows.h" | 10 #include "ui/aura/test/test_windows.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define TestInputMethodKeyEventPropagation \ | 26 #define TestInputMethodKeyEventPropagation \ |
27 DISABLED_TestInputMethodKeyEventPropagation | 27 DISABLED_TestInputMethodKeyEventPropagation |
28 #endif | 28 #endif |
29 | 29 |
30 namespace wm { | 30 namespace wm { |
31 | 31 |
32 class TestTextInputClient : public ui::DummyTextInputClient { | 32 class TestTextInputClient : public ui::DummyTextInputClient { |
33 public: | 33 public: |
34 explicit TestTextInputClient(aura::Window* window) : window_(window) {} | 34 explicit TestTextInputClient(aura::Window* window) : window_(window) {} |
35 | 35 |
36 virtual aura::Window* GetAttachedWindow() const OVERRIDE { return window_; } | 36 virtual aura::Window* GetAttachedWindow() const override { return window_; } |
37 | 37 |
38 private: | 38 private: |
39 aura::Window* window_; | 39 aura::Window* window_; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(TestTextInputClient); | 41 DISALLOW_COPY_AND_ASSIGN(TestTextInputClient); |
42 }; | 42 }; |
43 | 43 |
44 class InputMethodEventFilterTest : public aura::test::AuraTestBase { | 44 class InputMethodEventFilterTest : public aura::test::AuraTestBase { |
45 public: | 45 public: |
46 InputMethodEventFilterTest() {} | 46 InputMethodEventFilterTest() {} |
47 virtual ~InputMethodEventFilterTest() {} | 47 virtual ~InputMethodEventFilterTest() {} |
48 | 48 |
49 // testing::Test overrides: | 49 // testing::Test overrides: |
50 virtual void SetUp() OVERRIDE { | 50 virtual void SetUp() override { |
51 aura::test::AuraTestBase::SetUp(); | 51 aura::test::AuraTestBase::SetUp(); |
52 | 52 |
53 root_window()->AddPreTargetHandler(&root_filter_); | 53 root_window()->AddPreTargetHandler(&root_filter_); |
54 input_method_event_filter_.reset( | 54 input_method_event_filter_.reset( |
55 new InputMethodEventFilter(host()->GetAcceleratedWidget())); | 55 new InputMethodEventFilter(host()->GetAcceleratedWidget())); |
56 input_method_event_filter_->SetInputMethodPropertyInRootWindow( | 56 input_method_event_filter_->SetInputMethodPropertyInRootWindow( |
57 root_window()); | 57 root_window()); |
58 root_filter_.AddHandler(input_method_event_filter_.get()); | 58 root_filter_.AddHandler(input_method_event_filter_.get()); |
59 root_filter_.AddHandler(&test_filter_); | 59 root_filter_.AddHandler(&test_filter_); |
60 | 60 |
61 test_window_.reset(aura::test::CreateTestWindowWithDelegate( | 61 test_window_.reset(aura::test::CreateTestWindowWithDelegate( |
62 &test_window_delegate_, -1, gfx::Rect(), root_window())); | 62 &test_window_delegate_, -1, gfx::Rect(), root_window())); |
63 test_input_client_.reset(new TestTextInputClient(test_window_.get())); | 63 test_input_client_.reset(new TestTextInputClient(test_window_.get())); |
64 | 64 |
65 input_method_event_filter_->input_method()->SetFocusedTextInputClient( | 65 input_method_event_filter_->input_method()->SetFocusedTextInputClient( |
66 test_input_client_.get()); | 66 test_input_client_.get()); |
67 } | 67 } |
68 | 68 |
69 virtual void TearDown() OVERRIDE { | 69 virtual void TearDown() override { |
70 test_window_.reset(); | 70 test_window_.reset(); |
71 root_filter_.RemoveHandler(&test_filter_); | 71 root_filter_.RemoveHandler(&test_filter_); |
72 root_filter_.RemoveHandler(input_method_event_filter_.get()); | 72 root_filter_.RemoveHandler(input_method_event_filter_.get()); |
73 root_window()->RemovePreTargetHandler(&root_filter_); | 73 root_window()->RemovePreTargetHandler(&root_filter_); |
74 | 74 |
75 input_method_event_filter_.reset(); | 75 input_method_event_filter_.reset(); |
76 test_input_client_.reset(); | 76 test_input_client_.reset(); |
77 aura::test::AuraTestBase::TearDown(); | 77 aura::test::AuraTestBase::TearDown(); |
78 } | 78 } |
79 | 79 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 input_method_event_filter_->input_method()->SetFocusedTextInputClient( | 133 input_method_event_filter_->input_method()->SetFocusedTextInputClient( |
134 test_input_client_.get()); | 134 test_input_client_.get()); |
135 } | 135 } |
136 input_method_event_filter_->input_method()->DispatchKeyEvent(evt); | 136 input_method_event_filter_->input_method()->DispatchKeyEvent(evt); |
137 // Verifies 1 key event happened because InputMethodEventFilter:: | 137 // Verifies 1 key event happened because InputMethodEventFilter:: |
138 // DispatchKeyEventPostIME() returns true. | 138 // DispatchKeyEventPostIME() returns true. |
139 EXPECT_EQ(1, test_filter_.num_key_events()); | 139 EXPECT_EQ(1, test_filter_.num_key_events()); |
140 } | 140 } |
141 | 141 |
142 } // namespace wm | 142 } // namespace wm |
OLD | NEW |