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

Unified Diff: chromeos/login/login_state_unittest.cc

Issue 23444061: Test that LoginState observer triggers when only user type changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a spelling error Created 7 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/login/login_state_unittest.cc
diff --git a/chromeos/login/login_state_unittest.cc b/chromeos/login/login_state_unittest.cc
index d71b9d53fd681b8eebb709d2d0c33cf4f49b66ba..405400762bfdc8c3b4bace7563361cd07358c9e7 100644
--- a/chromeos/login/login_state_unittest.cc
+++ b/chromeos/login/login_state_unittest.cc
@@ -6,9 +6,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
#include "chromeos/chromeos_switches.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
@@ -25,8 +23,6 @@ class LoginStateTest : public testing::Test,
// testing::Test
virtual void SetUp() OVERRIDE {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kLoginManager);
- // Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
LoginState::Initialize();
LoginState::Get()->AddObserver(this);
}
@@ -34,7 +30,6 @@ class LoginStateTest : public testing::Test,
virtual void TearDown() OVERRIDE {
LoginState::Get()->RemoveObserver(this);
LoginState::Shutdown();
- DBusThreadManager::Shutdown();
}
// LoginState::Observer
@@ -52,7 +47,6 @@ class LoginStateTest : public testing::Test,
return result;
}
- base::MessageLoopForUI message_loop_;
LoginState::LoggedInUserType logged_in_user_type_;
private:
@@ -76,8 +70,6 @@ TEST_F(LoginStateTest, TestLoginState) {
EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
EXPECT_FALSE(LoginState::Get()->IsInSafeMode());
- // Run the message loop, observer should update members.
- message_loop_.RunUntilIdle();
EXPECT_EQ(1U, GetNewLoginStateChangesCount());
EXPECT_EQ(LoginState::LOGGED_IN_USER_REGULAR, logged_in_user_type_);
}
@@ -96,8 +88,6 @@ TEST_F(LoginStateTest, TestSafeModeLoginState) {
EXPECT_FALSE(LoginState::Get()->IsUserLoggedIn());
EXPECT_TRUE(LoginState::Get()->IsInSafeMode());
- // Run the message loop, observer should update members.
- message_loop_.RunUntilIdle();
EXPECT_EQ(1U, GetNewLoginStateChangesCount());
EXPECT_EQ(LoginState::LOGGED_IN_USER_NONE, logged_in_user_type_);
@@ -109,10 +99,29 @@ TEST_F(LoginStateTest, TestSafeModeLoginState) {
EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
EXPECT_FALSE(LoginState::Get()->IsInSafeMode());
- // Run the message loop, observer should update members.
- message_loop_.RunUntilIdle();
EXPECT_EQ(1U, GetNewLoginStateChangesCount());
EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER, logged_in_user_type_);
}
+TEST_F(LoginStateTest, TestLoggedInStateChangedObserverOnUserTypeChange) {
+ LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
+ LoginState::LOGGED_IN_USER_REGULAR);
+
+ EXPECT_EQ(1u, GetNewLoginStateChangesCount());
+ EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
+ EXPECT_EQ(LoginState::LOGGED_IN_USER_REGULAR, logged_in_user_type_);
+ EXPECT_EQ(LoginState::LOGGED_IN_USER_REGULAR,
+ LoginState::Get()->GetLoggedInUserType());
+
+ // Change the user type, without changing the logged in state.
+ LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
+ LoginState::LOGGED_IN_USER_OWNER);
+
+ EXPECT_EQ(1u, GetNewLoginStateChangesCount());
+ EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
+ EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER, logged_in_user_type_);
+ EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER,
+ LoginState::Get()->GetLoggedInUserType());
+}
+
} // namespace chromeos
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698