OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/json/json_writer.h" | |
6 #include "base/values.h" | |
5 #include "chrome/browser/chromeos/settings/cros_settings.h" | 7 #include "chrome/browser/chromeos/settings/cros_settings.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/common/chrome_switches.h" | |
7 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "chromeos/chromeos_switches.h" | |
8 #include "chromeos/settings/cros_settings_names.h" | 12 #include "chromeos/settings/cros_settings_names.h" |
9 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
10 | 14 |
11 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeOSInfoPrivateTest) { | 15 namespace { |
16 | |
17 const char kTestNameKey[] = "testName"; | |
18 const char kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi"; | |
19 | |
20 } // namespace | |
21 | |
22 // This class contains chrome.chromeosInfoPrivate API tests. | |
Devlin
2016/09/06 23:04:53
nit: I don't think this comment adds much that isn
Rahul Chaturvedi
2016/09/06 23:19:35
Done.
| |
23 class ChromeOSInfoPrivateTest : public ExtensionApiTest { | |
24 public: | |
25 ChromeOSInfoPrivateTest() {} | |
26 ~ChromeOSInfoPrivateTest() override {} | |
27 | |
28 protected: | |
29 std::string GenerateTestName(const std::string& test_name) { | |
30 base::DictionaryValue test_arg; | |
31 std::string result; | |
32 test_arg.SetString(kTestNameKey, test_name); | |
33 base::JSONWriter::Write(test_arg, &result); | |
34 return result; | |
35 } | |
36 | |
37 void EnableKioskSession() { | |
38 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
39 switches::kForceAppMode); | |
40 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, | |
41 kTestAppId); | |
42 } | |
43 | |
44 void MakeArcAvailable() { | |
45 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
46 chromeos::switches::kArcAvailable); | |
47 } | |
48 | |
49 void EnableArc() { | |
50 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
51 chromeos::switches::kEnableArc); | |
52 } | |
53 }; | |
54 | |
55 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Basic) { | |
12 // Set the initial timezone different from what JS function | 56 // Set the initial timezone different from what JS function |
13 // timezoneSetTest() will attempt to set. | 57 // timezoneSetTest() will attempt to set. |
14 base::StringValue initial_timezone("America/Los_Angeles"); | 58 base::StringValue initial_timezone("America/Los_Angeles"); |
15 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 59 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
16 initial_timezone); | 60 initial_timezone); |
17 | 61 |
18 // Check that accessibility settings are set to default values. | 62 // Check that accessibility settings are set to default values. |
19 PrefService* prefs = profile()->GetPrefs(); | 63 PrefService* prefs = profile()->GetPrefs(); |
20 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); | 64 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
21 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); | 65 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); |
22 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); | 66 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); |
23 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); | 67 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); |
24 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); | 68 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); |
25 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); | 69 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); |
26 | 70 |
27 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 71 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
28 prefs::kLanguageSendFunctionKeys)); | 72 prefs::kLanguageSendFunctionKeys)); |
29 | 73 |
30 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private")) << message_; | 74 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private/basic")) |
75 << message_; | |
31 | 76 |
32 // Check that all accessibility settings have been flipped by the test. | 77 // Check that all accessibility settings have been flipped by the test. |
33 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); | 78 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
34 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); | 79 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); |
35 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); | 80 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); |
36 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); | 81 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); |
37 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); | 82 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); |
38 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); | 83 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); |
39 | 84 |
40 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); | 85 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); |
41 } | 86 } |
87 | |
88 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { | |
89 EnableKioskSession(); | |
90 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
Devlin
2016/09/06 23:04:53
This file doesn't exist
Rahul Chaturvedi
2016/09/06 23:19:35
Done.
| |
91 GenerateTestName("kiosk").c_str())) | |
92 << message_; | |
93 } | |
94 | |
95 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { | |
96 MakeArcAvailable(); | |
97 ASSERT_TRUE( | |
98 RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
99 GenerateTestName("arc available").c_str())) | |
100 << message_; | |
101 } | |
102 | |
103 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) { | |
104 EnableArc(); | |
105 ASSERT_TRUE( | |
106 RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
107 GenerateTestName("arc enabled").c_str())) | |
108 << message_; | |
109 } | |
OLD | NEW |