| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | 209 #include "chromeos/dbus/dbus_thread_manager.h" |
| 210 #include "chromeos/dbus/fake_session_manager_client.h" | 210 #include "chromeos/dbus/fake_session_manager_client.h" |
| 211 #include "chromeos/dbus/session_manager_client.h" | 211 #include "chromeos/dbus/session_manager_client.h" |
| 212 #include "components/arc/arc_bridge_service.h" | |
| 213 #include "components/arc/arc_service_manager.h" | |
| 214 #include "components/arc/arc_session_runner.h" | 212 #include "components/arc/arc_session_runner.h" |
| 215 #include "components/arc/test/fake_arc_session.h" | 213 #include "components/arc/test/fake_arc_session.h" |
| 216 #include "components/signin/core/account_id/account_id.h" | 214 #include "components/signin/core/account_id/account_id.h" |
| 217 #include "components/user_manager/user_manager.h" | 215 #include "components/user_manager/user_manager.h" |
| 218 #include "ui/keyboard/keyboard_util.h" | 216 #include "ui/keyboard/keyboard_util.h" |
| 219 #include "ui/snapshot/screenshot_grabber.h" | 217 #include "ui/snapshot/screenshot_grabber.h" |
| 220 #endif | 218 #endif |
| 221 | 219 |
| 222 #if !defined(OS_MACOSX) | 220 #if !defined(OS_MACOSX) |
| 223 #include "base/compiler_specific.h" | 221 #include "base/compiler_specific.h" |
| (...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4045 } | 4043 } |
| 4046 | 4044 |
| 4047 class ArcPolicyTest : public PolicyTest { | 4045 class ArcPolicyTest : public PolicyTest { |
| 4048 public: | 4046 public: |
| 4049 ArcPolicyTest() {} | 4047 ArcPolicyTest() {} |
| 4050 ~ArcPolicyTest() override {} | 4048 ~ArcPolicyTest() override {} |
| 4051 | 4049 |
| 4052 protected: | 4050 protected: |
| 4053 void SetUpTest() { | 4051 void SetUpTest() { |
| 4054 arc::ArcSessionManager::DisableUIForTesting(); | 4052 arc::ArcSessionManager::DisableUIForTesting(); |
| 4053 arc::ArcSessionManager::Get()->SetArcSessionRunnerForTesting( |
| 4054 base::MakeUnique<arc::ArcSessionRunner>( |
| 4055 base::Bind(arc::FakeArcSession::Create))); |
| 4055 | 4056 |
| 4056 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 4057 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 4057 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, | 4058 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, |
| 4058 true); | 4059 true); |
| 4059 } | 4060 } |
| 4060 | 4061 |
| 4061 void TearDownTest() { arc::ArcSessionManager::Get()->Shutdown(); } | 4062 void TearDownTest() { arc::ArcSessionManager::Get()->Shutdown(); } |
| 4062 | 4063 |
| 4063 void SetUpInProcessBrowserTestFixture() override { | 4064 void SetUpInProcessBrowserTestFixture() override { |
| 4064 PolicyTest::SetUpInProcessBrowserTestFixture(); | 4065 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4065 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; | 4066 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; |
| 4066 fake_session_manager_client_->set_arc_available(true); | 4067 fake_session_manager_client_->set_arc_available(true); |
| 4067 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 4068 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 4068 std::unique_ptr<chromeos::SessionManagerClient>( | 4069 std::unique_ptr<chromeos::SessionManagerClient>( |
| 4069 fake_session_manager_client_)); | 4070 fake_session_manager_client_)); |
| 4070 | |
| 4071 arc::ArcServiceManager::SetArcSessionRunnerForTesting( | |
| 4072 base::MakeUnique<arc::ArcSessionRunner>( | |
| 4073 base::Bind(arc::FakeArcSession::Create))); | |
| 4074 } | 4071 } |
| 4075 | 4072 |
| 4076 void SetUpCommandLine(base::CommandLine* command_line) override { | 4073 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4077 // ArcSessionManager functionality is available only when Arc is enabled. | 4074 // ArcSessionManager functionality is available only when Arc is enabled. |
| 4078 // Use kEnableArc switch that activates it. | 4075 // Use kEnableArc switch that activates it. |
| 4079 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 4076 command_line->AppendSwitch(chromeos::switches::kEnableArc); |
| 4080 } | 4077 } |
| 4081 | 4078 |
| 4082 void SetArcEnabledByPolicy(bool enabled) { | 4079 void SetArcEnabledByPolicy(bool enabled) { |
| 4083 PolicyMap policies; | 4080 PolicyMap policies; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4096 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | 4093 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| 4097 | 4094 |
| 4098 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); | 4095 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4099 }; | 4096 }; |
| 4100 | 4097 |
| 4101 // Test ArcEnabled policy. | 4098 // Test ArcEnabled policy. |
| 4102 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { | 4099 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4103 SetUpTest(); | 4100 SetUpTest(); |
| 4104 | 4101 |
| 4105 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4102 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4106 const arc::ArcBridgeService* const arc_bridge_service = | 4103 const auto* const arc_session_manager = arc::ArcSessionManager::Get(); |
| 4107 arc::ArcServiceManager::Get()->arc_bridge_service(); | |
| 4108 | 4104 |
| 4109 // ARC is switched off by default. | 4105 // ARC is switched off by default. |
| 4110 EXPECT_TRUE(arc_bridge_service->stopped()); | 4106 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); |
| 4111 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 4107 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4112 | 4108 |
| 4113 // Enable ARC. | 4109 // Enable ARC. |
| 4114 SetArcEnabledByPolicy(true); | 4110 SetArcEnabledByPolicy(true); |
| 4115 EXPECT_TRUE(arc_bridge_service->ready()); | 4111 EXPECT_TRUE(arc_session_manager->IsSessionRunning()); |
| 4116 | 4112 |
| 4117 // Disable ARC. | 4113 // Disable ARC. |
| 4118 SetArcEnabledByPolicy(false); | 4114 SetArcEnabledByPolicy(false); |
| 4119 EXPECT_TRUE(arc_bridge_service->stopped()); | 4115 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); |
| 4120 | 4116 |
| 4121 TearDownTest(); | 4117 TearDownTest(); |
| 4122 } | 4118 } |
| 4123 | 4119 |
| 4124 // Test ArcBackupRestoreEnabled policy. | 4120 // Test ArcBackupRestoreEnabled policy. |
| 4125 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { | 4121 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { |
| 4126 SetUpTest(); | 4122 SetUpTest(); |
| 4127 | 4123 |
| 4128 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4124 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4129 | 4125 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4324 | 4320 |
| 4325 SetEmptyPolicy(); | 4321 SetEmptyPolicy(); |
| 4326 // Policy not set. | 4322 // Policy not set. |
| 4327 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4323 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4328 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4324 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4329 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4325 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4330 } | 4326 } |
| 4331 #endif // defined(OS_CHROMEOS) | 4327 #endif // defined(OS_CHROMEOS) |
| 4332 | 4328 |
| 4333 } // namespace policy | 4329 } // namespace policy |
| OLD | NEW |