OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/task_runner.h" | 8 #include "base/task_runner.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 " }\n" | 216 " }\n" |
217 " }\n" | 217 " }\n" |
218 " return result;\n" | 218 " return result;\n" |
219 "})()\n", | 219 "})()\n", |
220 select_id); | 220 select_id); |
221 return checker.GetString(expression); | 221 return checker.GetString(expression); |
222 } | 222 } |
223 | 223 |
224 std::string TranslateXKB2Extension(const std::string& src) { | 224 std::string TranslateXKB2Extension(const std::string& src) { |
225 std::string result(src); | 225 std::string result(src); |
226 if (!extension_ime_util::UseWrappedExtensionKeyboardLayouts()) | |
227 return result; | |
228 // Modifies the expected keyboard select control options for the new | 226 // Modifies the expected keyboard select control options for the new |
229 // extension based xkb id. | 227 // extension based xkb id. |
230 size_t pos = 0; | 228 size_t pos = 0; |
231 std::string repl_old = "xkb:"; | 229 std::string repl_old = "xkb:"; |
232 std::string repl_new = | 230 std::string repl_new = |
233 extension_ime_util::GetInputMethodIDByKeyboardLayout("xkb:"); | 231 extension_ime_util::GetInputMethodIDByEngineID("xkb:"); |
234 while ((pos = result.find(repl_old, pos)) != std::string::npos) { | 232 while ((pos = result.find(repl_old, pos)) != std::string::npos) { |
235 result.replace(pos, repl_old.length(), repl_new); | 233 result.replace(pos, repl_old.length(), repl_new); |
236 pos += repl_new.length(); | 234 pos += repl_new.length(); |
237 } | 235 } |
238 return result; | 236 return result; |
239 } | 237 } |
240 | 238 |
241 void OobeLocalizationTest::RunLocalizationTest( | 239 void OobeLocalizationTest::RunLocalizationTest( |
242 const std::string& initial_locale, | 240 const std::string& initial_locale, |
243 const std::string& keyboard_layout, | 241 const std::string& keyboard_layout, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if (!VerifyInitialOptions( | 276 if (!VerifyInitialOptions( |
279 kKeyboardSelect, | 277 kKeyboardSelect, |
280 TranslateXKB2Extension(expected_keyboard_layout).c_str(), | 278 TranslateXKB2Extension(expected_keyboard_layout).c_str(), |
281 false)) { | 279 false)) { |
282 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" | 280 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" |
283 << DumpOptions(kKeyboardSelect); | 281 << DumpOptions(kKeyboardSelect); |
284 } | 282 } |
285 | 283 |
286 // Make sure we have a fallback keyboard. | 284 // Make sure we have a fallback keyboard. |
287 if (!VerifyOptionExists(kKeyboardSelect, | 285 if (!VerifyOptionExists(kKeyboardSelect, |
288 extension_ime_util::GetInputMethodIDByKeyboardLayout( | 286 extension_ime_util::GetInputMethodIDByEngineID( |
289 kUSLayout).c_str())) { | 287 kUSLayout).c_str())) { |
290 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" | 288 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" |
291 << DumpOptions(kKeyboardSelect); | 289 << DumpOptions(kKeyboardSelect); |
292 } | 290 } |
293 | 291 |
294 // Note, that sort order is locale-specific, but is unlikely to change. | 292 // Note, that sort order is locale-specific, but is unlikely to change. |
295 // Especially for keyboard layouts. | 293 // Especially for keyboard layouts. |
296 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); | 294 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); |
297 | 295 |
298 // Shut down the display host. | 296 // Shut down the display host. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 "]"); | 368 "]"); |
371 // Another syntetic example. Check that british keyboard is available. | 369 // Another syntetic example. Check that british keyboard is available. |
372 RunLocalizationTest("en-AU", | 370 RunLocalizationTest("en-AU", |
373 "xkb:us::eng", | 371 "xkb:us::eng", |
374 "en-AU", | 372 "en-AU", |
375 "xkb:us::eng", | 373 "xkb:us::eng", |
376 "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]"); | 374 "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]"); |
377 } | 375 } |
378 | 376 |
379 } // namespace chromeos | 377 } // namespace chromeos |
OLD | NEW |