1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/chromeos/startup_settings_cache.h"
6 
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "components/language/core/browser/pref_names.h"
12 #include "components/prefs/pref_service.h"
13 #include "content/public/browser/browser_accessibility_state.h"
14 #include "content/public/test/browser_test.h"
15 #include "content/public/test/browser_test_utils.h"
16 
17 namespace {
18 
19 const char kSpanishLocale[] = "es";
20 
21 using StartupSettingsCacheTest = InProcessBrowserTest;
22 
IN_PROC_BROWSER_TEST_F(StartupSettingsCacheTest,PRE_RendererLocale)23 IN_PROC_BROWSER_TEST_F(StartupSettingsCacheTest, PRE_RendererLocale) {
24   // Simulate the user changing the browser's language setting. The setting
25   // takes effect after restart.
26   browser()->profile()->GetPrefs()->SetString(
27       language::prefs::kApplicationLocale, kSpanishLocale);
28 }
29 
30 // Regression test for the "Choose File" button not being localized.
31 // https://crbug.com/510455
IN_PROC_BROWSER_TEST_F(StartupSettingsCacheTest,RendererLocale)32 IN_PROC_BROWSER_TEST_F(StartupSettingsCacheTest, RendererLocale) {
33   EXPECT_EQ(kSpanishLocale, browser()->profile()->GetPrefs()->GetString(
34                                 language::prefs::kApplicationLocale));
35 
36   content::BrowserAccessibilityState::GetInstance()->EnableAccessibility();
37 
38   // Load a page with a "Choose File" form button.
39   const char kHTML[] =
40       "<html><body><form><input type='file'></form></body></html>";
41   GURL url(std::string("data:text/html,") + kHTML);
42   ui_test_utils::NavigateToURL(browser(), url);
43 
44   // The localized button label in the renderer is in Spanish.
45   WaitForAccessibilityTreeToContainNodeWithName(
46       browser()->tab_strip_model()->GetActiveWebContents(),
47       "Seleccionar archivo");
48 }
49 
50 }  // namespace
51