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

Side by Side Diff: chrome/browser/chromeos/login/oobe_localization_browsertest.cc

Issue 1610823003: Migrate call sites LoginDisplayHostImpl::default_host to LoginDisplayHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-add-supervised-user
Patch Set: Created 4 years, 11 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
OLDNEW
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
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 chromeos::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 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 chromeos::LoginDisplayHost::default_host()
achuithb 2016/01/21 23:14:31 Drop chromeos:: here and below
jdufault 2016/01/22 21:14:11 Done.
329 chromeos::LoginDisplayHostImpl::default_host())
330 ->GetOobeUI() 329 ->GetOobeUI()
331 ->web_ui() 330 ->web_ui()
332 ->GetWebContents(), 331 ->GetWebContents(),
333 waiting_script, 332 waiting_script, &done));
334 &done));
335 333
336 checker.set_web_contents(static_cast<chromeos::LoginDisplayHostImpl*>( 334 checker.set_web_contents(chromeos::LoginDisplayHost::default_host()
337 chromeos::LoginDisplayHostImpl::default_host())-> 335 ->GetOobeUI()
338 GetOobeUI()->web_ui()->GetWebContents()); 336 ->web_ui()
337 ->GetWebContents());
339 338
340 if (!VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true)) { 339 if (!VerifyInitialOptions(kLocaleSelect, expected_locale.c_str(), true)) {
341 LOG(ERROR) << "Actual value of " << kLocaleSelect << ":\n" 340 LOG(ERROR) << "Actual value of " << kLocaleSelect << ":\n"
342 << DumpOptions(kLocaleSelect); 341 << DumpOptions(kLocaleSelect);
343 } 342 }
344 if (!VerifyInitialOptions( 343 if (!VerifyInitialOptions(
345 kKeyboardSelect, 344 kKeyboardSelect,
346 TranslateXKB2Extension(expected_keyboard_layout).c_str(), 345 TranslateXKB2Extension(expected_keyboard_layout).c_str(),
347 false)) { 346 false)) {
348 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" 347 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n"
349 << DumpOptions(kKeyboardSelect); 348 << DumpOptions(kKeyboardSelect);
350 } 349 }
351 350
352 // Make sure we have a fallback keyboard. 351 // Make sure we have a fallback keyboard.
353 if (!VerifyOptionExists(kKeyboardSelect, 352 if (!VerifyOptionExists(kKeyboardSelect,
354 extension_ime_util::GetInputMethodIDByEngineID( 353 extension_ime_util::GetInputMethodIDByEngineID(
355 kUSLayout).c_str())) { 354 kUSLayout).c_str())) {
356 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n" 355 LOG(ERROR) << "Actual value of " << kKeyboardSelect << ":\n"
357 << DumpOptions(kKeyboardSelect); 356 << DumpOptions(kKeyboardSelect);
358 } 357 }
359 358
360 // Note, that sort order is locale-specific, but is unlikely to change. 359 // Note, that sort order is locale-specific, but is unlikely to change.
361 // Especially for keyboard layouts. 360 // Especially for keyboard layouts.
362 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect)); 361 EXPECT_EQ(expected_keyboard_select, DumpOptions(kKeyboardSelect));
363 362
364 // Shut down the display host. 363 // Shut down the display host.
365 chromeos::LoginDisplayHostImpl::default_host()->Finalize(); 364 chromeos::LoginDisplayHost::default_host()->Finalize();
366 base::MessageLoopForUI::current()->RunUntilIdle(); 365 base::MessageLoopForUI::current()->RunUntilIdle();
367 366
368 // Clear the locale pref so the statistics provider is pinged next time. 367 // Clear the locale pref so the statistics provider is pinged next time.
369 g_browser_process->local_state()->SetString(prefs::kApplicationLocale, 368 g_browser_process->local_state()->SetString(prefs::kApplicationLocale,
370 std::string()); 369 std::string());
371 } 370 }
372 371
373 IN_PROC_BROWSER_TEST_P(OobeLocalizationTest, LocalizationTest) { 372 IN_PROC_BROWSER_TEST_P(OobeLocalizationTest, LocalizationTest) {
374 RunLocalizationTest(); 373 RunLocalizationTest();
375 } 374 }
376 375
377 INSTANTIATE_TEST_CASE_P( 376 INSTANTIATE_TEST_CASE_P(
378 StructSequence, 377 StructSequence,
379 OobeLocalizationTest, 378 OobeLocalizationTest,
380 testing::Range(&oobe_localization_test_parameters[0], 379 testing::Range(&oobe_localization_test_parameters[0],
381 &oobe_localization_test_parameters[arraysize( 380 &oobe_localization_test_parameters[arraysize(
382 oobe_localization_test_parameters)])); 381 oobe_localization_test_parameters)]));
383 } // namespace chromeos 382 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698