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

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

Issue 1829703002: Add ArcEnabled policy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test and removed all changes from arc_auth_service 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/chromeos_switches.h"
bartfab (slow) 2016/04/01 10:41:18 Nit: No longer used.
Polina Bondarenko 2016/04/01 11:05:10 Done.
200 #include "chromeos/dbus/dbus_thread_manager.h"
201 #include "chromeos/dbus/fake_session_manager_client.h"
202 #include "chromeos/dbus/session_manager_client.h"
203 #include "components/arc/arc_bridge_service.h"
204 #include "components/arc/arc_bridge_service_impl.h"
205 #include "components/arc/arc_service_manager.h"
206 #include "components/arc/test/fake_arc_bridge_bootstrap.h"
207 #include "components/arc/test/fake_arc_bridge_instance.h"
197 #include "ui/chromeos/accessibility_types.h" 208 #include "ui/chromeos/accessibility_types.h"
198 #include "ui/keyboard/keyboard_util.h" 209 #include "ui/keyboard/keyboard_util.h"
199 #include "ui/snapshot/screenshot_grabber.h" 210 #include "ui/snapshot/screenshot_grabber.h"
200 #endif 211 #endif
201 212
202 #if !defined(OS_MACOSX) 213 #if !defined(OS_MACOSX)
203 #include "base/compiler_specific.h" 214 #include "base/compiler_specific.h"
204 #include "chrome/browser/ui/extensions/app_launch_params.h" 215 #include "chrome/browser/ui/extensions/app_launch_params.h"
205 #include "chrome/browser/ui/extensions/application_launch.h" 216 #include "chrome/browser/ui/extensions/application_launch.h"
206 #include "extensions/browser/app_window/app_window.h" 217 #include "extensions/browser/app_window/app_window.h"
(...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 EXPECT_TRUE(display_manager->unified_desktop_enabled()); 3995 EXPECT_TRUE(display_manager->unified_desktop_enabled());
3985 policies.Set(key::kUnifiedDesktopEnabledByDefault, 3996 policies.Set(key::kUnifiedDesktopEnabledByDefault,
3986 POLICY_LEVEL_MANDATORY, 3997 POLICY_LEVEL_MANDATORY,
3987 POLICY_SCOPE_USER, 3998 POLICY_SCOPE_USER,
3988 POLICY_SOURCE_CLOUD, 3999 POLICY_SOURCE_CLOUD,
3989 new base::FundamentalValue(false), 4000 new base::FundamentalValue(false),
3990 NULL); 4001 NULL);
3991 UpdateProviderPolicy(policies); 4002 UpdateProviderPolicy(policies);
3992 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 4003 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3993 } 4004 }
4005
4006 class ArcPolicyTest : public PolicyTest {
4007 public:
4008 ArcPolicyTest() {}
4009 ~ArcPolicyTest() override {}
4010
4011 protected:
4012 void SetUpTest() {
4013 arc::ArcAuthService::DisableUIForTesting();
4014
4015 browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
4016 arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared(
4017 multi_user_util::GetAccountIdFromProfile(browser()->profile()));
4018 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(
4019 browser()->profile());
4020 }
4021
4022 void TearDownTest() {
4023 arc::ArcAuthService::Get()->Shutdown();
4024 }
4025
4026 void SetUpInProcessBrowserTestFixture() override {
4027 PolicyTest::SetUpInProcessBrowserTestFixture();
4028 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient;
4029 fake_session_manager_client_->set_arc_available(true);
4030 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
4031 scoped_ptr<chromeos::SessionManagerClient>(
4032 fake_session_manager_client_));
4033
4034 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance);
4035 arc::ArcServiceManager::SetArcBridgeServiceForTesting(make_scoped_ptr(
4036 new arc::ArcBridgeServiceImpl(make_scoped_ptr(
4037 new arc::FakeArcBridgeBootstrap(
4038 fake_arc_bridge_instance_.get())))));
4039 }
4040
4041 private:
4042 chromeos::FakeSessionManagerClient *fake_session_manager_client_;
4043 scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_;
4044
4045 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest);
4046 };
4047
4048 // Test ArcEnabled policy.
4049 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) {
4050 SetUpTest();
4051
4052 const PrefService* const pref = browser()->profile()->GetPrefs();
4053 const arc::ArcBridgeService* const arc_bridge_service
4054 = arc::ArcBridgeService::Get();
4055
4056 // ARC is switched off by default.
4057 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4058 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4059
4060 // Enable ARC.
4061 PolicyMap policies;
4062 policies.Set(key::kArcEnabled,
4063 POLICY_LEVEL_MANDATORY,
4064 POLICY_SCOPE_USER,
4065 POLICY_SOURCE_CLOUD,
4066 new base::FundamentalValue(true),
4067 nullptr);
4068 UpdateProviderPolicy(policies);
4069 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled));
4070 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state());
4071
4072 // Disable ARC.
4073 policies.Set(key::kArcEnabled,
4074 POLICY_LEVEL_MANDATORY,
4075 POLICY_SCOPE_USER,
4076 POLICY_SOURCE_CLOUD,
4077 new base::FundamentalValue(false),
4078 nullptr);
4079 UpdateProviderPolicy(policies);
4080 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4081 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4082
4083 TearDownTest();
4084 }
3994 #endif // defined(OS_CHROMEOS) 4085 #endif // defined(OS_CHROMEOS)
3995 4086
3996 } // namespace policy 4087 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698