| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 199 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 200 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 200 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 201 #include "chrome/browser/chromeos/login/test/js_checker.h" | 201 #include "chrome/browser/chromeos/login/test/js_checker.h" |
| 202 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" | 202 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
| 203 #include "chrome/browser/profiles/profile_manager.h" | 203 #include "chrome/browser/profiles/profile_manager.h" |
| 204 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 204 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 205 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 205 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 206 #include "chromeos/audio/cras_audio_handler.h" | 206 #include "chromeos/audio/cras_audio_handler.h" |
| 207 #include "chromeos/chromeos_switches.h" | 207 #include "chromeos/chromeos_switches.h" |
| 208 #include "chromeos/cryptohome/cryptohome_parameters.h" | 208 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 209 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 210 #include "chromeos/dbus/fake_session_manager_client.h" | |
| 211 #include "chromeos/dbus/session_manager_client.h" | |
| 212 #include "components/arc/arc_session_runner.h" | 209 #include "components/arc/arc_session_runner.h" |
| 210 #include "components/arc/arc_util.h" |
| 213 #include "components/arc/test/fake_arc_session.h" | 211 #include "components/arc/test/fake_arc_session.h" |
| 214 #include "components/signin/core/account_id/account_id.h" | 212 #include "components/signin/core/account_id/account_id.h" |
| 215 #include "components/user_manager/user_manager.h" | 213 #include "components/user_manager/user_manager.h" |
| 216 #include "ui/keyboard/keyboard_util.h" | 214 #include "ui/keyboard/keyboard_util.h" |
| 217 #include "ui/snapshot/screenshot_grabber.h" | 215 #include "ui/snapshot/screenshot_grabber.h" |
| 218 #endif | 216 #endif |
| 219 | 217 |
| 220 #if !defined(OS_MACOSX) | 218 #if !defined(OS_MACOSX) |
| 221 #include "base/compiler_specific.h" | 219 #include "base/compiler_specific.h" |
| 222 #include "chrome/browser/ui/extensions/app_launch_params.h" | 220 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| (...skipping 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 UpdateProviderPolicy(policies); | 4039 UpdateProviderPolicy(policies); |
| 4042 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4040 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 4043 } | 4041 } |
| 4044 | 4042 |
| 4045 class ArcPolicyTest : public PolicyTest { | 4043 class ArcPolicyTest : public PolicyTest { |
| 4046 public: | 4044 public: |
| 4047 ArcPolicyTest() {} | 4045 ArcPolicyTest() {} |
| 4048 ~ArcPolicyTest() override {} | 4046 ~ArcPolicyTest() override {} |
| 4049 | 4047 |
| 4050 protected: | 4048 protected: |
| 4051 void SetUpTest() { | 4049 void SetUpOnMainThread() override { |
| 4050 PolicyTest::SetUpOnMainThread(); |
| 4052 arc::ArcSessionManager::DisableUIForTesting(); | 4051 arc::ArcSessionManager::DisableUIForTesting(); |
| 4053 arc::ArcSessionManager::Get()->SetArcSessionRunnerForTesting( | 4052 arc::ArcSessionManager::Get()->SetArcSessionRunnerForTesting( |
| 4054 base::MakeUnique<arc::ArcSessionRunner>( | 4053 base::MakeUnique<arc::ArcSessionRunner>( |
| 4055 base::Bind(arc::FakeArcSession::Create))); | 4054 base::Bind(arc::FakeArcSession::Create))); |
| 4056 | 4055 |
| 4057 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 4056 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 4058 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, | 4057 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, |
| 4059 true); | 4058 true); |
| 4060 } | 4059 } |
| 4061 | 4060 |
| 4062 void TearDownTest() { arc::ArcSessionManager::Get()->Shutdown(); } | 4061 void TearDownOnMainThread() override { |
| 4063 | 4062 arc::ArcSessionManager::Get()->Shutdown(); |
| 4064 void SetUpInProcessBrowserTestFixture() override { | 4063 PolicyTest::TearDownOnMainThread(); |
| 4065 PolicyTest::SetUpInProcessBrowserTestFixture(); | |
| 4066 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; | |
| 4067 fake_session_manager_client_->set_arc_available(true); | |
| 4068 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | |
| 4069 std::unique_ptr<chromeos::SessionManagerClient>( | |
| 4070 fake_session_manager_client_)); | |
| 4071 } | 4064 } |
| 4072 | 4065 |
| 4073 void SetUpCommandLine(base::CommandLine* command_line) override { | 4066 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4074 // ArcSessionManager functionality is available only when Arc is enabled. | 4067 PolicyTest::SetUpCommandLine(command_line); |
| 4075 // Use kEnableArc switch that activates it. | 4068 arc::SetArcAvailableCommandLineForTesting(command_line); |
| 4076 command_line->AppendSwitch(chromeos::switches::kEnableArc); | |
| 4077 } | 4069 } |
| 4078 | 4070 |
| 4079 void SetArcEnabledByPolicy(bool enabled) { | 4071 void SetArcEnabledByPolicy(bool enabled) { |
| 4080 PolicyMap policies; | 4072 PolicyMap policies; |
| 4081 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 4073 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 4082 POLICY_SOURCE_CLOUD, | 4074 POLICY_SOURCE_CLOUD, |
| 4083 base::WrapUnique(new base::FundamentalValue(enabled)), | 4075 base::WrapUnique(new base::FundamentalValue(enabled)), |
| 4084 nullptr); | 4076 nullptr); |
| 4085 UpdateProviderPolicy(policies); | 4077 UpdateProviderPolicy(policies); |
| 4086 if (browser()) { | 4078 if (browser()) { |
| 4087 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 4079 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 4088 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); | 4080 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); |
| 4089 } | 4081 } |
| 4090 } | 4082 } |
| 4091 | 4083 |
| 4092 private: | 4084 private: |
| 4093 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | |
| 4094 | |
| 4095 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); | 4085 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4096 }; | 4086 }; |
| 4097 | 4087 |
| 4098 // Test ArcEnabled policy. | 4088 // Test ArcEnabled policy. |
| 4099 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { | 4089 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4100 SetUpTest(); | |
| 4101 | |
| 4102 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4090 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4103 const auto* const arc_session_manager = arc::ArcSessionManager::Get(); | 4091 const auto* const arc_session_manager = arc::ArcSessionManager::Get(); |
| 4104 | 4092 |
| 4105 // ARC is switched off by default. | 4093 // ARC is switched off by default. |
| 4106 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); | 4094 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); |
| 4107 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 4095 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4108 | 4096 |
| 4109 // Enable ARC. | 4097 // Enable ARC. |
| 4110 SetArcEnabledByPolicy(true); | 4098 SetArcEnabledByPolicy(true); |
| 4111 EXPECT_TRUE(arc_session_manager->IsSessionRunning()); | 4099 EXPECT_TRUE(arc_session_manager->IsSessionRunning()); |
| 4112 | 4100 |
| 4113 // Disable ARC. | 4101 // Disable ARC. |
| 4114 SetArcEnabledByPolicy(false); | 4102 SetArcEnabledByPolicy(false); |
| 4115 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); | 4103 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); |
| 4116 | |
| 4117 TearDownTest(); | |
| 4118 } | 4104 } |
| 4119 | 4105 |
| 4120 // Test ArcBackupRestoreEnabled policy. | 4106 // Test ArcBackupRestoreEnabled policy. |
| 4121 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { | 4107 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { |
| 4122 SetUpTest(); | |
| 4123 | |
| 4124 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4108 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4125 | 4109 |
| 4126 // ARC Backup & Restore is switched on by default. | 4110 // ARC Backup & Restore is switched on by default. |
| 4127 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4111 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4128 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4112 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4129 | 4113 |
| 4130 // Disable ARC Backup & Restore. | 4114 // Disable ARC Backup & Restore. |
| 4131 PolicyMap policies; | 4115 PolicyMap policies; |
| 4132 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4116 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4133 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4117 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4134 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 4118 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 4135 UpdateProviderPolicy(policies); | 4119 UpdateProviderPolicy(policies); |
| 4136 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4120 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4137 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4121 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4138 | 4122 |
| 4139 // Enable ARC Backup & Restore. | 4123 // Enable ARC Backup & Restore. |
| 4140 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4124 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4141 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4125 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4142 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 4126 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 4143 UpdateProviderPolicy(policies); | 4127 UpdateProviderPolicy(policies); |
| 4144 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4128 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4145 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4129 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4146 | |
| 4147 TearDownTest(); | |
| 4148 } | 4130 } |
| 4149 | 4131 |
| 4150 // Test ArcLocationServiceEnabled policy. | 4132 // Test ArcLocationServiceEnabled policy. |
| 4151 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { | 4133 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { |
| 4152 SetUpTest(); | |
| 4153 | |
| 4154 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4134 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4155 | 4135 |
| 4156 // ARC Location Service is switched on by default. | 4136 // ARC Location Service is switched on by default. |
| 4157 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4137 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4158 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4138 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4159 | 4139 |
| 4160 // Managed Location Service. | 4140 // Managed Location Service. |
| 4161 PolicyMap policies; | 4141 PolicyMap policies; |
| 4162 // AllowGeolocation | 4142 // AllowGeolocation |
| 4163 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, | 4143 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4175 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4155 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4176 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4156 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4177 | 4157 |
| 4178 // AskGeolocation | 4158 // AskGeolocation |
| 4179 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, | 4159 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
| 4180 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4160 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4181 base::MakeUnique<base::FundamentalValue>(3), nullptr); | 4161 base::MakeUnique<base::FundamentalValue>(3), nullptr); |
| 4182 UpdateProviderPolicy(policies); | 4162 UpdateProviderPolicy(policies); |
| 4183 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4163 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4184 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4164 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4185 | |
| 4186 TearDownTest(); | |
| 4187 } | 4165 } |
| 4188 | 4166 |
| 4189 namespace { | 4167 namespace { |
| 4190 const char kTestUser1[] = "test1@domain.com"; | 4168 const char kTestUser1[] = "test1@domain.com"; |
| 4191 } // anonymous namespace | 4169 } // anonymous namespace |
| 4192 | 4170 |
| 4193 class ChromeOSPolicyTest : public PolicyTest { | 4171 class ChromeOSPolicyTest : public PolicyTest { |
| 4194 public: | 4172 public: |
| 4195 ChromeOSPolicyTest() {} | 4173 ChromeOSPolicyTest() {} |
| 4196 | 4174 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4320 | 4298 |
| 4321 SetEmptyPolicy(); | 4299 SetEmptyPolicy(); |
| 4322 // Policy not set. | 4300 // Policy not set. |
| 4323 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4301 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4324 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4302 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4325 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4303 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4326 } | 4304 } |
| 4327 #endif // defined(OS_CHROMEOS) | 4305 #endif // defined(OS_CHROMEOS) |
| 4328 | 4306 |
| 4329 } // namespace policy | 4307 } // namespace policy |
| OLD | NEW |