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

Side by Side Diff: chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc

Issue 635573005: Cleanup: Better constify some strings in chrome/browser/{chromeos,extensions}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, nit Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" 5 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/test/base/testing_profile_manager.h" 23 #include "chrome/test/base/testing_profile_manager.h"
24 #include "components/user_manager/user_manager.h" 24 #include "components/user_manager/user_manager.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "net/cert/x509_certificate.h" 26 #include "net/cert/x509_certificate.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 namespace chromeos { 29 namespace chromeos {
30 30
31 namespace { 31 namespace {
32 32
33 const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; 33 const char* const kUsers[] = {"a@gmail.com", "b@gmail.com" };
34 34
35 struct BehaviorTestCase { 35 struct BehaviorTestCase {
36 const char* primary; 36 const char* primary;
37 const char* secondary; 37 const char* secondary;
38 MultiProfileUserController::UserAllowedInSessionReason 38 MultiProfileUserController::UserAllowedInSessionReason
39 expected_primary_policy; 39 expected_primary_policy;
40 MultiProfileUserController::UserAllowedInSessionReason 40 MultiProfileUserController::UserAllowedInSessionReason
41 expected_secondary_allowed; 41 expected_secondary_allowed;
42 }; 42 };
43 43
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 scoped_ptr<TestingProfileManager> profile_manager_; 205 scoped_ptr<TestingProfileManager> profile_manager_;
206 FakeUserManager* fake_user_manager_; // Not owned 206 FakeUserManager* fake_user_manager_; // Not owned
207 ScopedUserManagerEnabler user_manager_enabler_; 207 ScopedUserManagerEnabler user_manager_enabler_;
208 208
209 scoped_ptr<MultiProfileUserController> controller_; 209 scoped_ptr<MultiProfileUserController> controller_;
210 210
211 std::vector<TestingProfile*> user_profiles_; 211 std::vector<TestingProfile*> user_profiles_;
212 212
213 int user_not_allowed_count_; 213 int user_not_allowed_count_;
214 214
215 private:
215 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserControllerTest); 216 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserControllerTest);
216 }; 217 };
217 218
218 // Tests that everyone is allowed before a session starts. 219 // Tests that everyone is allowed before a session starts.
219 TEST_F(MultiProfileUserControllerTest, AllAllowedBeforeLogin) { 220 TEST_F(MultiProfileUserControllerTest, AllAllowedBeforeLogin) {
220 const char* kTestCases[] = { 221 const char* const kTestCases[] = {
221 MultiProfileUserController::kBehaviorUnrestricted, 222 MultiProfileUserController::kBehaviorUnrestricted,
222 MultiProfileUserController::kBehaviorPrimaryOnly, 223 MultiProfileUserController::kBehaviorPrimaryOnly,
223 MultiProfileUserController::kBehaviorNotAllowed, 224 MultiProfileUserController::kBehaviorNotAllowed,
224 }; 225 };
225 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 226 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
226 SetCachedBehavior(0, kTestCases[i]); 227 SetCachedBehavior(0, kTestCases[i]);
227 MultiProfileUserController::UserAllowedInSessionReason reason; 228 MultiProfileUserController::UserAllowedInSessionReason reason;
228 EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason)) 229 EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason))
229 << "Case " << i; 230 << "Case " << i;
230 EXPECT_EQ(MultiProfileUserController::ALLOWED, reason) << "Case " << i; 231 EXPECT_EQ(MultiProfileUserController::ALLOWED, reason) << "Case " << i;
231 EXPECT_EQ(MultiProfileUserController::ALLOWED, 232 EXPECT_EQ(MultiProfileUserController::ALLOWED,
232 MultiProfileUserController::GetPrimaryUserPolicy()) 233 MultiProfileUserController::GetPrimaryUserPolicy())
233 << "Case " << i; 234 << "Case " << i;
234 } 235 }
235 } 236 }
236 237
237 // Tests that invalid cache value would become the default "unrestricted". 238 // Tests that invalid cache value would become the default "unrestricted".
238 TEST_F(MultiProfileUserControllerTest, InvalidCacheBecomesDefault) { 239 TEST_F(MultiProfileUserControllerTest, InvalidCacheBecomesDefault) {
239 const char kBad[] = "some invalid value"; 240 const char kBad[] = "some invalid value";
240 SetCachedBehavior(0, kBad); 241 SetCachedBehavior(0, kBad);
241 EXPECT_EQ(MultiProfileUserController::kBehaviorUnrestricted, 242 EXPECT_EQ(MultiProfileUserController::kBehaviorUnrestricted,
242 GetCachedBehavior(0)); 243 GetCachedBehavior(0));
243 } 244 }
244 245
245 // Tests that cached behavior value changes with user pref after login. 246 // Tests that cached behavior value changes with user pref after login.
246 TEST_F(MultiProfileUserControllerTest, CachedBehaviorUpdate) { 247 TEST_F(MultiProfileUserControllerTest, CachedBehaviorUpdate) {
247 LoginUser(0); 248 LoginUser(0);
248 249
249 const char* kTestCases[] = { 250 const char* const kTestCases[] = {
250 MultiProfileUserController::kBehaviorUnrestricted, 251 MultiProfileUserController::kBehaviorUnrestricted,
251 MultiProfileUserController::kBehaviorPrimaryOnly, 252 MultiProfileUserController::kBehaviorPrimaryOnly,
252 MultiProfileUserController::kBehaviorNotAllowed, 253 MultiProfileUserController::kBehaviorNotAllowed,
253 MultiProfileUserController::kBehaviorUnrestricted, 254 MultiProfileUserController::kBehaviorUnrestricted,
254 }; 255 };
255 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 256 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
256 SetPrefBehavior(0, kTestCases[i]); 257 SetPrefBehavior(0, kTestCases[i]);
257 EXPECT_EQ(kTestCases[i], GetCachedBehavior(0)); 258 EXPECT_EQ(kTestCases[i], GetCachedBehavior(0));
258 } 259 }
259 } 260 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, 438 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
438 reason); 439 reason);
439 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, 440 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
440 MultiProfileUserController::GetPrimaryUserPolicy()); 441 MultiProfileUserController::GetPrimaryUserPolicy());
441 442
442 // Flush tasks posted to IO. 443 // Flush tasks posted to IO.
443 base::RunLoop().RunUntilIdle(); 444 base::RunLoop().RunUntilIdle();
444 } 445 }
445 446
446 } // namespace chromeos 447 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698