| Index: chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc b/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
|
| index 32797a755e01bf460bbd9d9b9d71b02f98550750..8e010d42b391d9775501107083c87816407ef717 100644
|
| --- a/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
|
| @@ -13,13 +13,19 @@
|
| #include "base/files/scoped_temp_dir.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/observer_list.h"
|
| #include "base/run_loop.h"
|
| #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
|
| #include "chrome/browser/chromeos/arc/arc_session_manager.h"
|
| +#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_initial_oobe_negotiator_for_managed_user.h"
|
| +#include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_actor.h"
|
| +#include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_actor_observer.h"
|
| #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
|
| #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
|
| #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
|
| #include "chrome/browser/chromeos/profiles/profile_helper.h"
|
| +#include "chrome/browser/policy/profile_policy_connector.h"
|
| +#include "chrome/browser/policy/profile_policy_connector_factory.h"
|
| #include "chrome/browser/prefs/pref_service_syncable_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
|
| @@ -98,7 +104,7 @@ class ArcSessionManagerTestBase : public testing::Test {
|
| }
|
|
|
| protected:
|
| - Profile* profile() { return profile_.get(); }
|
| + TestingProfile* profile() { return profile_.get(); }
|
| FakeArcBridgeService* bridge_service() {
|
| return static_cast<FakeArcBridgeService*>(
|
| arc_service_manager_->arc_bridge_service());
|
| @@ -531,4 +537,88 @@ TEST_F(ArcSessionManagerKioskTest, AuthFailure) {
|
| EXPECT_TRUE(terminated);
|
| }
|
|
|
| +class ArcSessionOobeManagedUserTest
|
| + : public ArcSessionManagerTest,
|
| + public chromeos::ArcTermsOfServiceScreenActor {
|
| + public:
|
| + ArcSessionOobeManagedUserTest() = default;
|
| +
|
| + void SetUp() override {
|
| + ArcSessionManagerTest::SetUp();
|
| +
|
| + ArcTermsOfServiceInitialOobeNegotiatorForManagedUser::
|
| + SetArcTermsOfServiceScreenActorForTesting(this);
|
| +
|
| + GetFakeUserManager()->set_current_user_new(true);
|
| +
|
| + policy::ProfilePolicyConnector* const connector =
|
| + policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile());
|
| + connector->OverrideIsManagedForTesting(true);
|
| +
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + chromeos::switches::kEnableArcOOBEOptIn);
|
| +
|
| + profile()->GetTestingPrefService()->SetManagedPref(
|
| + prefs::kArcEnabled, new base::FundamentalValue(true));
|
| + }
|
| +
|
| + void TearDown() override {
|
| + ArcTermsOfServiceInitialOobeNegotiatorForManagedUser::
|
| + SetArcTermsOfServiceScreenActorForTesting(nullptr);
|
| +
|
| + ArcSessionManagerTest::TearDown();
|
| + }
|
| +
|
| + protected:
|
| + void ReportResult(bool accepted) {
|
| + for (auto& observer : observer_list_) {
|
| + if (accepted)
|
| + observer.OnAccept();
|
| + else
|
| + observer.OnSkip();
|
| + }
|
| + base::RunLoop().RunUntilIdle();
|
| + }
|
| +
|
| + private:
|
| + // ArcTermsOfServiceScreenActor:
|
| + void AddObserver(
|
| + chromeos::ArcTermsOfServiceScreenActorObserver* observer) override {
|
| + observer_list_.AddObserver(observer);
|
| + }
|
| +
|
| + void RemoveObserver(
|
| + chromeos::ArcTermsOfServiceScreenActorObserver* observer) override {
|
| + observer_list_.RemoveObserver(observer);
|
| + }
|
| +
|
| + void Show() override {}
|
| + void Hide() override {}
|
| +
|
| + base::ObserverList<chromeos::ArcTermsOfServiceScreenActorObserver>
|
| + observer_list_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeManagedUserTest);
|
| +};
|
| +
|
| +TEST_F(ArcSessionOobeManagedUserTest, OobeTermsAccepted) {
|
| + arc_session_manager()->OnPrimaryUserProfilePrepared(profile());
|
| + EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
|
| + arc_session_manager()->state());
|
| + ReportResult(true);
|
| + EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
|
| + // Correctly stop service.
|
| + arc_session_manager()->Shutdown();
|
| +}
|
| +
|
| +TEST_F(ArcSessionOobeManagedUserTest, OobeTermsRejected) {
|
| + arc_session_manager()->OnPrimaryUserProfilePrepared(profile());
|
| + EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
|
| + arc_session_manager()->state());
|
| + ReportResult(false);
|
| + EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state());
|
| + // Correctly stop service.
|
| + arc_session_manager()->Shutdown();
|
| +}
|
| +
|
| } // namespace arc
|
|
|