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

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

Issue 2553193002: Remove explicit singletonness of ArcBridgeService part 4. (Closed)
Patch Set: Address comments. 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 98b7e135f7c278cf2b97582f2ad00a88ae360e3f..f28109a490f1fca7f421afc7bee826f0c1481c35 100644
--- a/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
+++ b/chrome/browser/chromeos/arc/arc_session_manager_unittest.cc
@@ -46,12 +46,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::GetSetterForTesting()->SetSessionManagerClient(
@@ -65,6 +65,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();
@@ -77,11 +78,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();
}
@@ -118,11 +114,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_;
@@ -132,6 +127,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);
};
@@ -476,4 +488,37 @@ TEST_F(ArcSessionManagerTest, IgnoreSecondErrorReporting) {
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, leave the dangling pointer |terminated|,
+ // assuming the callback will never be called.
Luis Héctor Chávez 2016/12/08 17:36:13 I'm still a bit confused by this. If I understand
hidehiko 2016/12/08 18:01:00 Oh, I see your point, I believe. Updated the comme
Luis Héctor Chávez 2016/12/08 18:04:01 No need, the reworded comment is enough.
+ 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