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

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 comments. 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 "chromeos/dbus/session_manager_client.h"
200 #include "components/arc/arc_bridge_service.h"
201 #include "components/arc/arc_service_manager.h"
202 #include "components/arc/test/fake_arc_bridge_bootstrap.h"
203 #include "components/arc/test/fake_arc_bridge_instance.h"
194 #include "ui/chromeos/accessibility_types.h" 204 #include "ui/chromeos/accessibility_types.h"
195 #include "ui/keyboard/keyboard_util.h" 205 #include "ui/keyboard/keyboard_util.h"
196 #include "ui/snapshot/screenshot_grabber.h" 206 #include "ui/snapshot/screenshot_grabber.h"
197 #endif 207 #endif
198 208
199 #if !defined(OS_MACOSX) 209 #if !defined(OS_MACOSX)
200 #include "base/compiler_specific.h" 210 #include "base/compiler_specific.h"
201 #include "chrome/browser/ui/extensions/app_launch_params.h" 211 #include "chrome/browser/ui/extensions/app_launch_params.h"
202 #include "chrome/browser/ui/extensions/application_launch.h" 212 #include "chrome/browser/ui/extensions/application_launch.h"
203 #include "extensions/browser/app_window/app_window.h" 213 #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()); 3944 EXPECT_TRUE(display_manager->unified_desktop_enabled());
3935 policies.Set(key::kUnifiedDesktopEnabledByDefault, 3945 policies.Set(key::kUnifiedDesktopEnabledByDefault,
3936 POLICY_LEVEL_MANDATORY, 3946 POLICY_LEVEL_MANDATORY,
3937 POLICY_SCOPE_USER, 3947 POLICY_SCOPE_USER,
3938 POLICY_SOURCE_CLOUD, 3948 POLICY_SOURCE_CLOUD,
3939 new base::FundamentalValue(false), 3949 new base::FundamentalValue(false),
3940 NULL); 3950 NULL);
3941 UpdateProviderPolicy(policies); 3951 UpdateProviderPolicy(policies);
3942 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 3952 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3943 } 3953 }
3954
3955 class ArcPolicyTest : public PolicyTest {
3956 public:
3957 ArcPolicyTest() {}
3958 ~ArcPolicyTest() {}
3959
3960 protected:
3961 void SetUpTest() {
3962 base::CommandLine::ForCurrentProcess()->AppendSwitch(
3963 chromeos::switches::kDisableArcOptInVerification);
3964 arc::ArcAuthService::DisableUIForTesting();
3965
3966 arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared(
3967 multi_user_util::GetAccountIdFromProfile(browser()->profile()));
3968 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(
3969 browser()->profile());
3970 }
3971
3972 void TearDownTest() {
3973 arc::ArcAuthService::Get()->Shutdown();
3974 }
3975
3976 void SetUpInProcessBrowserTestFixture() override {
3977 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient;
3978 fake_session_manager_client_->set_arc_available(true);
3979 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
3980 scoped_ptr<chromeos::SessionManagerClient>(
3981 fake_session_manager_client_));
3982
3983 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance);
3984 arc::ArcBridgeBootstrap::SetBootstrapForTesting(make_scoped_ptr(
bartfab (slow) 2016/03/07 13:44:04 This is another place where one object has two own
Polina Bondarenko 2016/03/09 17:59:15 No, fake_arc_bridge_bootstrap_ doesn't own this in
bartfab (slow) 2016/03/10 16:13:08 If SetBootstrapForTesting() does not take ownershi
3985 new arc::FakeArcBridgeBootstrap(fake_arc_bridge_instance_.get())));
3986
3987 PolicyTest::SetUpInProcessBrowserTestFixture();
3988 }
3989
3990 private:
3991 chromeos::FakeSessionManagerClient *fake_session_manager_client_;
3992 scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_;
3993
3994 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest);
3995 };
3996
3997 // Test ArcEnabled policy.
3998 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) {
3999 SetUpTest();
4000
4001 PrefService const *pref = browser()->profile()->GetPrefs();
bartfab (slow) 2016/03/07 13:44:04 Nit 1: You had a pointer to const here before. If
Polina Bondarenko 2016/03/09 17:59:15 Done.
4002 arc::ArcBridgeService const *arc_bridge_service
bartfab (slow) 2016/03/07 13:44:04 Nit 1: As above, if you are calling const methods
Polina Bondarenko 2016/03/09 17:59:15 Done.
4003 = arc::ArcBridgeService::Get();
4004
4005 // ARC is switched off by default.
4006 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4007 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4008
4009 // Enable ARC.
4010 PolicyMap policies;
4011 policies.Set(key::kArcEnabled,
4012 POLICY_LEVEL_MANDATORY,
4013 POLICY_SCOPE_USER,
4014 POLICY_SOURCE_CLOUD,
4015 new base::FundamentalValue(true),
4016 nullptr);
4017 UpdateProviderPolicy(policies);
4018 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled));
4019 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state());
4020
4021 // Disable ARC.
4022 policies.Set(key::kArcEnabled,
4023 POLICY_LEVEL_MANDATORY,
4024 POLICY_SCOPE_USER,
4025 POLICY_SOURCE_CLOUD,
4026 new base::FundamentalValue(false),
4027 nullptr);
4028 UpdateProviderPolicy(policies);
4029 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
4030 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
4031
4032 TearDownTest();
4033 }
3944 #endif // defined(OS_CHROMEOS) 4034 #endif // defined(OS_CHROMEOS)
3945 4035
3946 } // namespace policy 4036 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698