Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

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

Powered by Google App Engine
This is Rietveld 408576698