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

Unified Diff: chrome/browser/chromeos/arc/arc_session_manager_unittest.cc

Issue 2553193002: Remove explicit singletonness of ArcBridgeService part 4. (Closed)
Patch Set: Created 4 years 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/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 7403af09cf93d450cc35f63daf901471a04261de..aa2860b2e721b1282ced6cc7b62cc72407e1d551 100644
--- a/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
+++ b/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
@@ -45,12 +45,12 @@
namespace arc {
-class ArcSessionManagerTest : public testing::Test {
+class ArcSessionManagerTestBase : public testing::Test {
public:
- ArcSessionManagerTest()
+ ArcSessionManagerTestBase()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
- user_manager_enabler_(new chromeos::FakeChromeUserManager) {}
- ~ArcSessionManagerTest() override = default;
+ user_manager_enabler_(new chromeos::FakeChromeUserManager()) {}
+ ~ArcSessionManagerTestBase() override = default;
void SetUp() override {
chromeos::DBusThreadManager::Initialize();
@@ -61,6 +61,7 @@ class ArcSessionManagerTest : public testing::Test {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
TestingProfile::Builder profile_builder;
+ profile_builder.SetProfileName("user@gmail.com");
profile_builder.SetPath(temp_dir_.GetPath().AppendASCII("TestArcProfile"));
profile_ = profile_builder.Build();
@@ -73,11 +74,6 @@ class ArcSessionManagerTest : public testing::Test {
EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get());
EXPECT_TRUE(ArcBridgeService::Get()->stopped());
- const AccountId account_id(
- AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890"));
- GetFakeUserManager()->AddUser(account_id);
- GetFakeUserManager()->LoginUser(account_id);
-
chromeos::WallpaperManager::Initialize();
}
@@ -102,11 +98,10 @@ class ArcSessionManagerTest : public testing::Test {
void StartPreferenceSyncing() const {
PrefServiceSyncableFromProfile(profile_.get())
->GetSyncableService(syncer::PREFERENCES)
- ->MergeDataAndStartSyncing(syncer::PREFERENCES, syncer::SyncDataList(),
- std::unique_ptr<syncer::SyncChangeProcessor>(
- new syncer::FakeSyncChangeProcessor),
- std::unique_ptr<syncer::SyncErrorFactory>(
- new syncer::SyncErrorFactoryMock()));
+ ->MergeDataAndStartSyncing(
+ syncer::PREFERENCES, syncer::SyncDataList(),
+ base::MakeUnique<syncer::FakeSyncChangeProcessor>(),
+ base::MakeUnique<syncer::SyncErrorFactoryMock>());
}
content::TestBrowserThreadBundle thread_bundle_;
@@ -116,6 +111,23 @@ class ArcSessionManagerTest : public testing::Test {
chromeos::ScopedUserManagerEnabler user_manager_enabler_;
base::ScopedTempDir temp_dir_;
+ DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase);
+};
+
+class ArcSessionManagerTest : public ArcSessionManagerTestBase {
+ public:
+ ArcSessionManagerTest() = default;
+
+ void SetUp() override {
+ ArcSessionManagerTestBase::SetUp();
+
+ const AccountId account_id(AccountId::FromUserEmailGaiaId(
+ profile()->GetProfileUserName(), "1234567890"));
+ GetFakeUserManager()->AddUser(account_id);
+ GetFakeUserManager()->LoginUser(account_id);
+ }
+
+ private:
DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTest);
};
@@ -377,4 +389,37 @@ TEST_F(ArcSessionManagerTest, DisabledForNonPrimaryProfile) {
arc_session_manager()->Shutdown();
}
+class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase {
+ public:
+ ArcSessionManagerKioskTest() = default;
+
+ void SetUp() override {
+ ArcSessionManagerTestBase::SetUp();
+ const AccountId account_id(
+ AccountId::FromUserEmail(profile()->GetProfileUserName()));
+ GetFakeUserManager()->AddArcKioskAppUser(account_id);
+ GetFakeUserManager()->LoginUser(account_id);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerKioskTest);
+};
+
+TEST_F(ArcSessionManagerKioskTest, AuthFailure) {
+ profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
+ arc_session_manager()->OnPrimaryUserProfilePrepared(profile());
+ EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
+
+ // Replace chrome::AttemptUserExit() for testing.
+ // At the end of test, we leave the dangling pointer |terminated|,
Luis Héctor Chávez 2016/12/06 19:08:56 I don't understand this comment. You are calling E
hidehiko 2016/12/08 14:29:33 The attempt_user_exit_callback_ in ArcSessionManag
+ // assuming the callback will never be called.
+ bool terminated = false;
+ arc_session_manager()->SetAttemptUserExitCallbackForTesting(
+ base::Bind([](bool* terminated) { *terminated = true; }, &terminated));
+
+ arc_session_manager()->OnProvisioningFinished(
+ ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
+ EXPECT_TRUE(terminated);
+}
+
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698