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

Unified 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 comments. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index eb72c63681024fce592adc0c92e910fcfe98d23d..e8032512a1467efba3e9188b3700e9668d9022da 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -191,9 +191,19 @@
#include "ash/shell.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
+#include "chrome/browser/chromeos/arc/arc_auth_service.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
+#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chromeos/audio/cras_audio_handler.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/fake_session_manager_client.h"
+#include "chromeos/dbus/session_manager_client.h"
+#include "components/arc/arc_bridge_service.h"
+#include "components/arc/arc_bridge_service_impl.h"
+#include "components/arc/arc_service_manager.h"
+#include "components/arc/test/fake_arc_bridge_bootstrap.h"
+#include "components/arc/test/fake_arc_bridge_instance.h"
#include "ui/chromeos/accessibility_types.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/snapshot/screenshot_grabber.h"
@@ -3991,6 +4001,86 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) {
UpdateProviderPolicy(policies);
EXPECT_FALSE(display_manager->unified_desktop_enabled());
}
+
+class ArcPolicyTest : public PolicyTest {
+ public:
+ ArcPolicyTest() {}
+ ~ArcPolicyTest() override {}
+
+ protected:
+ void SetUpTest() {
+ arc::ArcAuthService::DisableUIForTesting();
+
+ browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
+ arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared(
+ multi_user_util::GetAccountIdFromProfile(browser()->profile()));
+ arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(
+ browser()->profile());
+ }
+
+ void TearDownTest() {
+ arc::ArcAuthService::Get()->Shutdown();
+ }
+
+ void SetUpInProcessBrowserTestFixture() override {
+ PolicyTest::SetUpInProcessBrowserTestFixture();
+ fake_session_manager_client_ = new chromeos::FakeSessionManagerClient;
+ fake_session_manager_client_->set_arc_available(true);
+ chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
+ scoped_ptr<chromeos::SessionManagerClient>(
+ fake_session_manager_client_));
+
+ fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance);
+ arc::ArcServiceManager::SetArcBridgeServiceForTesting(make_scoped_ptr(
+ new arc::ArcBridgeServiceImpl(make_scoped_ptr(
+ new arc::FakeArcBridgeBootstrap(
+ fake_arc_bridge_instance_.get())))));
+ }
+
+ private:
+ chromeos::FakeSessionManagerClient *fake_session_manager_client_;
+ scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest);
+};
+
+// Test ArcEnabled policy.
+IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) {
+ SetUpTest();
+
+ const PrefService* const pref = browser()->profile()->GetPrefs();
+ const arc::ArcBridgeService* const arc_bridge_service
+ = arc::ArcBridgeService::Get();
+
+ // ARC is switched off by default.
+ EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
+ EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
+
+ // Enable ARC.
+ PolicyMap policies;
+ policies.Set(key::kArcEnabled,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
+ new base::FundamentalValue(true),
+ nullptr);
+ UpdateProviderPolicy(policies);
+ EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled));
+ EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state());
+
+ // Disable ARC.
+ policies.Set(key::kArcEnabled,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ POLICY_SOURCE_CLOUD,
+ new base::FundamentalValue(false),
+ nullptr);
+ UpdateProviderPolicy(policies);
+ EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled));
+ EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state());
+
+ TearDownTest();
+}
#endif // defined(OS_CHROMEOS)
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698