Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc b/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc |
| index e8f90f171ad1fc1adbed7f77392209d89ec88bbf..4b8d6c51db677fe831591e2c25375293d00ab5e2 100644 |
| --- a/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc |
| +++ b/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc |
| @@ -176,6 +176,12 @@ class ArcSessionManagerTest : public InProcessBrowserTest { |
| user_manager::UserManager::Get()); |
| } |
| + void EnableArc() { |
| + PrefService* const prefs = profile()->GetPrefs(); |
| + prefs->SetBoolean(prefs::kArcEnabled, true); |
| + base::RunLoop().RunUntilIdle(); |
| + } |
| + |
| void set_profile_name(const std::string& username) { |
| profile_->set_profile_name(username); |
| } |
| @@ -195,8 +201,7 @@ class ArcSessionManagerTest : public InProcessBrowserTest { |
| }; |
| IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ConsumerAccount) { |
| - PrefService* const prefs = profile()->GetPrefs(); |
| - prefs->SetBoolean(prefs::kArcEnabled, true); |
| + EnableArc(); |
| token_service()->IssueTokenForAllPendingRequests(kUnmanagedAuthToken, |
| base::Time::Max()); |
| ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| @@ -205,9 +210,7 @@ IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ConsumerAccount) { |
| IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, WellKnownConsumerAccount) { |
| set_profile_name(kWellKnownConsumerName); |
| - PrefService* const prefs = profile()->GetPrefs(); |
| - |
| - prefs->SetBoolean(prefs::kArcEnabled, true); |
| + EnableArc(); |
| ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| ArcSessionManager::Get()->state()); |
| } |
| @@ -217,17 +220,13 @@ IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ManagedChromeAccount) { |
| policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile()); |
| connector->OverrideIsManagedForTesting(true); |
| - PrefService* const pref = profile()->GetPrefs(); |
| - |
| - pref->SetBoolean(prefs::kArcEnabled, true); |
| + EnableArc(); |
| ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| ArcSessionManager::Get()->state()); |
| } |
| IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ManagedAndroidAccount) { |
| - PrefService* const prefs = profile()->GetPrefs(); |
| - |
| - prefs->SetBoolean(prefs::kArcEnabled, true); |
| + EnableArc(); |
| token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken, |
| base::Time::Max()); |
| ArcSessionManagerShutdownObserver observer; |
| @@ -236,4 +235,38 @@ IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ManagedAndroidAccount) { |
| ArcSessionManager::Get()->state()); |
| } |
| +IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, RemoveDataFolder) { |
|
hidehiko
2016/12/01 16:15:03
Could you move this into unittest, instead of brow
khmel
2016/12/01 17:18:59
Done.
|
| + EnableArc(); |
| + ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| + ArcSessionManager::Get()->state()); |
| + EXPECT_FALSE( |
| + profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| + |
| + // Request to remove data folder and close session immediately. |
| + ArcSessionManager::Get()->RemoveArcData(); |
| + ASSERT_TRUE( |
| + profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| + ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| + ArcSessionManager::Get()->state()); |
| + ArcSessionManager::Get()->Shutdown(); |
| + base::RunLoop().RunUntilIdle(); |
| + // Request to remove data is still active. |
| + ASSERT_TRUE( |
| + profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| + |
| + ArcServiceLauncher::Get()->OnPrimaryUserProfilePrepared(profile()); |
| + // Data removal request is in progress. |
| + ASSERT_EQ(ArcSessionManager::State::STOPPED, |
| + ArcSessionManager::Get()->state()); |
| + ASSERT_TRUE( |
| + profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| + base::RunLoop().RunUntilIdle(); |
| + // After remove Arc is started. |
|
hidehiko
2016/12/01 16:15:03
nit: s/Arc/ARC/ for consistency.
khmel
2016/12/01 17:18:59
Done.
|
| + ASSERT_EQ(ArcSessionManager::State::ACTIVE, |
| + ArcSessionManager::Get()->state()); |
| + ASSERT_FALSE( |
| + profile()->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| + ArcSessionManager::Get()->Shutdown(); |
| +} |
| + |
| } // namespace arc |