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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/chromeos/customization/customization_document.h" | 14 #include "chrome/browser/chromeos/customization/customization_document.h" |
15 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
16 #include "chrome/browser/chromeos/login/login_manager_test.h" | 16 #include "chrome/browser/chromeos/login/login_manager_test.h" |
17 #include "chrome/browser/chromeos/login/login_wizard.h" | 17 #include "chrome/browser/chromeos/login/login_wizard.h" |
18 #include "chrome/browser/chromeos/login/screens/network_screen.h" | 18 #include "chrome/browser/chromeos/login/screens/network_screen.h" |
19 #include "chrome/browser/chromeos/login/test/js_checker.h" | 19 #include "chrome/browser/chromeos/login/test/js_checker.h" |
20 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
21 #include "chrome/browser/chromeos/login/wizard_controller.h" | 21 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 22 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chromeos/system/fake_statistics_provider.h" | 25 #include "chromeos/system/fake_statistics_provider.h" |
25 #include "chromeos/system/statistics_provider.h" | 26 #include "chromeos/system/statistics_provider.h" |
26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
29 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
30 #include "ui/base/ime/chromeos/extension_ime_util.h" | 31 #include "ui/base/ime/chromeos/extension_ime_util.h" |
31 #include "ui/base/ime/chromeos/input_method_manager.h" | 32 #include "ui/base/ime/chromeos/input_method_manager.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool VerifyOptionExists(const char* select_id, const char* value); | 148 bool VerifyOptionExists(const char* select_id, const char* value); |
148 | 149 |
149 // Dumps OOBE select control (language or keyboard) to string. | 150 // Dumps OOBE select control (language or keyboard) to string. |
150 std::string DumpOptions(const char* select_id); | 151 std::string DumpOptions(const char* select_id); |
151 | 152 |
152 protected: | 153 protected: |
153 // Runs the test for the given locale and keyboard layout. | 154 // Runs the test for the given locale and keyboard layout. |
154 void RunLocalizationTest(); | 155 void RunLocalizationTest(); |
155 | 156 |
156 void WaitUntilJSIsReady() { | 157 void WaitUntilJSIsReady() { |
157 LoginDisplayHostImpl* host = static_cast<LoginDisplayHostImpl*>( | 158 LoginDisplayHost* host = LoginDisplayHost::default_host(); |
158 LoginDisplayHostImpl::default_host()); | |
159 if (!host) | 159 if (!host) |
160 return; | 160 return; |
161 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | 161 OobeUI* oobe_ui = host->GetOobeUI(); |
162 if (!oobe_ui) | 162 if (!oobe_ui) |
163 return; | 163 return; |
164 base::RunLoop run_loop; | 164 base::RunLoop run_loop; |
165 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | 165 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); |
166 if (!oobe_ui_ready) | 166 if (!oobe_ui_ready) |
167 run_loop.Run(); | 167 run_loop.Run(); |
168 } | 168 } |
169 | 169 |
170 private: | 170 private: |
171 system::ScopedFakeStatisticsProvider fake_statistics_provider_; | 171 system::ScopedFakeStatisticsProvider fake_statistics_provider_; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 " return true;" | 318 " return true;" |
319 "}" | 319 "}" |
320 "var observer = new MutationObserver(SendReplyIfAcceptEnabled);" | 320 "var observer = new MutationObserver(SendReplyIfAcceptEnabled);" |
321 "if (!SendReplyIfAcceptEnabled()) {" | 321 "if (!SendReplyIfAcceptEnabled()) {" |
322 " var options = { attributes: true };" | 322 " var options = { attributes: true };" |
323 " observer.observe(screenElement, options);" | 323 " observer.observe(screenElement, options);" |
324 "}", | 324 "}", |
325 first_language.c_str()); | 325 first_language.c_str()); |
326 | 326 |
327 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 327 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
328 static_cast<chromeos::LoginDisplayHostImpl*>( | 328 LoginDisplayHost::default_host()->GetOobeUI()->web_ui()->GetWebContents(), |
329 chromeos::LoginDisplayHostImpl::default_host()) | 329 waiting_script, &done)); |
330 ->GetOobeUI() | |
331 ->web_ui() | |
332 ->GetWebContents(), | |
333 waiting_script, | |
334 &done)); | |
335 | 330 |
336 checker.set_web_contents(static_cast<chromeos::LoginDisplayHostImpl*>( | 331 checker.set_web_contents(LoginDisplayHost::default_host() |
337 chromeos::LoginDisplayHostImpl::default_host())-> | 332 ->GetOobeUI() |
338 GetOobeUI()->web_ui()->GetWebContents()); | 333 ->web_ui() |
| 334 ->GetWebContents()); |
339 | 335 |
340 if (!VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true)) { | 336 if (!VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true)) { |
341 LOG(ERROR) << "Actual value of " << kLocaleSelect << ":\n" | 337 LOG(ERROR) << "Actual value of " << kLocaleSelect << ":\n" |
342 << DumpOptions(kLocaleSelect); | 338 << DumpOptions(kLocaleSelect); |
343 } | 339 } |
344 if (!VerifyInitialOptions( | 340 if (!VerifyInitialOptions( |
345 kKeyboardSelect, | 341 kKeyboardSelect, |
346 TranslateXKB2Extension(expected_keyboard_layout).c_str(), | 342 TranslateXKB2Extension(expected_keyboard_layout).c_str(), |
347 false)) { | 343 false)) { |
348 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" | 344 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" |
349 << DumpOptions(kKeyboardSelect); | 345 << DumpOptions(kKeyboardSelect); |
350 } | 346 } |
351 | 347 |
352 // Make sure we have a fallback keyboard. | 348 // Make sure we have a fallback keyboard. |
353 if (!VerifyOptionExists(kKeyboardSelect, | 349 if (!VerifyOptionExists(kKeyboardSelect, |
354 extension_ime_util::GetInputMethodIDByEngineID( | 350 extension_ime_util::GetInputMethodIDByEngineID( |
355 kUSLayout).c_str())) { | 351 kUSLayout).c_str())) { |
356 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" | 352 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" |
357 << DumpOptions(kKeyboardSelect); | 353 << DumpOptions(kKeyboardSelect); |
358 } | 354 } |
359 | 355 |
360 // Note, that sort order is locale-specific, but is unlikely to change. | 356 // Note, that sort order is locale-specific, but is unlikely to change. |
361 // Especially for keyboard layouts. | 357 // Especially for keyboard layouts. |
362 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); | 358 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); |
363 | 359 |
364 // Shut down the display host. | 360 // Shut down the display host. |
365 chromeos::LoginDisplayHostImpl::default_host()->Finalize(); | 361 LoginDisplayHost::default_host()->Finalize(); |
366 base::MessageLoopForUI::current()->RunUntilIdle(); | 362 base::MessageLoopForUI::current()->RunUntilIdle(); |
367 | 363 |
368 // Clear the locale pref so the statistics provider is pinged next time. | 364 // Clear the locale pref so the statistics provider is pinged next time. |
369 g_browser_process->local_state()->SetString(prefs::kApplicationLocale, | 365 g_browser_process->local_state()->SetString(prefs::kApplicationLocale, |
370 std::string()); | 366 std::string()); |
371 } | 367 } |
372 | 368 |
373 IN_PROC_BROWSER_TEST_P(OobeLocalizationTest, LocalizationTest) { | 369 IN_PROC_BROWSER_TEST_P(OobeLocalizationTest, LocalizationTest) { |
374 RunLocalizationTest(); | 370 RunLocalizationTest(); |
375 } | 371 } |
376 | 372 |
377 INSTANTIATE_TEST_CASE_P( | 373 INSTANTIATE_TEST_CASE_P( |
378 StructSequence, | 374 StructSequence, |
379 OobeLocalizationTest, | 375 OobeLocalizationTest, |
380 testing::Range(&oobe_localization_test_parameters[0], | 376 testing::Range(&oobe_localization_test_parameters[0], |
381 &oobe_localization_test_parameters[arraysize( | 377 &oobe_localization_test_parameters[arraysize( |
382 oobe_localization_test_parameters)])); | 378 oobe_localization_test_parameters)])); |
383 } // namespace chromeos | 379 } // namespace chromeos |
OLD | NEW |