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

Side by Side Diff: chrome/browser/signin/signin_names_io_thread_unittest.cc

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 years, 8 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 (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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/observer_list.h" 6 #include "base/observer_list.h"
7 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/browser/signin/account_tracker_service_factory.h"
11 #include "chrome/browser/signin/fake_signin_manager.h" 12 #include "chrome/browser/signin/fake_signin_manager.h"
12 #include "chrome/browser/signin/signin_names_io_thread.h" 13 #include "chrome/browser/signin/signin_names_io_thread.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "chrome/test/base/testing_profile_manager.h" 16 #include "chrome/test/base/testing_profile_manager.h"
17 #include "components/signin/core/browser/account_tracker_service.h"
16 #include "components/signin/core/browser/signin_manager.h" 18 #include "components/signin/core/browser/signin_manager.h"
17 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
18 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
19 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 23
22 class SigninNamesOnIOThreadTest : public testing::Test { 24 class SigninNamesOnIOThreadTest : public testing::Test {
23 public: 25 public:
24 SigninNamesOnIOThreadTest(); 26 SigninNamesOnIOThreadTest();
25 void SetUp() override; 27 void SetUp() override;
26 void TearDown() override; 28 void TearDown() override;
27 29
30 // Seed the account tracker with information from logged in user. Normally
31 // this is done by UI code before calling SigninManager. Returns the string
32 // to use as the account_id.
33 std::string AddToAccountTracker(const std::string& gaia_id,
34 const std::string& email);
28 void SimulateSignin(const base::string16& email); 35 void SimulateSignin(const base::string16& email);
29 void AddNewProfile(const base::string16& name, const base::string16& email); 36 void AddNewProfile(const base::string16& name, const base::string16& email);
30 37
31 base::MessageLoop message_loop_; 38 base::MessageLoop message_loop_;
32 content::TestBrowserThread ui_thread_; 39 content::TestBrowserThread ui_thread_;
33 content::TestBrowserThread io_thread_; 40 content::TestBrowserThread io_thread_;
34 scoped_ptr<TestingProfile> profile_; 41 scoped_ptr<TestingProfile> profile_;
35 FakeSigninManager* signin_manager_; 42 FakeSigninManager* signin_manager_;
36 TestingProfileManager testing_profile_manager_; 43 TestingProfileManager testing_profile_manager_;
37 SigninNamesOnIOThread signin_names_; 44 SigninNamesOnIOThread signin_names_;
(...skipping 13 matching lines...) Expand all
51 FakeSigninManagerBase::Build); 58 FakeSigninManagerBase::Build);
52 profile_ = builder.Build(); 59 profile_ = builder.Build();
53 signin_manager_ = static_cast<FakeSigninManager*>( 60 signin_manager_ = static_cast<FakeSigninManager*>(
54 SigninManagerFactory::GetForProfile(profile_.get())); 61 SigninManagerFactory::GetForProfile(profile_.get()));
55 } 62 }
56 63
57 void SigninNamesOnIOThreadTest::TearDown() { 64 void SigninNamesOnIOThreadTest::TearDown() {
58 signin_names_.ReleaseResourcesOnUIThread(); 65 signin_names_.ReleaseResourcesOnUIThread();
59 } 66 }
60 67
68 // Seed the account tracker with information from logged in user. Normally
69 // this is done by UI code before calling SigninManager. Returns the string
70 // to use as the account_id.
71 std::string SigninNamesOnIOThreadTest::AddToAccountTracker(
72 const std::string& gaia_id,
73 const std::string& email) {
74 AccountTrackerService* service =
75 AccountTrackerServiceFactory::GetForProfile(profile_.get());
76 service->SeedAccountInfo(gaia_id, email);
Mike Lerman 2015/04/08 14:45:26 Don't think this needs to be its own method (see s
Roger Tawa OOO till Jul 10th 2015/04/08 20:24:20 Done.
77 return service->PickAccountIdForAccount(gaia_id, email);
78 }
79
61 void SigninNamesOnIOThreadTest::SimulateSignin(const base::string16& email) { 80 void SigninNamesOnIOThreadTest::SimulateSignin(const base::string16& email) {
62 signin_manager_->SignIn(base::UTF16ToUTF8(email), "password"); 81 std::string email_str = base::UTF16ToUTF8(email);
82 AddToAccountTracker("gaia_id", email_str);
Mike Lerman 2015/04/08 14:45:26 Similarly to signin_tracker_unittest. Why not just
Roger Tawa OOO till Jul 10th 2015/04/08 20:24:20 Return value not used. Put code inline here since
83 signin_manager_->SignIn("gaia_id", email_str, "password");
63 } 84 }
64 85
65 void SigninNamesOnIOThreadTest::AddNewProfile(const base::string16& name, 86 void SigninNamesOnIOThreadTest::AddNewProfile(const base::string16& name,
66 const base::string16& email) { 87 const base::string16& email) {
67 ProfileInfoCache* cache = testing_profile_manager_.profile_info_cache(); 88 ProfileInfoCache* cache = testing_profile_manager_.profile_info_cache();
68 const base::FilePath& user_data_dir = cache->GetUserDataDir(); 89 const base::FilePath& user_data_dir = cache->GetUserDataDir();
69 #if defined(OS_POSIX) 90 #if defined(OS_POSIX)
70 const base::FilePath profile_dir = 91 const base::FilePath profile_dir =
71 user_data_dir.Append(base::UTF16ToUTF8(name)); 92 user_data_dir.Append(base::UTF16ToUTF8(name));
72 #else 93 #else
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 128
108 SigninNamesOnIOThread signin_names; 129 SigninNamesOnIOThread signin_names;
109 130
110 const SigninNamesOnIOThread::EmailSet& emails = signin_names.GetEmails(); 131 const SigninNamesOnIOThread::EmailSet& emails = signin_names.GetEmails();
111 ASSERT_EQ(2u, emails.size()); 132 ASSERT_EQ(2u, emails.size());
112 ASSERT_EQ(1u, emails.count(email1)); 133 ASSERT_EQ(1u, emails.count(email1));
113 ASSERT_EQ(1u, emails.count(email2)); 134 ASSERT_EQ(1u, emails.count(email2));
114 135
115 signin_names.ReleaseResourcesOnUIThread(); 136 signin_names.ReleaseResourcesOnUIThread();
116 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698