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

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: Added browser test. 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 #include "ui/base/page_transition_types.h" 181 #include "ui/base/page_transition_types.h"
182 #include "ui/base/resource/resource_bundle.h" 182 #include "ui/base/resource/resource_bundle.h"
183 #include "url/gurl.h" 183 #include "url/gurl.h"
184 184
185 #if defined(OS_CHROMEOS) 185 #if defined(OS_CHROMEOS)
186 #include "ash/accelerators/accelerator_controller.h" 186 #include "ash/accelerators/accelerator_controller.h"
187 #include "ash/accelerators/accelerator_table.h" 187 #include "ash/accelerators/accelerator_table.h"
188 #include "ash/shell.h" 188 #include "ash/shell.h"
189 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 189 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
190 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 190 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
191 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
191 #include "chrome/browser/profiles/profile_manager.h" 192 #include "chrome/browser/profiles/profile_manager.h"
192 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" 193 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
194 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
193 #include "chromeos/audio/cras_audio_handler.h" 195 #include "chromeos/audio/cras_audio_handler.h"
196 #include "chromeos/chromeos_switches.h"
197 #include "chromeos/dbus/dbus_thread_manager.h"
198 #include "chromeos/dbus/fake_session_manager_client.h"
199 #include "components/arc/arc_bridge_service.h"
200 #include "components/arc/arc_service_manager.h"
201 #include "components/arc/test/fake_arc_bridge_bootstrap.h"
202 #include "components/arc/test/fake_arc_bridge_instance.h"
194 #include "ui/chromeos/accessibility_types.h" 203 #include "ui/chromeos/accessibility_types.h"
195 #include "ui/keyboard/keyboard_util.h" 204 #include "ui/keyboard/keyboard_util.h"
196 #include "ui/snapshot/screenshot_grabber.h" 205 #include "ui/snapshot/screenshot_grabber.h"
197 #endif 206 #endif
198 207
199 #if !defined(OS_MACOSX) 208 #if !defined(OS_MACOSX)
200 #include "base/compiler_specific.h" 209 #include "base/compiler_specific.h"
201 #include "chrome/browser/ui/extensions/app_launch_params.h" 210 #include "chrome/browser/ui/extensions/app_launch_params.h"
202 #include "chrome/browser/ui/extensions/application_launch.h" 211 #include "chrome/browser/ui/extensions/application_launch.h"
203 #include "extensions/browser/app_window/app_window.h" 212 #include "extensions/browser/app_window/app_window.h"
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 EXPECT_TRUE(display_manager->unified_desktop_enabled()); 3943 EXPECT_TRUE(display_manager->unified_desktop_enabled());
3935 policies.Set(key::kUnifiedDesktopEnabledByDefault, 3944 policies.Set(key::kUnifiedDesktopEnabledByDefault,
3936 POLICY_LEVEL_MANDATORY, 3945 POLICY_LEVEL_MANDATORY,
3937 POLICY_SCOPE_USER, 3946 POLICY_SCOPE_USER,
3938 POLICY_SOURCE_CLOUD, 3947 POLICY_SOURCE_CLOUD,
3939 new base::FundamentalValue(false), 3948 new base::FundamentalValue(false),
3940 NULL); 3949 NULL);
3941 UpdateProviderPolicy(policies); 3950 UpdateProviderPolicy(policies);
3942 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 3951 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3943 } 3952 }
3953
3954 class ArcPolicyTest : public PolicyTest {
3955 protected:
3956 void SetUpTest() {
3957 base::CommandLine::ForCurrentProcess()->AppendSwitch(
3958 chromeos::switches::kDisableArcOptInVerification);
3959 arc::ArcAuthService::DisableUIForTesting();
3960
3961 arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared(
3962 multi_user_util::GetAccountIdFromProfile(browser()->profile()));
3963 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(
3964 browser()->profile());
3965 }
3966
3967 void TearDownTest() {
3968 arc::ArcAuthService::Get()->Shutdown();
3969 }
3970
3971 void SetUpInProcessBrowserTestFixture() override {
3972 fake_session_manager_client_.reset(new chromeos::FakeSessionManagerClient);
3973 fake_session_manager_client_->set_arc_available(true);
3974 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
3975 scoped_ptr<chromeos::SessionManagerClient>(
bartfab (slow) 2016/03/02 14:45:40 Nit: #include "chromeos/dbus/session_manager_clien
Polina Bondarenko 2016/03/06 20:22:32 Done.
3976 fake_session_manager_client_.get()));
bartfab (slow) 2016/03/02 14:45:40 You now have two scoped_ptrs who both think they o
Polina Bondarenko 2016/03/06 20:22:32 Fixed.
3977
3978 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance);
3979 arc::ArcBridgeBootstrap::SetBootstrapForTesting(
3980 new arc::FakeArcBridgeBootstrap(fake_arc_bridge_instance_.get()));
3981
3982 PolicyTest::SetUpInProcessBrowserTestFixture();
3983 }
3984
3985 private:
3986 scoped_ptr<chromeos::FakeSessionManagerClient> fake_session_manager_client_;
3987 scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_;
3988 };
bartfab (slow) 2016/03/02 14:45:40 Nit: DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest)
Polina Bondarenko 2016/03/06 20:22:32 Done.
3989
3990 // Test ArcEnabled policy.
3991 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) {
3992 SetUpTest();
3993
3994 const PrefService* pref = browser()->profile()->GetPrefs();
bartfab (slow) 2016/03/02 14:45:40 Nit: const pointer.
Polina Bondarenko 2016/03/06 20:22:32 Done.
3995 const arc::ArcBridgeService* arc_bridge_service
bartfab (slow) 2016/03/02 14:45:40 Nit: const pointer.
Polina Bondarenko 2016/03/06 20:22:33 Done.
3996 = arc::ArcBridgeService::Get();
3997
3998 // ARC is switched off by default.
3999 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4000 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4001
4002 // Enable ARC.
4003 PolicyMap policies;
4004 policies.Set(key::kArcEnabled,
4005 POLICY_LEVEL_MANDATORY,
4006 POLICY_SCOPE_USER,
4007 POLICY_SOURCE_CLOUD,
4008 new base::FundamentalValue(true),
4009 NULL);
bartfab (slow) 2016/03/02 14:45:40 Nit: s/NULL/nullptr/
Polina Bondarenko 2016/03/06 20:22:32 Done.
4010 UpdateProviderPolicy(policies);
4011 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled));
4012 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state());
4013
4014 // Disable ARC.
4015 policies.Set(key::kArcEnabled,
4016 POLICY_LEVEL_MANDATORY,
4017 POLICY_SCOPE_USER,
4018 POLICY_SOURCE_CLOUD,
4019 new base::FundamentalValue(false),
4020 NULL);
bartfab (slow) 2016/03/02 14:45:40 Nit: s/NULL/nullptr/
Polina Bondarenko 2016/03/06 20:22:33 Done.
4021 UpdateProviderPolicy(policies);
4022 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4023 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4024
4025 TearDownTest();
4026 }
3944 #endif // defined(OS_CHROMEOS) 4027 #endif // defined(OS_CHROMEOS)
3945 4028
3946 } // namespace policy 4029 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698