| 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 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4124 base::Bind(arc::FakeArcBridgeBootstrap::Create)); | 4126 base::Bind(arc::FakeArcBridgeBootstrap::Create)); |
| 4125 arc::ArcServiceManager::SetArcBridgeServiceForTesting(std::move(service)); | 4127 arc::ArcServiceManager::SetArcBridgeServiceForTesting(std::move(service)); |
| 4126 } | 4128 } |
| 4127 | 4129 |
| 4128 void SetUpCommandLine(base::CommandLine* command_line) override { | 4130 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4129 // ArcAuthService functionality is available only when Arc is enabled. Use | 4131 // ArcAuthService functionality is available only when Arc is enabled. Use |
| 4130 // kEnableArc switch that activates it. | 4132 // kEnableArc switch that activates it. |
| 4131 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 4133 command_line->AppendSwitch(chromeos::switches::kEnableArc); |
| 4132 } | 4134 } |
| 4133 | 4135 |
| 4136 void SetArcEnabledByPolicy(bool enabled) { |
| 4137 PolicyMap policies; |
| 4138 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 4139 POLICY_SOURCE_CLOUD, |
| 4140 base::WrapUnique(new base::FundamentalValue(enabled)), |
| 4141 nullptr); |
| 4142 UpdateProviderPolicy(policies); |
| 4143 if (browser()) { |
| 4144 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 4145 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); |
| 4146 } |
| 4147 } |
| 4148 |
| 4134 private: | 4149 private: |
| 4135 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | 4150 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| 4136 | 4151 |
| 4137 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); | 4152 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4138 }; | 4153 }; |
| 4139 | 4154 |
| 4155 class ArcPolicyDefaultAppTest : public ArcPolicyTest { |
| 4156 public: |
| 4157 ArcPolicyDefaultAppTest() {} |
| 4158 ~ArcPolicyDefaultAppTest() override {} |
| 4159 |
| 4160 protected: |
| 4161 void SetUpInProcessBrowserTestFixture() override { |
| 4162 ArcDefaultAppList::UseTestAppsDirectory(); |
| 4163 ArcPolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4164 } |
| 4165 |
| 4166 private: |
| 4167 DISALLOW_COPY_AND_ASSIGN(ArcPolicyDefaultAppTest); |
| 4168 }; |
| 4169 |
| 4140 // Test ArcEnabled policy. | 4170 // Test ArcEnabled policy. |
| 4141 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { | 4171 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4142 SetUpTest(); | 4172 SetUpTest(); |
| 4143 | 4173 |
| 4144 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4174 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4145 const arc::ArcBridgeService* const arc_bridge_service | 4175 const arc::ArcBridgeService* const arc_bridge_service = |
| 4146 = arc::ArcBridgeService::Get(); | 4176 arc::ArcBridgeService::Get(); |
| 4147 | 4177 |
| 4148 // ARC is switched off by default. | 4178 // ARC is switched off by default. |
| 4149 EXPECT_TRUE(arc_bridge_service->stopped()); | 4179 EXPECT_TRUE(arc_bridge_service->stopped()); |
| 4150 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 4180 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4151 | 4181 |
| 4152 // Enable ARC. | 4182 // Enable ARC. |
| 4153 PolicyMap policies; | 4183 SetArcEnabledByPolicy(true); |
| 4154 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 4155 POLICY_SOURCE_CLOUD, | |
| 4156 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | |
| 4157 UpdateProviderPolicy(policies); | |
| 4158 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 4159 EXPECT_TRUE(arc_bridge_service->ready()); | 4184 EXPECT_TRUE(arc_bridge_service->ready()); |
| 4160 | 4185 |
| 4161 // Disable ARC. | 4186 // Disable ARC. |
| 4162 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 4187 SetArcEnabledByPolicy(false); |
| 4163 POLICY_SOURCE_CLOUD, | |
| 4164 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | |
| 4165 UpdateProviderPolicy(policies); | |
| 4166 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 4167 EXPECT_TRUE(arc_bridge_service->stopped()); | 4188 EXPECT_TRUE(arc_bridge_service->stopped()); |
| 4168 | 4189 |
| 4169 TearDownTest(); | 4190 TearDownTest(); |
| 4170 } | 4191 } |
| 4171 | 4192 |
| 4193 // Test Arc default apps do not appear when Arc is disabled by policy. |
| 4194 IN_PROC_BROWSER_TEST_F(ArcPolicyDefaultAppTest, DefaultApps) { |
| 4195 // Started disabled. |
| 4196 SetArcEnabledByPolicy(false); |
| 4197 |
| 4198 SetUpTest(); |
| 4199 |
| 4200 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(browser()->profile()); |
| 4201 ASSERT_NE(nullptr, prefs); |
| 4202 |
| 4203 base::RunLoop run_loop; |
| 4204 prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 4205 run_loop.Run(); |
| 4206 |
| 4207 EXPECT_TRUE(prefs->GetAppIds().empty()); |
| 4208 |
| 4209 // Enable Arc |
| 4210 SetArcEnabledByPolicy(true); |
| 4211 EXPECT_FALSE(prefs->GetAppIds().empty()); |
| 4212 |
| 4213 // Disable Arc again. |
| 4214 SetArcEnabledByPolicy(false); |
| 4215 EXPECT_TRUE(prefs->GetAppIds().empty()); |
| 4216 |
| 4217 TearDownTest(); |
| 4218 } |
| 4219 |
| 4172 // Test ArcBackupRestoreEnabled policy. | 4220 // Test ArcBackupRestoreEnabled policy. |
| 4173 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { | 4221 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { |
| 4174 SetUpTest(); | 4222 SetUpTest(); |
| 4175 | 4223 |
| 4176 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4224 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4177 | 4225 |
| 4178 // ARC Backup & Restore is switched on by default. | 4226 // ARC Backup & Restore is switched on by default. |
| 4179 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4227 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4180 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4228 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4181 | 4229 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4372 | 4420 |
| 4373 SetEmptyPolicy(); | 4421 SetEmptyPolicy(); |
| 4374 // Policy not set. | 4422 // Policy not set. |
| 4375 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4423 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4376 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4424 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4377 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4425 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4378 } | 4426 } |
| 4379 #endif // defined(OS_CHROMEOS) | 4427 #endif // defined(OS_CHROMEOS) |
| 4380 | 4428 |
| 4381 } // namespace policy | 4429 } // namespace policy |
| OLD | NEW |