Index: chrome/browser/policy/policy_browsertest.cc |
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
index 6eab46fd9e24d19b03d48f97c620733f5f27accb..d98d177ceaa0ff2bebf1b3311f088c42d018ffce 100644 |
--- a/chrome/browser/policy/policy_browsertest.cc |
+++ b/chrome/browser/policy/policy_browsertest.cc |
@@ -188,9 +188,18 @@ |
#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/chromeos_switches.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/fake_session_manager_client.h" |
+#include "components/arc/arc_bridge_service.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" |
@@ -3941,6 +3950,80 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { |
UpdateProviderPolicy(policies); |
EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
} |
+ |
+class ArcPolicyTest : public PolicyTest { |
+ protected: |
+ void SetUpTest() { |
+ base::CommandLine::ForCurrentProcess()->AppendSwitch( |
+ chromeos::switches::kDisableArcOptInVerification); |
+ arc::ArcAuthService::DisableUIForTesting(); |
+ |
+ 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 { |
+ fake_session_manager_client_.reset(new chromeos::FakeSessionManagerClient); |
+ fake_session_manager_client_->set_arc_available(true); |
+ chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
+ 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.
|
+ 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.
|
+ |
+ fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance); |
+ arc::ArcBridgeBootstrap::SetBootstrapForTesting( |
+ new arc::FakeArcBridgeBootstrap(fake_arc_bridge_instance_.get())); |
+ |
+ PolicyTest::SetUpInProcessBrowserTestFixture(); |
+ } |
+ |
+ private: |
+ scoped_ptr<chromeos::FakeSessionManagerClient> fake_session_manager_client_; |
+ scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_; |
+}; |
bartfab (slow)
2016/03/02 14:45:40
Nit: DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest)
Polina Bondarenko
2016/03/06 20:22:32
Done.
|
+ |
+// Test ArcEnabled policy. |
+IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
+ SetUpTest(); |
+ |
+ 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.
|
+ 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.
|
+ = 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), |
+ NULL); |
bartfab (slow)
2016/03/02 14:45:40
Nit: s/NULL/nullptr/
Polina Bondarenko
2016/03/06 20:22:32
Done.
|
+ 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), |
+ NULL); |
bartfab (slow)
2016/03/02 14:45:40
Nit: s/NULL/nullptr/
Polina Bondarenko
2016/03/06 20:22:33
Done.
|
+ 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 |