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

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

Issue 598023006: Add browser test for initial languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. 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 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 "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/input_method/input_method_util.h"
13 #include "chrome/browser/chromeos/login/login_wizard.h" 13 #include "chrome/browser/chromeos/login/login_wizard.h"
14 #include "chrome/browser/chromeos/login/test/js_checker.h" 14 #include "chrome/browser/chromeos/login/test/js_checker.h"
15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #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" 18 #include "chromeos/ime/extension_ime_util.h"
19 #include "chromeos/ime/input_method_manager.h" 19 #include "chromeos/ime/input_method_manager.h"
20 #include "chromeos/ime/input_method_whitelist.h" 20 #include "chromeos/ime/input_method_whitelist.h"
21 #include "chromeos/system/fake_statistics_provider.h"
21 #include "chromeos/system/statistics_provider.h" 22 #include "chromeos/system/statistics_provider.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
25 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
26 27
27 namespace base { 28 namespace base {
28 class TaskRunner; 29 class TaskRunner;
29 } 30 }
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 namespace { 34 namespace {
34 35
35 // OOBE constants. 36 // OOBE constants.
36 const char* kLocaleSelect = "language-select"; 37 const char* kLocaleSelect = "language-select";
37 const char* kKeyboardSelect = "keyboard-select"; 38 const char* kKeyboardSelect = "keyboard-select";
38 39
39 const char* kUSLayout = "xkb:us::eng"; 40 const char* kUSLayout = "xkb:us::eng";
40 41
41 } 42 }
42 43
43 namespace system {
44
45 // Custom StatisticsProvider that will return each set of region settings.
46 class FakeStatisticsProvider : public StatisticsProvider {
47 public:
48 virtual ~FakeStatisticsProvider() {}
49
50 void set_locale(const std::string& locale) {
51 initial_locale_ = locale;
52 }
53
54 void set_keyboard_layout(const std::string& keyboard_layout) {
55 keyboard_layout_ = keyboard_layout;
56 }
57
58 private:
59 // StatisticsProvider overrides.
60 virtual void StartLoadingMachineStatistics(
61 const scoped_refptr<base::TaskRunner>& file_task_runner,
62 bool load_oem_manifest) OVERRIDE {
63 }
64
65 // Populates the named machine statistic for initial_locale and
66 // keyboard_layout only.
67 virtual bool GetMachineStatistic(const std::string& name,
68 std::string* result) OVERRIDE {
69 if (name == "initial_locale")
70 *result = initial_locale_;
71 else if (name == "keyboard_layout")
72 *result = keyboard_layout_;
73 else
74 return false;
75
76 return true;
77 }
78
79 virtual bool GetMachineFlag(const std::string& name, bool* result) OVERRIDE {
80 return false;
81 }
82
83 virtual void Shutdown() OVERRIDE {
84 }
85
86 std::string initial_locale_;
87 std::string keyboard_layout_;
88 };
89
90 } // namespace system
91
92 class OobeLocalizationTest : public InProcessBrowserTest { 44 class OobeLocalizationTest : public InProcessBrowserTest {
93 public: 45 public:
94 OobeLocalizationTest(); 46 OobeLocalizationTest();
95 virtual ~OobeLocalizationTest(); 47 virtual ~OobeLocalizationTest();
96 48
97 // Verifies that the comma-separated |values| corresponds with the first 49 // Verifies that the comma-separated |values| corresponds with the first
98 // values in |select_id|, optionally checking for an options group label after 50 // values in |select_id|, optionally checking for an options group label after
99 // the first set of options. 51 // the first set of options.
100 bool VerifyInitialOptions(const char* select_id, 52 bool VerifyInitialOptions(const char* select_id,
101 const char* values, 53 const char* values,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 "]"); 320 "]");
369 // Another syntetic example. Check that british keyboard is available. 321 // Another syntetic example. Check that british keyboard is available.
370 RunLocalizationTest("en-AU", 322 RunLocalizationTest("en-AU",
371 "xkb:us::eng", 323 "xkb:us::eng",
372 "en-AU", 324 "en-AU",
373 "xkb:us::eng", 325 "xkb:us::eng",
374 "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]"); 326 "xkb:us::eng,[xkb:gb:extd:eng,xkb:gb:dvorak:eng]");
375 } 327 }
376 328
377 } // namespace chromeos 329 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698