Chromium Code Reviews| 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 kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi"; | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 class ChromeOSInfoPrivateTest : public ExtensionApiTest { | |
| 22 public: | |
| 23 ChromeOSInfoPrivateTest() {} | |
| 24 ~ChromeOSInfoPrivateTest() override {} | |
| 25 | |
| 26 protected: | |
| 27 std::string GenerateTestName(const std::string& test_name) { | |
| 28 std::string result; | |
| 29 base::JSONWriter::Write(base::StringValue(test_name), &result); | |
| 30 return result; | |
| 31 } | |
| 32 | |
| 33 void EnableKioskSession() { | |
| 34 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 35 switches::kForceAppMode); | |
| 36 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, | |
| 37 kTestAppId); | |
| 38 } | |
| 39 | |
| 40 void MakeArcAvailable() { | |
| 41 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 42 chromeos::switches::kArcAvailable); | |
| 43 } | |
| 44 | |
| 45 void EnableArc() { | |
| 46 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 47 chromeos::switches::kEnableArc); | |
| 48 } | |
| 49 }; | |
| 50 | |
| 51 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, TestGetAndSet) { | |
| 12 // Set the initial timezone different from what JS function | 52 // Set the initial timezone different from what JS function |
| 13 // timezoneSetTest() will attempt to set. | 53 // timezoneSetTest() will attempt to set. |
| 14 base::StringValue initial_timezone("America/Los_Angeles"); | 54 base::StringValue initial_timezone("America/Los_Angeles"); |
| 15 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 55 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
| 16 initial_timezone); | 56 initial_timezone); |
| 17 | 57 |
| 18 // Check that accessibility settings are set to default values. | 58 // Check that accessibility settings are set to default values. |
| 19 PrefService* prefs = profile()->GetPrefs(); | 59 PrefService* prefs = profile()->GetPrefs(); |
| 20 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); | 60 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
| 21 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); | 61 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); |
| 22 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); | 62 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); |
| 23 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); | 63 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); |
| 24 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); | 64 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); |
| 25 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); | 65 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); |
| 26 | 66 |
| 27 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 67 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 28 prefs::kLanguageSendFunctionKeys)); | 68 prefs::kLanguageSendFunctionKeys)); |
| 29 | 69 |
| 30 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private")) << message_; | 70 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private/basic")) |
| 71 << message_; | |
| 31 | 72 |
| 32 // Check that all accessibility settings have been flipped by the test. | 73 // Check that all accessibility settings have been flipped by the test. |
| 33 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); | 74 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
| 34 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); | 75 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); |
| 35 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); | 76 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); |
| 36 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); | 77 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); |
| 37 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); | 78 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); |
| 38 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); | 79 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); |
| 39 | 80 |
| 40 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); | 81 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); |
| 41 } | 82 } |
| 83 | |
| 84 // TODO(steel): Investigate merging the following tests. | |
| 85 | |
| 86 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { | |
| 87 EnableKioskSession(); | |
| 88 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
| 89 GenerateTestName("kiosk").c_str())) | |
|
Devlin
2016/09/07 23:08:43
Why not just "kiosk"?
Rahul Chaturvedi
2016/09/07 23:40:55
Done.
| |
| 90 << message_; | |
| 91 } | |
| 92 | |
| 93 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { | |
| 94 MakeArcAvailable(); | |
| 95 ASSERT_TRUE( | |
| 96 RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
| 97 GenerateTestName("arc available").c_str())) | |
| 98 << message_; | |
| 99 } | |
| 100 | |
| 101 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) { | |
| 102 EnableArc(); | |
| 103 ASSERT_TRUE( | |
| 104 RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
| 105 GenerateTestName("arc enabled").c_str())) | |
| 106 << message_; | |
| 107 } | |
| OLD | NEW |