Chromium Code Reviews| Index: chromeos/login/scoped_test_public_session_login_state.cc |
| diff --git a/chromeos/login/scoped_test_public_session_login_state.cc b/chromeos/login/scoped_test_public_session_login_state.cc |
| index 0067ebcf7a724b30118e79f44946296f093c587c..7ec7e36bccf4776376072cde5f9926dda68ee143 100644 |
| --- a/chromeos/login/scoped_test_public_session_login_state.cc |
| +++ b/chromeos/login/scoped_test_public_session_login_state.cc |
| @@ -10,15 +10,20 @@ namespace chromeos { |
| ScopedTestPublicSessionLoginState::ScopedTestPublicSessionLoginState() { |
| // Set Public Session state. |
| - chromeos::LoginState::Initialize(); |
| - chromeos::LoginState::Get()->SetLoggedInState( |
| - chromeos::LoginState::LOGGED_IN_ACTIVE, |
| - chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); |
| + if (!LoginState::IsInitialized()) { |
| + LoginState::Initialize(); |
| + needs_shutdown_ = true; |
|
Devlin
2017/05/04 18:03:17
It might be worth noting (in the class comments in
|
| + } |
| + LoginState::Get()->SetLoggedInState( |
| + LoginState::LOGGED_IN_ACTIVE, |
| + LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); |
| } |
| ScopedTestPublicSessionLoginState::~ScopedTestPublicSessionLoginState() { |
| // Reset state at the end of test. |
| - chromeos::LoginState::Shutdown(); |
| + if (needs_shutdown_) { |
| + LoginState::Shutdown(); |
| + } |
| } |
| } // namespace chromeos |