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

Side by Side Diff: chromeos/login/login_state_unittest.cc

Issue 242983004: Disable some API calls in networkingPrivate for non-primary user (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/login/login_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/login/login_state.h" 5 #include "chromeos/login/login_state.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "chromeos/chromeos_switches.h" 9 #include "chromeos/chromeos_switches.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace {
13 const char kTestUserHash[] = "testuserhash";
14 } // namespace
15
12 namespace chromeos { 16 namespace chromeos {
13 17
14 class LoginStateTest : public testing::Test, 18 class LoginStateTest : public testing::Test,
15 public LoginState::Observer { 19 public LoginState::Observer {
16 public: 20 public:
17 LoginStateTest() : logged_in_user_type_(LoginState::LOGGED_IN_USER_NONE), 21 LoginStateTest() : logged_in_user_type_(LoginState::LOGGED_IN_USER_NONE),
18 login_state_changes_count_(0) { 22 login_state_changes_count_(0) {
19 } 23 }
20 virtual ~LoginStateTest() { 24 virtual ~LoginStateTest() {
21 } 25 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE, 121 LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
118 LoginState::LOGGED_IN_USER_OWNER); 122 LoginState::LOGGED_IN_USER_OWNER);
119 123
120 EXPECT_EQ(1u, GetNewLoginStateChangesCount()); 124 EXPECT_EQ(1u, GetNewLoginStateChangesCount());
121 EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn()); 125 EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
122 EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER, logged_in_user_type_); 126 EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER, logged_in_user_type_);
123 EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER, 127 EXPECT_EQ(LoginState::LOGGED_IN_USER_OWNER,
124 LoginState::Get()->GetLoggedInUserType()); 128 LoginState::Get()->GetLoggedInUserType());
125 } 129 }
126 130
131 TEST_F(LoginStateTest, TestPrimaryUser) {
132 EXPECT_FALSE(LoginState::Get()->IsUserLoggedIn());
133 EXPECT_FALSE(LoginState::Get()->IsInSafeMode());
134 EXPECT_EQ(LoginState::LOGGED_IN_USER_NONE, logged_in_user_type_);
135 EXPECT_EQ(LoginState::LOGGED_IN_USER_NONE,
136 LoginState::Get()->GetLoggedInUserType());
137
138 // Setting login state to ACTIVE and setting the primary user.
139 LoginState::Get()->SetLoggedInStateAndPrimaryUser(
140 LoginState::LOGGED_IN_ACTIVE,
141 LoginState::LOGGED_IN_USER_REGULAR,
142 kTestUserHash);
143 EXPECT_EQ(LoginState::LOGGED_IN_USER_REGULAR,
144 LoginState::Get()->GetLoggedInUserType());
145 EXPECT_TRUE(LoginState::Get()->IsUserLoggedIn());
146 EXPECT_FALSE(LoginState::Get()->IsInSafeMode());
147 EXPECT_EQ(kTestUserHash, LoginState::Get()->primary_user_hash());
148
149 EXPECT_EQ(1U, GetNewLoginStateChangesCount());
150 EXPECT_EQ(LoginState::LOGGED_IN_USER_REGULAR, logged_in_user_type_);
151 }
152
127 } // namespace chromeos 153 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/login_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698