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/values.h" | 5 #include "base/values.h" |
| 6 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
6 #include "chrome/browser/chromeos/settings/cros_settings.h" | 7 #include "chrome/browser/chromeos/settings/cros_settings.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
10 #include "chromeos/chromeos_switches.h" | |
11 #include "chromeos/settings/cros_settings_names.h" | 11 #include "chromeos/settings/cros_settings_names.h" |
| 12 #include "components/arc/arc_util.h" |
12 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const char kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi"; | 17 const char kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi"; |
17 | 18 |
18 } // namespace | 19 } // namespace |
19 | 20 |
20 class ChromeOSInfoPrivateTest : public ExtensionApiTest { | 21 class ChromeOSInfoPrivateTest : public ExtensionApiTest { |
21 public: | 22 public: |
22 ChromeOSInfoPrivateTest() {} | 23 ChromeOSInfoPrivateTest() {} |
23 ~ChromeOSInfoPrivateTest() override {} | 24 ~ChromeOSInfoPrivateTest() override {} |
24 | 25 |
25 protected: | 26 protected: |
26 void EnableKioskSession() { | 27 void EnableKioskSession() { |
27 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 28 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
28 switches::kForceAppMode); | 29 switches::kForceAppMode); |
29 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, | 30 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, |
30 kTestAppId); | 31 kTestAppId); |
31 } | 32 } |
32 | |
33 void MakeArcAvailable() { | |
34 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
35 chromeos::switches::kArcAvailable); | |
36 } | |
37 | |
38 void EnableArc() { | |
39 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
40 chromeos::switches::kEnableArc); | |
41 } | |
42 }; | 33 }; |
43 | 34 |
44 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, TestGetAndSet) { | 35 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, TestGetAndSet) { |
45 // Set the initial timezone different from what JS function | 36 // Set the initial timezone different from what JS function |
46 // timezoneSetTest() will attempt to set. | 37 // timezoneSetTest() will attempt to set. |
47 base::StringValue initial_timezone("America/Los_Angeles"); | 38 base::StringValue initial_timezone("America/Los_Angeles"); |
48 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 39 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
49 initial_timezone); | 40 initial_timezone); |
50 | 41 |
51 // Check that accessibility settings are set to default values. | 42 // Check that accessibility settings are set to default values. |
(...skipping 24 matching lines...) Expand all Loading... |
76 | 67 |
77 // TODO(steel): Investigate merging the following tests. | 68 // TODO(steel): Investigate merging the following tests. |
78 | 69 |
79 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { | 70 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { |
80 EnableKioskSession(); | 71 EnableKioskSession(); |
81 ASSERT_TRUE( | 72 ASSERT_TRUE( |
82 RunPlatformAppTestWithArg("chromeos_info_private/extended", "kiosk")) | 73 RunPlatformAppTestWithArg("chromeos_info_private/extended", "kiosk")) |
83 << message_; | 74 << message_; |
84 } | 75 } |
85 | 76 |
86 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { | 77 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcNotAvailable) { |
87 MakeArcAvailable(); | 78 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", |
| 79 "arc not-available")) |
| 80 << message_; |
| 81 } |
| 82 |
| 83 class ChromeOSArcInfoPrivateTest : public ChromeOSInfoPrivateTest { |
| 84 public: |
| 85 ChromeOSArcInfoPrivateTest() = default; |
| 86 ~ChromeOSArcInfoPrivateTest() override = default; |
| 87 |
| 88 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 89 ExtensionApiTest::SetUpCommandLine(command_line); |
| 90 // Make ARC enabled for ArcAvailable/ArcEnabled tests. |
| 91 arc::SetArcAvailableCommandLineForTesting(command_line); |
| 92 } |
| 93 |
| 94 private: |
| 95 DISALLOW_COPY_AND_ASSIGN(ChromeOSArcInfoPrivateTest); |
| 96 }; |
| 97 |
| 98 IN_PROC_BROWSER_TEST_F(ChromeOSArcInfoPrivateTest, ArcEnabled) { |
| 99 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", |
| 100 "arc enabled")) |
| 101 << message_; |
| 102 } |
| 103 |
| 104 IN_PROC_BROWSER_TEST_F(ChromeOSArcInfoPrivateTest, ArcAvailable) { |
| 105 // Even if ARC is available, ARC may not be able to be enabled. (Please |
| 106 // see ArcSessionManager::IsAllowedForProfile() for details). |
| 107 // In such cases, we expect "available". However, current testing framework |
| 108 // does not seem to run with such cases, unfortunately. So, here directly |
| 109 // control the function. |
| 110 arc::ArcSessionManager::DisallowForTesting(); |
88 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | 111 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", |
89 "arc available")) | 112 "arc available")) |
90 << message_; | 113 << message_; |
91 } | 114 } |
92 | |
93 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) { | |
94 EnableArc(); | |
95 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
96 "arc enabled")) | |
97 << message_; | |
98 } | |
OLD | NEW |