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

Side by Side Diff: ui/base/ime/input_method_ibus_unittest.cc

Issue 13812013: Fix ibus-m17n crash due to wrong parameter from Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 7 years, 8 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
« no previous file with comments | « ui/base/ime/input_method_ibus.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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 // Here (2, 4) is selection range in expected surrounding text coordinates.
1210 SetSurroundingTextVerifier verifier("fghij", 2, 4);
1211
1212 mock_ibus_input_context_client_->set_set_surrounding_text_handler(
1213 base::Bind(&SetSurroundingTextVerifier::Verify,
1187 base::Unretained(&verifier))); 1214 base::Unretained(&verifier)));
1188 ime_->OnCaretBoundsChanged(this); 1215 ime_->OnCaretBoundsChanged(this);
1189 1216
1190 // Check the call count. 1217 // Check the call count.
1191 EXPECT_EQ(1, 1218 EXPECT_EQ(1,
1192 mock_ibus_input_context_client_->set_surrounding_text_call_count()); 1219 mock_ibus_input_context_client_->set_surrounding_text_call_count());
1193 } 1220 }
1194 1221
1195 class InputMethodIBusKeyEventTest : public InputMethodIBusTest { 1222 class InputMethodIBusKeyEventTest : public InputMethodIBusTest {
1196 public: 1223 public:
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 1709
1683 // Do callback. 1710 // Do callback.
1684 success_consume_handler.RunCallback(KEYEVENT_CONSUME); 1711 success_consume_handler.RunCallback(KEYEVENT_CONSUME);
1685 1712
1686 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); 1713 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count());
1687 } 1714 }
1688 1715
1689 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). 1716 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593).
1690 1717
1691 } // namespace ui 1718 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_ibus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698