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 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 #include "ui/base/resource/resource_bundle.h" | 184 #include "ui/base/resource/resource_bundle.h" |
185 #include "url/gurl.h" | 185 #include "url/gurl.h" |
186 #include "url/origin.h" | 186 #include "url/origin.h" |
187 | 187 |
188 #if defined(OS_CHROMEOS) | 188 #if defined(OS_CHROMEOS) |
189 #include "ash/accelerators/accelerator_controller.h" | 189 #include "ash/accelerators/accelerator_controller.h" |
190 #include "ash/accelerators/accelerator_table.h" | 190 #include "ash/accelerators/accelerator_table.h" |
191 #include "ash/shell.h" | 191 #include "ash/shell.h" |
192 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 192 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
193 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 193 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 194 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
194 #include "chrome/browser/profiles/profile_manager.h" | 195 #include "chrome/browser/profiles/profile_manager.h" |
195 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 196 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 197 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
196 #include "chromeos/audio/cras_audio_handler.h" | 198 #include "chromeos/audio/cras_audio_handler.h" |
| 199 #include "chromeos/dbus/dbus_thread_manager.h" |
| 200 #include "chromeos/dbus/fake_session_manager_client.h" |
| 201 #include "chromeos/dbus/session_manager_client.h" |
| 202 #include "components/arc/arc_bridge_service.h" |
| 203 #include "components/arc/arc_bridge_service_impl.h" |
| 204 #include "components/arc/arc_service_manager.h" |
| 205 #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
| 206 #include "components/arc/test/fake_arc_bridge_instance.h" |
197 #include "ui/chromeos/accessibility_types.h" | 207 #include "ui/chromeos/accessibility_types.h" |
198 #include "ui/keyboard/keyboard_util.h" | 208 #include "ui/keyboard/keyboard_util.h" |
199 #include "ui/snapshot/screenshot_grabber.h" | 209 #include "ui/snapshot/screenshot_grabber.h" |
200 #endif | 210 #endif |
201 | 211 |
202 #if !defined(OS_MACOSX) | 212 #if !defined(OS_MACOSX) |
203 #include "base/compiler_specific.h" | 213 #include "base/compiler_specific.h" |
204 #include "chrome/browser/ui/extensions/app_launch_params.h" | 214 #include "chrome/browser/ui/extensions/app_launch_params.h" |
205 #include "chrome/browser/ui/extensions/application_launch.h" | 215 #include "chrome/browser/ui/extensions/application_launch.h" |
206 #include "extensions/browser/app_window/app_window.h" | 216 #include "extensions/browser/app_window/app_window.h" |
(...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3984 EXPECT_TRUE(display_manager->unified_desktop_enabled()); | 3994 EXPECT_TRUE(display_manager->unified_desktop_enabled()); |
3985 policies.Set(key::kUnifiedDesktopEnabledByDefault, | 3995 policies.Set(key::kUnifiedDesktopEnabledByDefault, |
3986 POLICY_LEVEL_MANDATORY, | 3996 POLICY_LEVEL_MANDATORY, |
3987 POLICY_SCOPE_USER, | 3997 POLICY_SCOPE_USER, |
3988 POLICY_SOURCE_CLOUD, | 3998 POLICY_SOURCE_CLOUD, |
3989 new base::FundamentalValue(false), | 3999 new base::FundamentalValue(false), |
3990 NULL); | 4000 NULL); |
3991 UpdateProviderPolicy(policies); | 4001 UpdateProviderPolicy(policies); |
3992 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4002 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
3993 } | 4003 } |
| 4004 |
| 4005 class ArcPolicyTest : public PolicyTest { |
| 4006 public: |
| 4007 ArcPolicyTest() {} |
| 4008 ~ArcPolicyTest() override {} |
| 4009 |
| 4010 protected: |
| 4011 void SetUpTest() { |
| 4012 arc::ArcAuthService::DisableUIForTesting(); |
| 4013 |
| 4014 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 4015 arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared( |
| 4016 multi_user_util::GetAccountIdFromProfile(browser()->profile())); |
| 4017 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared( |
| 4018 browser()->profile()); |
| 4019 } |
| 4020 |
| 4021 void TearDownTest() { |
| 4022 arc::ArcAuthService::Get()->Shutdown(); |
| 4023 } |
| 4024 |
| 4025 void SetUpInProcessBrowserTestFixture() override { |
| 4026 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4027 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; |
| 4028 fake_session_manager_client_->set_arc_available(true); |
| 4029 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 4030 scoped_ptr<chromeos::SessionManagerClient>( |
| 4031 fake_session_manager_client_)); |
| 4032 |
| 4033 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance); |
| 4034 arc::ArcServiceManager::SetArcBridgeServiceForTesting(make_scoped_ptr( |
| 4035 new arc::ArcBridgeServiceImpl(make_scoped_ptr( |
| 4036 new arc::FakeArcBridgeBootstrap( |
| 4037 fake_arc_bridge_instance_.get()))))); |
| 4038 } |
| 4039 |
| 4040 private: |
| 4041 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| 4042 scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_; |
| 4043 |
| 4044 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4045 }; |
| 4046 |
| 4047 // Test ArcEnabled policy. |
| 4048 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4049 SetUpTest(); |
| 4050 |
| 4051 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4052 const arc::ArcBridgeService* const arc_bridge_service |
| 4053 = arc::ArcBridgeService::Get(); |
| 4054 |
| 4055 // ARC is switched off by default. |
| 4056 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
| 4057 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4058 |
| 4059 // Enable ARC. |
| 4060 PolicyMap policies; |
| 4061 policies.Set(key::kArcEnabled, |
| 4062 POLICY_LEVEL_MANDATORY, |
| 4063 POLICY_SCOPE_USER, |
| 4064 POLICY_SOURCE_CLOUD, |
| 4065 new base::FundamentalValue(true), |
| 4066 nullptr); |
| 4067 UpdateProviderPolicy(policies); |
| 4068 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4069 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state()); |
| 4070 |
| 4071 // Disable ARC. |
| 4072 policies.Set(key::kArcEnabled, |
| 4073 POLICY_LEVEL_MANDATORY, |
| 4074 POLICY_SCOPE_USER, |
| 4075 POLICY_SOURCE_CLOUD, |
| 4076 new base::FundamentalValue(false), |
| 4077 nullptr); |
| 4078 UpdateProviderPolicy(policies); |
| 4079 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4080 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
| 4081 |
| 4082 TearDownTest(); |
| 4083 } |
3994 #endif // defined(OS_CHROMEOS) | 4084 #endif // defined(OS_CHROMEOS) |
3995 | 4085 |
3996 } // namespace policy | 4086 } // namespace policy |
OLD | NEW |