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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_sync_starter_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/sync/one_click_signin_sync_starter.h" 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.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_manager_factory.h" 13 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "components/signin/core/browser/account_tracker_service.h"
16 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 22
21 namespace { 23 namespace {
24
25 const char* kTestingGaiaId = "gaia_id";
22 const char* kTestingUsername = "fake_username"; 26 const char* kTestingUsername = "fake_username";
27
23 } // namespace 28 } // namespace
24 29
25 class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness { 30 class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness {
26 public: 31 public:
27 OneClickSigninSyncStarterTest() 32 OneClickSigninSyncStarterTest()
28 : sync_starter_(NULL), 33 : sync_starter_(NULL),
29 failed_count_(0), 34 failed_count_(0),
30 succeeded_count_(0) {} 35 succeeded_count_(0) {}
31 36
32 // ChromeRenderViewHostTestHarness: 37 // ChromeRenderViewHostTestHarness:
33 void SetUp() override { 38 void SetUp() override {
34 ChromeRenderViewHostTestHarness::SetUp(); 39 ChromeRenderViewHostTestHarness::SetUp();
35 40
36 // Disable sync to simplify the creation of a OneClickSigninSyncStarter. 41 // Disable sync to simplify the creation of a OneClickSigninSyncStarter.
37 base::CommandLine::ForCurrentProcess()->AppendSwitch( 42 base::CommandLine::ForCurrentProcess()->AppendSwitch(
38 switches::kDisableSync); 43 switches::kDisableSync);
39 44
40 SigninManagerBase* signin_manager = static_cast<FakeSigninManager*>( 45 SigninManagerBase* signin_manager = static_cast<FakeSigninManager*>(
41 SigninManagerFactory::GetForProfile(profile())); 46 SigninManagerFactory::GetForProfile(profile()));
42 47
43 signin_manager->Initialize(NULL); 48 signin_manager->Initialize(NULL);
44 signin_manager->SetAuthenticatedUsername(kTestingUsername); 49 signin_manager->SetAuthenticatedAccountInfo(kTestingGaiaId,
50 kTestingUsername);
45 } 51 }
46 52
47 void Callback(OneClickSigninSyncStarter::SyncSetupResult result) { 53 void Callback(OneClickSigninSyncStarter::SyncSetupResult result) {
48 if (result == OneClickSigninSyncStarter::SYNC_SETUP_SUCCESS) 54 if (result == OneClickSigninSyncStarter::SYNC_SETUP_SUCCESS)
49 ++succeeded_count_; 55 ++succeeded_count_;
50 else 56 else
51 ++failed_count_; 57 ++failed_count_;
52 } 58 }
53 59
54 // ChromeRenderViewHostTestHarness: 60 // ChromeRenderViewHostTestHarness:
55 content::BrowserContext* CreateBrowserContext() override { 61 content::BrowserContext* CreateBrowserContext() override {
56 // Create the sign in manager required by OneClickSigninSyncStarter. 62 // Create the sign in manager required by OneClickSigninSyncStarter.
57 TestingProfile::Builder builder; 63 TestingProfile::Builder builder;
58 builder.AddTestingFactory( 64 builder.AddTestingFactory(
59 SigninManagerFactory::GetInstance(), 65 SigninManagerFactory::GetInstance(),
60 &OneClickSigninSyncStarterTest::BuildSigninManager); 66 &OneClickSigninSyncStarterTest::BuildSigninManager);
61 return builder.Build().release(); 67 return builder.Build().release();
62 } 68 }
63 69
64 protected: 70 protected:
65 void CreateSyncStarter(OneClickSigninSyncStarter::Callback callback, 71 void CreateSyncStarter(OneClickSigninSyncStarter::Callback callback,
66 const GURL& continue_url) { 72 const GURL& continue_url) {
67 sync_starter_ = new OneClickSigninSyncStarter( 73 sync_starter_ = new OneClickSigninSyncStarter(
68 profile(), 74 profile(),
69 NULL, 75 NULL,
76 kTestingGaiaId,
70 kTestingUsername, 77 kTestingUsername,
71 std::string(), 78 std::string(),
72 "refresh_token", 79 "refresh_token",
73 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, 80 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS,
74 web_contents(), 81 web_contents(),
75 OneClickSigninSyncStarter::NO_CONFIRMATION, 82 OneClickSigninSyncStarter::NO_CONFIRMATION,
76 continue_url, 83 continue_url,
77 callback); 84 callback);
78 } 85 }
79 86
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 128
122 const GURL kTestURL = GURL("http://www.example.com"); 129 const GURL kTestURL = GURL("http://www.example.com");
123 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, 130 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback,
124 base::Unretained(this)), 131 base::Unretained(this)),
125 kTestURL); 132 kTestURL);
126 sync_starter_->MergeSessionComplete( 133 sync_starter_->MergeSessionComplete(
127 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); 134 GoogleServiceAuthError(GoogleServiceAuthError::NONE));
128 EXPECT_EQ(1, succeeded_count_); 135 EXPECT_EQ(1, succeeded_count_);
129 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); 136 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL());
130 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698