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( |
1151 selection_range_.start(), | 1151 UTF16ToUTF8(surrounding_text_), |
1152 selection_range_.end()); | 1152 selection_range_.start() - text_range_.start(), |
| 1153 selection_range_.end() - text_range_.end()); |
1153 | 1154 |
1154 mock_ibus_input_context_client_->set_set_surrounding_text_handler( | 1155 mock_ibus_input_context_client_->set_set_surrounding_text_handler( |
1155 base::Bind(&SetSurroundingTextVerifier::Verify, | 1156 base::Bind(&SetSurroundingTextVerifier::Verify, |
1156 base::Unretained(&verifier))); | 1157 base::Unretained(&verifier))); |
1157 ime_->OnCaretBoundsChanged(this); | 1158 ime_->OnCaretBoundsChanged(this); |
1158 | 1159 |
1159 // Check the call count. | 1160 // Check the call count. |
1160 EXPECT_EQ(1, | 1161 EXPECT_EQ(1, |
1161 mock_ibus_input_context_client_->set_surrounding_text_call_count()); | 1162 mock_ibus_input_context_client_->set_surrounding_text_call_count()); |
1162 } | 1163 } |
1163 | 1164 |
1164 TEST_F(InputMethodIBusTest, SurroundingText_SelectionTest) { | 1165 TEST_F(InputMethodIBusTest, SurroundingText_SelectionTest) { |
1165 SetCreateContextSuccessHandler(); | 1166 SetCreateContextSuccessHandler(); |
1166 ime_->Init(true); | 1167 ime_->Init(true); |
1167 // Click a text input form. | 1168 // Click a text input form. |
1168 input_type_ = TEXT_INPUT_TYPE_TEXT; | 1169 input_type_ = TEXT_INPUT_TYPE_TEXT; |
1169 ime_->OnTextInputTypeChanged(this); | 1170 ime_->OnTextInputTypeChanged(this); |
1170 // Start the daemon. | 1171 // Start the daemon. |
1171 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", | 1172 chromeos::DBusThreadManager::Get()->InitIBusBus("dummy address", |
1172 base::Bind(&base::DoNothing)); | 1173 base::Bind(&base::DoNothing)); |
1173 mock_ibus_daemon_controller_->EmulateConnect(); | 1174 mock_ibus_daemon_controller_->EmulateConnect(); |
1174 | 1175 |
1175 // Set the TextInputClient behaviors. | 1176 // Set the TextInputClient behaviors. |
1176 surrounding_text_ = UTF8ToUTF16("abcdef"); | 1177 surrounding_text_ = UTF8ToUTF16("abcdef"); |
1177 text_range_ = ui::Range(0, 6); | 1178 text_range_ = ui::Range(0, 6); |
1178 selection_range_ = ui::Range(2, 5); | 1179 selection_range_ = ui::Range(2, 5); |
1179 | 1180 |
1180 // Set the verifier for SetSurroundingText mock call. | 1181 // Set the verifier for SetSurroundingText mock call. |
1181 SetSurroundingTextVerifier verifier(UTF16ToUTF8(surrounding_text_), | 1182 SetSurroundingTextVerifier verifier( |
1182 selection_range_.start(), | 1183 UTF16ToUTF8(surrounding_text_), |
1183 selection_range_.end()); | 1184 selection_range_.start() - text_range_.start(), |
| 1185 selection_range_.end() - text_range_.end()); |
1184 | 1186 |
1185 mock_ibus_input_context_client_->set_set_surrounding_text_handler( | 1187 mock_ibus_input_context_client_->set_set_surrounding_text_handler( |
1186 base::Bind(&SetSurroundingTextVerifier::Verify, | 1188 base::Bind(&SetSurroundingTextVerifier::Verify, |
1187 base::Unretained(&verifier))); | 1189 base::Unretained(&verifier))); |
1188 ime_->OnCaretBoundsChanged(this); | 1190 ime_->OnCaretBoundsChanged(this); |
1189 | 1191 |
1190 // Check the call count. | 1192 // Check the call count. |
1191 EXPECT_EQ(1, | 1193 EXPECT_EQ(1, |
1192 mock_ibus_input_context_client_->set_surrounding_text_call_count()); | 1194 mock_ibus_input_context_client_->set_surrounding_text_call_count()); |
1193 } | 1195 } |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 | 1684 |
1683 // Do callback. | 1685 // Do callback. |
1684 success_consume_handler.RunCallback(KEYEVENT_CONSUME); | 1686 success_consume_handler.RunCallback(KEYEVENT_CONSUME); |
1685 | 1687 |
1686 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); | 1688 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); |
1687 } | 1689 } |
1688 | 1690 |
1689 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). | 1691 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). |
1690 | 1692 |
1691 } // namespace ui | 1693 } // namespace ui |
OLD | NEW |