OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h" | 7 #include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 base::AutoReset<bool> auto_reset_disable_bubble( | 75 base::AutoReset<bool> auto_reset_disable_bubble( |
76 &InputImeActivateFunction::disable_bubble_for_testing_, true); | 76 &InputImeActivateFunction::disable_bubble_for_testing_, true); |
77 SetTrackKeyEvents(input_method, true); | 77 SetTrackKeyEvents(input_method, true); |
78 | 78 |
79 // Listens for the input.ime.onBlur event. | 79 // Listens for the input.ime.onBlur event. |
80 ExtensionTestMessageListener blur_listener("get_blur_event", false); | 80 ExtensionTestMessageListener blur_listener("get_blur_event", false); |
81 | 81 |
82 ASSERT_TRUE(RunExtensionTest("input_ime_nonchromeos")) << message_; | 82 ASSERT_TRUE(RunExtensionTest("input_ime_nonchromeos")) << message_; |
83 | 83 |
84 // Test the input.ime.commitText API. | 84 // Test the input.ime.commitText API. |
85 ASSERT_EQ(1, client->insert_text_count()); | 85 const std::vector<base::string16>& insert_text_history = |
86 EXPECT_EQ(base::UTF8ToUTF16("test_commit_text"), client->last_insert_text()); | 86 client->insert_text_history(); |
| 87 ASSERT_EQ(1UL, insert_text_history.size()); |
| 88 EXPECT_EQ(base::UTF8ToUTF16("test_commit_text"), insert_text_history[0]); |
87 | 89 |
88 // Test the input.ime.setComposition API. | 90 // Test the input.ime.setComposition API. |
89 ui::CompositionText composition; | 91 ui::CompositionText composition; |
90 composition.text = base::UTF8ToUTF16("test_set_composition"); | 92 composition.text = base::UTF8ToUTF16("test_set_composition"); |
91 composition.underlines.push_back( | 93 composition.underlines.push_back( |
92 ui::CompositionUnderline(0, composition.text.length(), SK_ColorBLACK, | 94 ui::CompositionUnderline(0, composition.text.length(), SK_ColorBLACK, |
93 false /* thick */, SK_ColorTRANSPARENT)); | 95 false /* thick */, SK_ColorTRANSPARENT)); |
94 composition.selection = gfx::Range(2, 2); | 96 composition.selection = gfx::Range(2, 2); |
95 ASSERT_EQ(1, client->set_composition_count()); | 97 const std::vector<ui::CompositionText>& composition_history = |
96 ASSERT_EQ(composition, client->last_composition()); | 98 client->composition_history(); |
| 99 ASSERT_EQ(2UL, composition_history.size()); |
| 100 EXPECT_EQ(base::UTF8ToUTF16("test_set_composition"), |
| 101 composition_history[0].text); |
| 102 EXPECT_EQ(base::UTF8ToUTF16(""), composition_history[1].text); |
97 | 103 |
98 // Tests input.ime.onBlur API should get event when focusing to another | 104 // Tests input.ime.onBlur API should get event when focusing to another |
99 // text input client. | 105 // text input client. |
100 std::unique_ptr<ui::DummyTextInputClient> client2( | 106 std::unique_ptr<ui::DummyTextInputClient> client2( |
101 new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT)); | 107 new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT)); |
102 input_method->SetFocusedTextInputClient(client2.get()); | 108 input_method->SetFocusedTextInputClient(client2.get()); |
103 ASSERT_TRUE(blur_listener.WaitUntilSatisfied()) << message_; | 109 ASSERT_TRUE(blur_listener.WaitUntilSatisfied()) << message_; |
104 | 110 |
105 input_method->DetachTextInputClient(client2.get()); | 111 input_method->DetachTextInputClient(client2.get()); |
106 } | 112 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 key_events.push_back(std::unique_ptr<ui::KeyEvent>( | 165 key_events.push_back(std::unique_ptr<ui::KeyEvent>( |
160 new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); | 166 new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); |
161 key_events.push_back(std::unique_ptr<ui::KeyEvent>( | 167 key_events.push_back(std::unique_ptr<ui::KeyEvent>( |
162 new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE))); | 168 new ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE))); |
163 | 169 |
164 EXPECT_TRUE(CompareKeyEvents(key_events, input_method)); | 170 EXPECT_TRUE(CompareKeyEvents(key_events, input_method)); |
165 input_method->DetachTextInputClient(client.get()); | 171 input_method->DetachTextInputClient(client.get()); |
166 } | 172 } |
167 | 173 |
168 } // namespace extensions | 174 } // namespace extensions |
OLD | NEW |