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

Side by Side Diff: chrome/browser/profiles/profile_attributes_storage_unittest.cc

Issue 2928823003: Make it possible to build without enable_supervised_users.
Patch Set: Does it still compile with the feature enabled? Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_set> 7 #include <unordered_set>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
13 #include "chrome/browser/profiles/profile_info_cache.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/signin/signin_util.h" 15 #include "chrome/browser/signin/signin_util.h"
16 #include "chrome/browser/supervised_user/supervised_user_constants.h" 16 #include "chrome/browser/supervised_user/supervised_user_constants.h"
17 #include "chrome/common/features.h"
17 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 using ::testing::Mock; 24 using ::testing::Mock;
24 using ::testing::_; 25 using ::testing::_;
25 26
26 namespace { 27 namespace {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 ASSERT_FALSE(entry->IsAuthenticated()); 281 ASSERT_FALSE(entry->IsAuthenticated());
281 EXPECT_EQ(base::string16(), entry->GetUserName()); 282 EXPECT_EQ(base::string16(), entry->GetUserName());
282 EXPECT_EQ("", entry->GetGAIAId()); 283 EXPECT_EQ("", entry->GetGAIAId());
283 284
284 entry->SetAuthInfo("foo", base::ASCIIToUTF16("bar")); 285 entry->SetAuthInfo("foo", base::ASCIIToUTF16("bar"));
285 ASSERT_TRUE(entry->IsAuthenticated()); 286 ASSERT_TRUE(entry->IsAuthenticated());
286 EXPECT_EQ(base::ASCIIToUTF16("bar"), entry->GetUserName()); 287 EXPECT_EQ(base::ASCIIToUTF16("bar"), entry->GetUserName());
287 EXPECT_EQ("foo", entry->GetGAIAId()); 288 EXPECT_EQ("foo", entry->GetGAIAId());
288 } 289 }
289 290
291 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
290 TEST_F(ProfileAttributesStorageTest, SupervisedUsersAccessors) { 292 TEST_F(ProfileAttributesStorageTest, SupervisedUsersAccessors) {
291 AddTestingProfile(); 293 AddTestingProfile();
292 294
293 ProfileAttributesEntry* entry; 295 ProfileAttributesEntry* entry;
294 ASSERT_TRUE(storage()->GetProfileAttributesWithPath( 296 ASSERT_TRUE(storage()->GetProfileAttributesWithPath(
295 GetProfilePath("testing_profile_path0"), &entry)); 297 GetProfilePath("testing_profile_path0"), &entry));
296 298
297 entry->SetSupervisedUserId(""); 299 entry->SetSupervisedUserId("");
298 ASSERT_FALSE(entry->IsSupervised()); 300 ASSERT_FALSE(entry->IsSupervised());
299 ASSERT_FALSE(entry->IsChild()); 301 ASSERT_FALSE(entry->IsChild());
300 ASSERT_FALSE(entry->IsLegacySupervised()); 302 ASSERT_FALSE(entry->IsLegacySupervised());
301 303
302 entry->SetSupervisedUserId("some_supervised_user_id"); 304 entry->SetSupervisedUserId("some_supervised_user_id");
303 ASSERT_TRUE(entry->IsSupervised()); 305 ASSERT_TRUE(entry->IsSupervised());
304 ASSERT_FALSE(entry->IsChild()); 306 ASSERT_FALSE(entry->IsChild());
305 ASSERT_TRUE(entry->IsLegacySupervised()); 307 ASSERT_TRUE(entry->IsLegacySupervised());
306 308
307 entry->SetSupervisedUserId(supervised_users::kChildAccountSUID); 309 entry->SetSupervisedUserId(supervised_users::kChildAccountSUID);
308 ASSERT_TRUE(entry->IsSupervised()); 310 ASSERT_TRUE(entry->IsSupervised());
309 ASSERT_TRUE(entry->IsChild()); 311 ASSERT_TRUE(entry->IsChild());
310 ASSERT_FALSE(entry->IsLegacySupervised()); 312 ASSERT_FALSE(entry->IsLegacySupervised());
311 } 313 }
314 #endif
312 315
313 TEST_F(ProfileAttributesStorageTest, ReSortTriggered) { 316 TEST_F(ProfileAttributesStorageTest, ReSortTriggered) {
314 storage()->AddProfile(GetProfilePath("alpha_path"), 317 storage()->AddProfile(GetProfilePath("alpha_path"),
315 base::ASCIIToUTF16("alpha"), 318 base::ASCIIToUTF16("alpha"),
316 std::string("alpha_gaia"), 319 std::string("alpha_gaia"),
317 base::ASCIIToUTF16("alpha_username"), 320 base::ASCIIToUTF16("alpha_username"),
318 1, 321 1,
319 std::string("")); 322 std::string(""));
320 323
321 storage()->AddProfile(GetProfilePath("lima_path"), 324 storage()->AddProfile(GetProfilePath("lima_path"),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1); 466 EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1);
464 entry->LockForceSigninProfile(true); 467 entry->LockForceSigninProfile(true);
465 ASSERT_TRUE(entry->IsSigninRequired()); 468 ASSERT_TRUE(entry->IsSigninRequired());
466 Mock::VerifyAndClear(&observer); 469 Mock::VerifyAndClear(&observer);
467 470
468 EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1); 471 EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1);
469 entry->SetIsSigninRequired(false); 472 entry->SetIsSigninRequired(false);
470 ASSERT_FALSE(entry->IsSigninRequired()); 473 ASSERT_FALSE(entry->IsSigninRequired());
471 Mock::VerifyAndClear(&observer); 474 Mock::VerifyAndClear(&observer);
472 } 475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698