Fix user_manager_unittest to not break profile_manager_unittest
user_manager_unittest.cc changes g_current_session_type via
UserSessionManager.
Make it change it back at the end of each test.
Bug: 1224618
Test: Manually ran unit test single-threaded, see bug.
Change-Id: Ia3b5573375d20b1d8548a83eec3f70ea8751914d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2993035
Reviewed-by: Pavol Marko <pmarko@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/master@{#897666}
diff --git a/chrome/browser/ash/login/users/user_manager_unittest.cc b/chrome/browser/ash/login/users/user_manager_unittest.cc
index b093e461..dbae321 100644
--- a/chrome/browser/ash/login/users/user_manager_unittest.cc
+++ b/chrome/browser/ash/login/users/user_manager_unittest.cc
@@ -36,6 +36,8 @@
#include "components/user_manager/user_manager.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_task_environment.h"
+#include "extensions/common/features/feature_session_type.h"
+#include "extensions/common/mojom/feature_session_type.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -76,7 +78,10 @@
class UserManagerTest : public testing::Test {
public:
- UserManagerTest() {}
+ UserManagerTest() {
+ session_type_ = extensions::ScopedCurrentFeatureSessionType(
+ extensions::GetCurrentFeatureSessionType());
+ }
protected:
void SetUp() override {
@@ -180,6 +185,18 @@
AccountId::FromUserEmailGaiaId("user1@invalid.domain", "9012345678");
protected:
+ // The call chain
+ // - `ProfileRequiresPolicyUnknown`
+ // - `UserManagerBase::UserLoggedIn()`
+ // - `ChromeUserManagerImpl::NotifyOnLogin()`
+ // - `UserSessionManager::InitNonKioskExtensionFeaturesSessionType()`
+ // calls
+ // `extensions::SetCurrentFeatureSessionType(FeatureSessionType::kRegular)`
+ //
+ // |session_type_| is used to capture the original session type during |SetUp|
+ // and set it back to what it was during |TearDown|.
+ std::unique_ptr<base::AutoReset<extensions::mojom::FeatureSessionType>>
+ session_type_;
std::unique_ptr<WallpaperControllerClientImpl> wallpaper_controller_client_;
TestWallpaperController test_wallpaper_controller_;