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 |
26 void SetUpCommandLine(base::CommandLine* command_line) override { | |
27 ExtensionApiTest::SetUpCommandLine(command_line); | |
28 // Make ARC enabled for ArcAvailable/ArcEnabled tests. | |
29 arc::SetArcAvailableCommandLineForTesting(command_line); | |
30 } | |
31 | |
25 protected: | 32 protected: |
26 void EnableKioskSession() { | 33 void EnableKioskSession() { |
27 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 34 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
28 switches::kForceAppMode); | 35 switches::kForceAppMode); |
29 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, | 36 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, |
30 kTestAppId); | 37 kTestAppId); |
31 } | 38 } |
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 }; | 39 }; |
43 | 40 |
44 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, TestGetAndSet) { | 41 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, TestGetAndSet) { |
45 // Set the initial timezone different from what JS function | 42 // Set the initial timezone different from what JS function |
46 // timezoneSetTest() will attempt to set. | 43 // timezoneSetTest() will attempt to set. |
47 base::StringValue initial_timezone("America/Los_Angeles"); | 44 base::StringValue initial_timezone("America/Los_Angeles"); |
48 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 45 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
49 initial_timezone); | 46 initial_timezone); |
50 | 47 |
51 // Check that accessibility settings are set to default values. | 48 // Check that accessibility settings are set to default values. |
(...skipping 24 matching lines...) Expand all Loading... | |
76 | 73 |
77 // TODO(steel): Investigate merging the following tests. | 74 // TODO(steel): Investigate merging the following tests. |
78 | 75 |
79 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { | 76 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) { |
80 EnableKioskSession(); | 77 EnableKioskSession(); |
81 ASSERT_TRUE( | 78 ASSERT_TRUE( |
82 RunPlatformAppTestWithArg("chromeos_info_private/extended", "kiosk")) | 79 RunPlatformAppTestWithArg("chromeos_info_private/extended", "kiosk")) |
83 << message_; | 80 << message_; |
84 } | 81 } |
85 | 82 |
83 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) { | |
Rahul Chaturvedi
2017/01/26 06:31:22
I hate to nit-pick, but these tests will now alway
hidehiko
2017/01/26 06:51:07
Sure, done.
Instead of "not enabled", I named "not
| |
84 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | |
85 "arc enabled")) | |
86 << message_; | |
87 } | |
88 | |
86 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { | 89 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { |
87 MakeArcAvailable(); | 90 // Even if ARC is available, ARC may not be able to be enabled. (Please |
91 // see ArcSessionManager::IsAllowedForProfile() for details). | |
92 // In such cases, we expect "available". However, current testing framework | |
93 // does not seem to run with such cases, unfortunately. So, here directly | |
94 // control the function. | |
95 arc::ArcSessionManager::DisallowForTesting(); | |
88 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", | 96 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", |
89 "arc available")) | 97 "arc available")) |
90 << message_; | 98 << message_; |
91 } | 99 } |
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 |