Fixed problem with leaving FeatureSessionType set between test invocations.
Bug: 760940
Change-Id: I73ebaee4a21bcfa745e87b7783349334f48ba144
Reviewed-on: https://chromium-review.googlesource.com/645635
Reviewed-by: Bernhard Bauer <[email protected]>
Commit-Queue: Drew Wilson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#499192}
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 92d0f64..b795da2c 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -60,6 +60,7 @@
#include "chromeos/chromeos_switches.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_names.h"
+#include "extensions/common/features/feature_session_type.h"
#endif // defined(OS_CHROMEOS)
using base::ASCIIToUTF16;
@@ -141,6 +142,13 @@
base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
cl->AppendSwitch(switches::kTestType);
chromeos::WallpaperManager::Initialize();
+
+ // Have to manually reset the session type in between test runs because
+ // some tests log in users.
+ ASSERT_EQ(extensions::FeatureSessionType::INITIAL,
+ extensions::GetCurrentFeatureSessionType());
+ session_type_ = extensions::ScopedCurrentFeatureSessionType(
+ extensions::GetCurrentFeatureSessionType());
#endif
}
@@ -148,6 +156,7 @@
TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
content::RunAllBlockingPoolTasksUntilIdle();
#if defined(OS_CHROMEOS)
+ session_type_.reset();
chromeos::WallpaperManager::Shutdown();
#endif
}
@@ -220,6 +229,8 @@
#if defined(OS_CHROMEOS)
chromeos::ScopedTestUserManager test_user_manager_;
+ std::unique_ptr<base::AutoReset<extensions::FeatureSessionType>>
+ session_type_;
#endif
DISALLOW_COPY_AND_ASSIGN(ProfileManagerTest);
@@ -582,6 +593,13 @@
cl->AppendSwitch(::switches::kIncognito);
chromeos::WallpaperManager::Initialize();
+ // Have to manually reset the session type in between test runs because
+ // RegisterUser() changes it.
+ ASSERT_EQ(extensions::FeatureSessionType::INITIAL,
+ extensions::GetCurrentFeatureSessionType());
+ session_type_ = extensions::ScopedCurrentFeatureSessionType(
+ extensions::GetCurrentFeatureSessionType());
+
RegisterUser(user_manager::kGuestUserName);
#endif
}