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" |
11 #include "chrome/browser/chromeos/customization_document.h" | 11 #include "chrome/browser/chromeos/customization_document.h" |
| 12 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
12 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 13 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
13 #include "chrome/browser/chromeos/login/login_wizard.h" | 14 #include "chrome/browser/chromeos/login/login_wizard.h" |
14 #include "chrome/browser/chromeos/login/test/js_checker.h" | 15 #include "chrome/browser/chromeos/login/test/js_checker.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chromeos/ime/extension_ime_util.h" |
| 19 #include "chromeos/ime/input_method_manager.h" |
| 20 #include "chromeos/ime/input_method_whitelist.h" |
17 #include "chromeos/system/statistics_provider.h" | 21 #include "chromeos/system/statistics_provider.h" |
18 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
20 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
21 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
22 | 26 |
23 namespace base { | 27 namespace base { |
24 class TaskRunner; | 28 class TaskRunner; |
25 } | 29 } |
26 | 30 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 const std::string& expected_locale, | 218 const std::string& expected_locale, |
215 const std::string& expected_keyboard_layout, | 219 const std::string& expected_keyboard_layout, |
216 const std::string& expected_keyboard_select_control) { | 220 const std::string& expected_keyboard_select_control) { |
217 statistics_provider_->set_locale(initial_locale); | 221 statistics_provider_->set_locale(initial_locale); |
218 statistics_provider_->set_keyboard_layout(keyboard_layout); | 222 statistics_provider_->set_keyboard_layout(keyboard_layout); |
219 | 223 |
220 // Initialize StartupCustomizationDocument with fake statistics provider. | 224 // Initialize StartupCustomizationDocument with fake statistics provider. |
221 StartupCustomizationDocument::GetInstance()->Init( | 225 StartupCustomizationDocument::GetInstance()->Init( |
222 statistics_provider_.get()); | 226 statistics_provider_.get()); |
223 | 227 |
| 228 input_method::InputMethodManager::Get() |
| 229 ->GetInputMethodUtil() |
| 230 ->InitXkbInputMethodsForTesting(); |
| 231 |
| 232 std::string expected_keyboard_select = expected_keyboard_select_control; |
| 233 if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) { |
| 234 // Modifies the expected keyboard select control options for the new |
| 235 // extension based xkb id. |
| 236 size_t pos = 0; |
| 237 std::string repl_old = "xkb:"; |
| 238 std::string repl_new = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:"; |
| 239 while ((pos = expected_keyboard_select.find(repl_old, pos)) != |
| 240 std::string::npos) { |
| 241 expected_keyboard_select.replace(pos, repl_old.length(), repl_new); |
| 242 pos += repl_new.length(); |
| 243 } |
| 244 } |
| 245 |
224 // Bring up the OOBE network screen. | 246 // Bring up the OOBE network screen. |
225 chromeos::ShowLoginWizard(chromeos::WizardController::kNetworkScreenName); | 247 chromeos::ShowLoginWizard(chromeos::WizardController::kNetworkScreenName); |
226 content::WindowedNotificationObserver( | 248 content::WindowedNotificationObserver( |
227 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 249 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
228 content::NotificationService::AllSources()).Wait(); | 250 content::NotificationService::AllSources()).Wait(); |
229 | 251 |
230 checker.set_web_contents(static_cast<chromeos::LoginDisplayHostImpl*>( | 252 checker.set_web_contents(static_cast<chromeos::LoginDisplayHostImpl*>( |
231 chromeos::LoginDisplayHostImpl::default_host())-> | 253 chromeos::LoginDisplayHostImpl::default_host())-> |
232 GetOobeUI()->web_ui()->GetWebContents()); | 254 GetOobeUI()->web_ui()->GetWebContents()); |
233 | 255 |
234 VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true); | 256 VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true); |
235 VerifyInitialOptions(kKeyboardSelect, | 257 VerifyInitialOptions(kKeyboardSelect, |
236 expected_keyboard_layout.c_str(), | 258 extension_ime_util::GetInputMethodIDByKeyboardLayout( |
| 259 expected_keyboard_layout).c_str(), |
237 false); | 260 false); |
238 | 261 |
239 // Make sure we have a fallback keyboard. | 262 // Make sure we have a fallback keyboard. |
240 VerifyOptionExists(kKeyboardSelect, kUSLayout); | 263 VerifyOptionExists( |
| 264 kKeyboardSelect, |
| 265 extension_ime_util::GetInputMethodIDByKeyboardLayout(kUSLayout).c_str()); |
241 | 266 |
242 // Note, that sort order is locale-specific, but is unlikely to change. | 267 // Note, that sort order is locale-specific, but is unlikely to change. |
243 // Especially for keyboard layouts. | 268 // Especially for keyboard layouts. |
244 EXPECT_EQ(expected_keyboard_select_control, DumpOptions(kKeyboardSelect)); | 269 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); |
245 | 270 |
246 // Shut down the display host. | 271 // Shut down the display host. |
247 chromeos::LoginDisplayHostImpl::default_host()->Finalize(); | 272 chromeos::LoginDisplayHostImpl::default_host()->Finalize(); |
248 base::MessageLoopForUI::current()->RunUntilIdle(); | 273 base::MessageLoopForUI::current()->RunUntilIdle(); |
249 | 274 |
250 // Clear the locale pref so the statistics provider is pinged next time. | 275 // Clear the locale pref so the statistics provider is pinged next time. |
251 g_browser_process->local_state()->SetString(prefs::kApplicationLocale, | 276 g_browser_process->local_state()->SetString(prefs::kApplicationLocale, |
252 std::string()); | 277 std::string()); |
253 } | 278 } |
254 | 279 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 RunLocalizationTest("es,en-US,nl", "xkb:be::nld", | 325 RunLocalizationTest("es,en-US,nl", "xkb:be::nld", |
301 "es,en-US,nl", "xkb:be::nld", | 326 "es,en-US,nl", "xkb:be::nld", |
302 "xkb:be::nld,[xkb:es::spa,xkb:latam::spa,xkb:us::eng]"); | 327 "xkb:be::nld,[xkb:es::spa,xkb:latam::spa,xkb:us::eng]"); |
303 | 328 |
304 RunLocalizationTest("ru,de", "xkb:ru::rus", | 329 RunLocalizationTest("ru,de", "xkb:ru::rus", |
305 "ru,de", kUSLayout, | 330 "ru,de", kUSLayout, |
306 "xkb:us::eng"); | 331 "xkb:us::eng"); |
307 } | 332 } |
308 | 333 |
309 } // namespace chromeos | 334 } // namespace chromeos |
OLD | NEW |