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