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

Unified Diff: chrome/browser/chromeos/login/oobe_localization_browsertest.cc

Issue 653723004: Revert of ChromeOS NetworkScreenHandler should not call CheckAndResolveLocale on UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/oobe_localization_browsertest.cc
diff --git a/chrome/browser/chromeos/login/oobe_localization_browsertest.cc b/chrome/browser/chromeos/login/oobe_localization_browsertest.cc
index 7d844cb5dffd94cfa57a23e74441f0ed5bf0f383..cb68d69bd4eca9c6fb0a09e4ba9a9cf8e9f1a2c4 100644
--- a/chrome/browser/chromeos/login/oobe_localization_browsertest.cc
+++ b/chrome/browser/chromeos/login/oobe_localization_browsertest.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
-#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/login_wizard.h"
#include "chrome/browser/chromeos/login/test/js_checker.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
@@ -90,76 +89,7 @@
} // namespace system
-struct LocalizationTestParams {
- const char* initial_locale;
- const char* keyboard_layout;
- const char* expected_locale;
- const char* expected_keyboard_layout;
- const char* expected_keyboard_select_control;
-} const oobe_localization_test_parameters[] = {
- // ------------------ Non-Latin setup
- // For a non-Latin keyboard layout like Russian, we expect to see the US
- // keyboard.
- {"ru", "xkb:ru::rus", "ru", kUSLayout, "xkb:us::eng"},
- {"ru", "xkb:us::eng,xkb:ru::rus", "ru", kUSLayout, "xkb:us::eng"},
-
- // IMEs do not load at OOBE, so we just expect to see the (Latin) Japanese
- // keyboard.
- {"ja", "xkb:jp::jpn", "ja", "xkb:jp::jpn", "xkb:jp::jpn,[xkb:us::eng]"},
-
- // We don't use the Icelandic locale but the Icelandic keyboard layout
- // should still be selected when specified as the default.
- {"en-US",
- "xkb:is::ice",
- "en-US",
- "xkb:is::ice",
- "xkb:is::ice,[xkb:us::eng,xkb:us:intl:eng,xkb:us:altgr-intl:eng,"
- "xkb:us:dvorak:eng,xkb:us:colemak:eng]"},
- // ------------------ Full Latin setup
- // French Swiss keyboard.
- {"fr",
- "xkb:ch:fr:fra",
- "fr",
- "xkb:ch:fr:fra",
- "xkb:ch:fr:fra,[xkb:fr::fra,xkb:be::fra,xkb:ca::fra,"
- "xkb:ca:multix:fra,xkb:us::eng]"},
-
- // German Swiss keyboard.
- {"de",
- "xkb:ch::ger",
- "de",
- "xkb:ch::ger",
- "xkb:ch::ger,[xkb:de::ger,xkb:de:neo:ger,xkb:be::ger,xkb:us::eng]"},
-
- // NetworkScreenMultipleLocales
- {"es,en-US,nl",
- "xkb:be::nld",
- "es,en-US,nl",
- "xkb:be::nld",
- "xkb:be::nld,[xkb:es::spa,xkb:latam::spa,xkb:us::eng]"},
-
- {"ru,de", "xkb:ru::rus", "ru,de", kUSLayout, "xkb:us::eng"},
-
- // ------------------ Regional Locales
- // Syntetic example to test correct merging of different locales.
- {"fr-CH,it-CH,de-CH",
- "xkb:fr::fra,xkb:it::ita,xkb:de::ger",
- "fr-CH,it-CH,de-CH",
- "xkb:fr::fra",
- "xkb:fr::fra,xkb:it::ita,xkb:de::ger,[xkb:be::fra,xkb:ca::fra,"
- "xkb:ch:fr:fra,xkb:ca:multix:fra,xkb:us::eng]"},
-
- // Another syntetic example. Check that british keyboard is available.
- {"en-AU",
- "xkb:us::eng",
- "en-AU",
- "xkb:us::eng",
- "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]"},
-};
-
-class OobeLocalizationTest
- : public LoginManagerTest,
- public testing::WithParamInterface<const LocalizationTestParams*> {
+class OobeLocalizationTest : public InProcessBrowserTest {
public:
OobeLocalizationTest();
virtual ~OobeLocalizationTest();
@@ -179,21 +109,11 @@
protected:
// Runs the test for the given locale and keyboard layout.
- void RunLocalizationTest();
-
- void WaitUntilJSIsReady() {
- LoginDisplayHostImpl* host = static_cast<LoginDisplayHostImpl*>(
- LoginDisplayHostImpl::default_host());
- if (!host)
- return;
- chromeos::OobeUI* oobe_ui = host->GetOobeUI();
- if (!oobe_ui)
- return;
- base::RunLoop run_loop;
- const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure());
- if (!oobe_ui_ready)
- run_loop.Run();
- }
+ void RunLocalizationTest(const std::string& initial_locale,
+ const std::string& keyboard_layout,
+ const std::string& expected_locale,
+ const std::string& expected_keyboard_layout,
+ const std::string& expected_keyboard_select_control);
private:
scoped_ptr<system::FakeStatisticsProvider> statistics_provider_;
@@ -202,13 +122,10 @@
DISALLOW_COPY_AND_ASSIGN(OobeLocalizationTest);
};
-OobeLocalizationTest::OobeLocalizationTest() : LoginManagerTest(false) {
+OobeLocalizationTest::OobeLocalizationTest() {
statistics_provider_.reset(new system::FakeStatisticsProvider());
// Set the instance returned by GetInstance() for testing.
system::StatisticsProvider::SetTestProvider(statistics_provider_.get());
-
- statistics_provider_->set_locale(GetParam()->initial_locale);
- statistics_provider_->set_keyboard_layout(GetParam()->keyboard_layout);
}
OobeLocalizationTest::~OobeLocalizationTest() {
@@ -319,47 +236,34 @@
return result;
}
-void OobeLocalizationTest::RunLocalizationTest() {
- const std::string initial_locale(GetParam()->initial_locale);
- const std::string keyboard_layout(GetParam()->keyboard_layout);
- const std::string expected_locale(GetParam()->expected_locale);
- const std::string expected_keyboard_layout(
- GetParam()->expected_keyboard_layout);
- const std::string expected_keyboard_select_control(
- GetParam()->expected_keyboard_select_control);
+void OobeLocalizationTest::RunLocalizationTest(
+ const std::string& initial_locale,
+ const std::string& keyboard_layout,
+ const std::string& expected_locale,
+ const std::string& expected_keyboard_layout,
+ const std::string& expected_keyboard_select_control) {
+ statistics_provider_->set_locale(initial_locale);
+ statistics_provider_->set_keyboard_layout(keyboard_layout);
+
+ // Initialize StartupCustomizationDocument with fake statistics provider.
+ StartupCustomizationDocument::GetInstance()->Init(
+ statistics_provider_.get());
+
+ g_browser_process->local_state()->SetString(
+ prefs::kHardwareKeyboardLayout, keyboard_layout);
+
+ input_method::InputMethodManager::Get()
+ ->GetInputMethodUtil()
+ ->InitXkbInputMethodsForTesting();
const std::string expected_keyboard_select =
TranslateXKB2Extension(expected_keyboard_select_control);
- WaitUntilJSIsReady();
-
- const std::string first_language =
- expected_locale.substr(0, expected_locale.find(','));
- bool done = false;
- const std::string waiting_script = base::StringPrintf(
- "var screenElement = document.getElementById('language-select');"
- "function SendReplyIfAcceptEnabled() {"
- " if ($('language-select').value != '%s')"
- " return false;"
- " domAutomationController.send(true);"
- " observer.disconnect();"
- " return true;"
- "}"
- "var observer = new MutationObserver(SendReplyIfAcceptEnabled);"
- "if (!SendReplyIfAcceptEnabled()) {"
- " var options = { attributes: true };"
- " observer.observe(screenElement, options);"
- "}",
- first_language.c_str());
-
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- static_cast<chromeos::LoginDisplayHostImpl*>(
- chromeos::LoginDisplayHostImpl::default_host())
- ->GetOobeUI()
- ->web_ui()
- ->GetWebContents(),
- waiting_script,
- &done));
+ // Bring up the OOBE network screen.
+ chromeos::ShowLoginWizard(chromeos::WizardController::kNetworkScreenName);
+ content::WindowedNotificationObserver(
+ chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
+ content::NotificationService::AllSources()).Wait();
checker.set_web_contents(static_cast<chromeos::LoginDisplayHostImpl*>(
chromeos::LoginDisplayHostImpl::default_host())->
@@ -398,14 +302,76 @@
std::string());
}
-IN_PROC_BROWSER_TEST_P(OobeLocalizationTest, LocalizationTest) {
- RunLocalizationTest();
-}
-
-INSTANTIATE_TEST_CASE_P(
- StructSequence,
- OobeLocalizationTest,
- testing::Range(&oobe_localization_test_parameters[0],
- &oobe_localization_test_parameters[arraysize(
- oobe_localization_test_parameters)]));
+IN_PROC_BROWSER_TEST_F(OobeLocalizationTest, NetworkScreenNonLatin) {
+ // For a non-Latin keyboard layout like Russian, we expect to see the US
+ // keyboard.
+ RunLocalizationTest("ru", "xkb:ru::rus",
+ "ru", kUSLayout,
+ "xkb:us::eng");
+
+ RunLocalizationTest("ru", "xkb:us::eng,xkb:ru::rus",
+ "ru", kUSLayout,
+ "xkb:us::eng");
+
+ // IMEs do not load at OOBE, so we just expect to see the (Latin) Japanese
+ // keyboard.
+ RunLocalizationTest("ja", "xkb:jp::jpn",
+ "ja", "xkb:jp::jpn",
+ "xkb:jp::jpn,[xkb:us::eng]");
+}
+
+IN_PROC_BROWSER_TEST_F(OobeLocalizationTest, NetworkScreenKeyboardLayout) {
+ // We don't use the Icelandic locale but the Icelandic keyboard layout
+ // should still be selected when specified as the default.
+ RunLocalizationTest("en-US", "xkb:is::ice",
+ "en-US", "xkb:is::ice",
+ "xkb:is::ice,["
+ "xkb:us::eng,xkb:us:intl:eng,xkb:us:altgr-intl:eng,"
+ "xkb:us:dvorak:eng,xkb:us:colemak:eng]");
+}
+
+IN_PROC_BROWSER_TEST_F(OobeLocalizationTest, NetworkScreenFullLatin) {
+ // French Swiss keyboard.
+ RunLocalizationTest("fr", "xkb:ch:fr:fra",
+ "fr", "xkb:ch:fr:fra",
+ "xkb:ch:fr:fra,["
+ "xkb:fr::fra,xkb:be::fra,xkb:ca::fra,"
+ "xkb:ca:multix:fra,xkb:us::eng]");
+
+ // German Swiss keyboard.
+ RunLocalizationTest("de", "xkb:ch::ger",
+ "de", "xkb:ch::ger",
+ "xkb:ch::ger,["
+ "xkb:de::ger,xkb:de:neo:ger,xkb:be::ger,xkb:us::eng"
+ "]");
+}
+
+IN_PROC_BROWSER_TEST_F(OobeLocalizationTest, NetworkScreenMultipleLocales) {
+ RunLocalizationTest("es,en-US,nl", "xkb:be::nld",
+ "es,en-US,nl", "xkb:be::nld",
+ "xkb:be::nld,[xkb:es::spa,xkb:latam::spa,xkb:us::eng]");
+
+ RunLocalizationTest("ru,de", "xkb:ru::rus",
+ "ru,de", kUSLayout,
+ "xkb:us::eng");
+}
+
+IN_PROC_BROWSER_TEST_F(OobeLocalizationTest, NetworkScreenRegionalLocales) {
+ // Syntetic example to test correct merging of different locales.
+ RunLocalizationTest("fr-CH,it-CH,de-CH",
+ "xkb:fr::fra,xkb:it::ita,xkb:de::ger",
+ "fr-CH,it-CH,de-CH",
+ "xkb:fr::fra",
+ "xkb:fr::fra,xkb:it::ita,xkb:de::ger,["
+ "xkb:be::fra,xkb:ca::fra,xkb:ch:fr:fra,"
+ "xkb:ca:multix:fra,xkb:us::eng"
+ "]");
+ // Another syntetic example. Check that british keyboard is available.
+ RunLocalizationTest("en-AU",
+ "xkb:us::eng",
+ "en-AU",
+ "xkb:us::eng",
+ "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]");
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.cc ('k') | chrome/browser/chromeos/login/session/user_session_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698