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 <X11/Xlib.h> | 5 #include <X11/Xlib.h> |
6 #undef Bool | 6 #undef Bool |
7 #undef FocusIn | 7 #undef FocusIn |
8 #undef FocusOut | 8 #undef FocusOut |
9 #undef None | 9 #undef None |
10 | 10 |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1140 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", | 1140 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", |
1141 base::Bind(&base::DoNothing)); | 1141 base::Bind(&base::DoNothing)); |
1142 mock_ibus_daemon_controller_->EmulateConnect(); | 1142 mock_ibus_daemon_controller_->EmulateConnect(); |
1143 | 1143 |
1144 // Set the TextInputClient behaviors. | 1144 // Set the TextInputClient behaviors. |
1145 surrounding_text_ = UTF8ToUTF16("abcdef"); | 1145 surrounding_text_ = UTF8ToUTF16("abcdef"); |
1146 text_range_ = ui::Range(0, 6); | 1146 text_range_ = ui::Range(0, 6); |
1147 selection_range_ = ui::Range(3, 3); | 1147 selection_range_ = ui::Range(3, 3); |
1148 | 1148 |
1149 // Set the verifier for SetSurroundingText mock call. | 1149 // Set the verifier for SetSurroundingText mock call. |
1150 SetSurroundingTextVerifier verifier(UTF16ToUTF8(surrounding_text_), | 1150 SetSurroundingTextVerifier verifier(UTF16ToUTF8(surrounding_text_), 3, 3); |
1151 selection_range_.start(), | 1151 |
1152 selection_range_.end()); | |
1153 | 1152 |
1154 mock_ibus_input_context_client_->set_set_surrounding_text_handler( | 1153 mock_ibus_input_context_client_->set_set_surrounding_text_handler( |
1155 base::Bind(&SetSurroundingTextVerifier::Verify, | 1154 base::Bind(&SetSurroundingTextVerifier::Verify, |
1156 base::Unretained(&verifier))); | 1155 base::Unretained(&verifier))); |
1157 ime_->OnCaretBoundsChanged(this); | 1156 ime_->OnCaretBoundsChanged(this); |
1158 | 1157 |
1159 // Check the call count. | 1158 // Check the call count. |
1160 EXPECT_EQ(1, | 1159 EXPECT_EQ(1, |
1161 mock_ibus_input_context_client_->set_surrounding_text_call_count()); | 1160 mock_ibus_input_context_client_->set_surrounding_text_call_count()); |
1162 } | 1161 } |
1163 | 1162 |
1164 TEST_F(InputMethodIBusTest, SurroundingText_SelectionTest) { | 1163 TEST_F(InputMethodIBusTest, SurroundingText_SelectionTest) { |
1165 SetCreateContextSuccessHandler(); | 1164 SetCreateContextSuccessHandler(); |
1166 ime_->Init(true); | 1165 ime_->Init(true); |
1167 // Click a text input form. | 1166 // Click a text input form. |
1168 input_type_ = TEXT_INPUT_TYPE_TEXT; | 1167 input_type_ = TEXT_INPUT_TYPE_TEXT; |
1169 ime_->OnTextInputTypeChanged(this); | 1168 ime_->OnTextInputTypeChanged(this); |
1170 // Start the daemon. | 1169 // Start the daemon. |
1171 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", | 1170 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", |
1172 base::Bind(&base::DoNothing)); | 1171 base::Bind(&base::DoNothing)); |
1173 mock_ibus_daemon_controller_->EmulateConnect(); | 1172 mock_ibus_daemon_controller_->EmulateConnect(); |
1174 | 1173 |
1175 // Set the TextInputClient behaviors. | 1174 // Set the TextInputClient behaviors. |
1176 surrounding_text_ = UTF8ToUTF16("abcdef"); | 1175 surrounding_text_ = UTF8ToUTF16("abcdef"); |
1177 text_range_ = ui::Range(0, 6); | 1176 text_range_ = ui::Range(0, 6); |
1178 selection_range_ = ui::Range(2, 5); | 1177 selection_range_ = ui::Range(2, 5); |
1179 | 1178 |
1180 // Set the verifier for SetSurroundingText mock call. | 1179 // Set the verifier for SetSurroundingText mock call. |
1181 SetSurroundingTextVerifier verifier(UTF16ToUTF8(surrounding_text_), | 1180 SetSurroundingTextVerifier verifier(UTF16ToUTF8(surrounding_text_), 2, 5); |
1182 selection_range_.start(), | |
1183 selection_range_.end()); | |
1184 | 1181 |
1185 mock_ibus_input_context_client_->set_set_surrounding_text_handler( | 1182 mock_ibus_input_context_client_->set_set_surrounding_text_handler( |
1186 base::Bind(&SetSurroundingTextVerifier::Verify, | 1183 base::Bind(&SetSurroundingTextVerifier::Verify, |
1184 base::Unretained(&verifier))); | |
1185 ime_->OnCaretBoundsChanged(this); | |
1186 | |
1187 // Check the call count. | |
1188 EXPECT_EQ(1, | |
1189 mock_ibus_input_context_client_->set_surrounding_text_call_count()); | |
1190 } | |
1191 | |
1192 TEST_F(InputMethodIBusTest, SurroundingText_PartialText) { | |
1193 SetCreateContextSuccessHandler(); | |
1194 ime_->Init(true); | |
1195 // Click a text input form. | |
1196 input_type_ = TEXT_INPUT_TYPE_TEXT; | |
1197 ime_->OnTextInputTypeChanged(this); | |
1198 // Start the daemon. | |
1199 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", | |
1200 base::Bind(&base::DoNothing)); | |
1201 mock_ibus_daemon_controller_->EmulateConnect(); | |
1202 | |
1203 // Set the TextInputClient behaviors. | |
1204 surrounding_text_ = UTF8ToUTF16("abcdefghij"); | |
1205 text_range_ = ui::Range(5, 10); | |
1206 selection_range_ = ui::Range(7, 9); | |
1207 | |
1208 // Set the verifier for SetSurroundingText mock call. | |
1209 SetSurroundingTextVerifier verifier("fghij", 2, 4); | |
kinaba
2013/04/10 04:30:04
please add comment about how the (2, 4) came up.
Seigo Nonaka
2013/04/10 05:15:54
Done.
| |
1210 | |
1211 mock_ibus_input_context_client_->set_set_surrounding_text_handler( | |
1212 base::Bind(&SetSurroundingTextVerifier::Verify, | |
1187 base::Unretained(&verifier))); | 1213 base::Unretained(&verifier))); |
1188 ime_->OnCaretBoundsChanged(this); | 1214 ime_->OnCaretBoundsChanged(this); |
1189 | 1215 |
1190 // Check the call count. | 1216 // Check the call count. |
1191 EXPECT_EQ(1, | 1217 EXPECT_EQ(1, |
1192 mock_ibus_input_context_client_->set_surrounding_text_call_count()); | 1218 mock_ibus_input_context_client_->set_surrounding_text_call_count()); |
1193 } | 1219 } |
1194 | 1220 |
1195 class InputMethodIBusKeyEventTest : public InputMethodIBusTest { | 1221 class InputMethodIBusKeyEventTest : public InputMethodIBusTest { |
1196 public: | 1222 public: |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1682 | 1708 |
1683 // Do callback. | 1709 // Do callback. |
1684 success_consume_handler.RunCallback(KEYEVENT_CONSUME); | 1710 success_consume_handler.RunCallback(KEYEVENT_CONSUME); |
1685 | 1711 |
1686 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); | 1712 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); |
1687 } | 1713 } |
1688 | 1714 |
1689 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). | 1715 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). |
1690 | 1716 |
1691 } // namespace ui | 1717 } // namespace ui |
OLD | NEW |