| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 #include "ash/common/accelerators/accelerator_table.h" | 196 #include "ash/common/accelerators/accelerator_table.h" |
| 197 #include "ash/common/accessibility_types.h" | 197 #include "ash/common/accessibility_types.h" |
| 198 #include "ash/common/wm_shell.h" | 198 #include "ash/common/wm_shell.h" |
| 199 #include "ash/shell.h" | 199 #include "ash/shell.h" |
| 200 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 200 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 201 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 201 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 202 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 202 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 203 #include "chrome/browser/chromeos/login/test/js_checker.h" | 203 #include "chrome/browser/chromeos/login/test/js_checker.h" |
| 204 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" | 204 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
| 205 #include "chrome/browser/profiles/profile_manager.h" | 205 #include "chrome/browser/profiles/profile_manager.h" |
| 206 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 207 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" |
| 206 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 208 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 207 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 209 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 208 #include "chromeos/audio/cras_audio_handler.h" | 210 #include "chromeos/audio/cras_audio_handler.h" |
| 209 #include "chromeos/chromeos_switches.h" | 211 #include "chromeos/chromeos_switches.h" |
| 210 #include "chromeos/cryptohome/cryptohome_parameters.h" | 212 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 211 #include "chromeos/dbus/dbus_thread_manager.h" | 213 #include "chromeos/dbus/dbus_thread_manager.h" |
| 212 #include "chromeos/dbus/fake_session_manager_client.h" | 214 #include "chromeos/dbus/fake_session_manager_client.h" |
| 213 #include "chromeos/dbus/session_manager_client.h" | 215 #include "chromeos/dbus/session_manager_client.h" |
| 214 #include "components/arc/arc_bridge_service.h" | 216 #include "components/arc/arc_bridge_service.h" |
| 215 #include "components/arc/arc_bridge_service_impl.h" | 217 #include "components/arc/arc_bridge_service_impl.h" |
| (...skipping 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4137 base::WrapUnique(new arc::FakeArcBridgeBootstrap( | 4139 base::WrapUnique(new arc::FakeArcBridgeBootstrap( |
| 4138 fake_arc_bridge_instance_.get()))))); | 4140 fake_arc_bridge_instance_.get()))))); |
| 4139 } | 4141 } |
| 4140 | 4142 |
| 4141 void SetUpCommandLine(base::CommandLine* command_line) override { | 4143 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4142 // ArcAuthService functionality is available only when Arc is enabled. Use | 4144 // ArcAuthService functionality is available only when Arc is enabled. Use |
| 4143 // kEnableArc switch that activates it. | 4145 // kEnableArc switch that activates it. |
| 4144 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 4146 command_line->AppendSwitch(chromeos::switches::kEnableArc); |
| 4145 } | 4147 } |
| 4146 | 4148 |
| 4149 void SetArcEnabledByPolicy(bool enabled) { |
| 4150 PolicyMap policies; |
| 4151 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 4152 POLICY_SOURCE_CLOUD, |
| 4153 base::WrapUnique(new base::FundamentalValue(enabled)), |
| 4154 nullptr); |
| 4155 UpdateProviderPolicy(policies); |
| 4156 if (browser()) { |
| 4157 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 4158 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); |
| 4159 } |
| 4160 } |
| 4161 |
| 4147 private: | 4162 private: |
| 4148 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | 4163 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| 4149 std::unique_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_; | 4164 std::unique_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_; |
| 4150 | 4165 |
| 4151 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); | 4166 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4152 }; | 4167 }; |
| 4153 | 4168 |
| 4169 class ArcPolicyDefaultAppTest : public ArcPolicyTest { |
| 4170 public: |
| 4171 ArcPolicyDefaultAppTest() {} |
| 4172 ~ArcPolicyDefaultAppTest() override {} |
| 4173 |
| 4174 protected: |
| 4175 void SetUpInProcessBrowserTestFixture() override { |
| 4176 ArcDefaultAppList::UseTestAppsDirectory(); |
| 4177 ArcPolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4178 } |
| 4179 |
| 4180 private: |
| 4181 DISALLOW_COPY_AND_ASSIGN(ArcPolicyDefaultAppTest); |
| 4182 }; |
| 4183 |
| 4154 // Test ArcEnabled policy. | 4184 // Test ArcEnabled policy. |
| 4155 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { | 4185 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4156 SetUpTest(); | 4186 SetUpTest(); |
| 4157 | 4187 |
| 4158 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4188 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4159 const arc::ArcBridgeService* const arc_bridge_service | 4189 const arc::ArcBridgeService* const arc_bridge_service = |
| 4160 = arc::ArcBridgeService::Get(); | 4190 arc::ArcBridgeService::Get(); |
| 4161 | 4191 |
| 4162 // ARC is switched off by default. | 4192 // ARC is switched off by default. |
| 4163 EXPECT_TRUE(arc_bridge_service->stopped()); | 4193 EXPECT_TRUE(arc_bridge_service->stopped()); |
| 4164 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 4194 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4165 | 4195 |
| 4166 // Enable ARC. | 4196 // Enable ARC. |
| 4167 PolicyMap policies; | 4197 SetArcEnabledByPolicy(true); |
| 4168 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 4169 POLICY_SOURCE_CLOUD, | |
| 4170 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | |
| 4171 UpdateProviderPolicy(policies); | |
| 4172 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 4173 EXPECT_TRUE(arc_bridge_service->ready()); | 4198 EXPECT_TRUE(arc_bridge_service->ready()); |
| 4174 | 4199 |
| 4175 // Disable ARC. | 4200 // Disable ARC. |
| 4176 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 4201 SetArcEnabledByPolicy(false); |
| 4177 POLICY_SOURCE_CLOUD, | |
| 4178 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | |
| 4179 UpdateProviderPolicy(policies); | |
| 4180 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 4181 EXPECT_TRUE(arc_bridge_service->stopped()); | 4202 EXPECT_TRUE(arc_bridge_service->stopped()); |
| 4182 | 4203 |
| 4183 TearDownTest(); | 4204 TearDownTest(); |
| 4184 } | 4205 } |
| 4185 | 4206 |
| 4207 // Test Arc default apps do not appear when Arc is disabled by policy. |
| 4208 IN_PROC_BROWSER_TEST_F(ArcPolicyDefaultAppTest, DefaultApps) { |
| 4209 // Started disabled. |
| 4210 SetArcEnabledByPolicy(false); |
| 4211 |
| 4212 SetUpTest(); |
| 4213 |
| 4214 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser()->profile()); |
| 4215 ASSERT_NE(nullptr, prefs); |
| 4216 |
| 4217 base::RunLoop run_loop; |
| 4218 prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 4219 run_loop.Run(); |
| 4220 |
| 4221 EXPECT_TRUE(prefs->GetAppIds().empty()); |
| 4222 |
| 4223 // Enable Arc |
| 4224 SetArcEnabledByPolicy(true); |
| 4225 EXPECT_FALSE(prefs->GetAppIds().empty()); |
| 4226 |
| 4227 // Disable Arc again. |
| 4228 SetArcEnabledByPolicy(false); |
| 4229 EXPECT_TRUE(prefs->GetAppIds().empty()); |
| 4230 |
| 4231 TearDownTest(); |
| 4232 } |
| 4233 |
| 4186 // Test ArcBackupRestoreEnabled policy. | 4234 // Test ArcBackupRestoreEnabled policy. |
| 4187 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { | 4235 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { |
| 4188 SetUpTest(); | 4236 SetUpTest(); |
| 4189 | 4237 |
| 4190 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4238 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4191 | 4239 |
| 4192 // ARC Backup & Restore is switched on by default. | 4240 // ARC Backup & Restore is switched on by default. |
| 4193 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4241 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4194 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4242 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4195 | 4243 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4386 | 4434 |
| 4387 SetEmptyPolicy(); | 4435 SetEmptyPolicy(); |
| 4388 // Policy not set. | 4436 // Policy not set. |
| 4389 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4437 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4390 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4438 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4391 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4439 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4392 } | 4440 } |
| 4393 #endif // defined(OS_CHROMEOS) | 4441 #endif // defined(OS_CHROMEOS) |
| 4394 | 4442 |
| 4395 } // namespace policy | 4443 } // namespace policy |
| OLD | NEW |