OLD | NEW |
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "google_apis/gaia/gaia_constants.h" | 36 #include "google_apis/gaia/gaia_constants.h" |
37 #include "google_apis/gaia/gaia_urls.h" | 37 #include "google_apis/gaia/gaia_urls.h" |
38 #include "net/url_request/test_url_fetcher_factory.h" | 38 #include "net/url_request/test_url_fetcher_factory.h" |
39 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> { | 44 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> { |
45 public: | 45 public: |
46 static KeyedService* Build(content::BrowserContext* context); | 46 static scoped_ptr<KeyedService> Build(content::BrowserContext* context); |
47 | 47 |
48 MockAccountReconcilor(ProfileOAuth2TokenService* token_service, | 48 MockAccountReconcilor(ProfileOAuth2TokenService* token_service, |
49 SigninManagerBase* signin_manager, | 49 SigninManagerBase* signin_manager, |
50 SigninClient* client, | 50 SigninClient* client, |
51 GaiaCookieManagerService* cookie_manager_service); | 51 GaiaCookieManagerService* cookie_manager_service); |
52 ~MockAccountReconcilor() override {} | 52 ~MockAccountReconcilor() override {} |
53 | 53 |
54 MOCK_METHOD1(PerformMergeAction, void(const std::string& account_id)); | 54 MOCK_METHOD1(PerformMergeAction, void(const std::string& account_id)); |
55 MOCK_METHOD0(PerformLogoutAllAccountsAction, void()); | 55 MOCK_METHOD0(PerformLogoutAllAccountsAction, void()); |
56 }; | 56 }; |
57 | 57 |
58 // static | 58 // static |
59 KeyedService* MockAccountReconcilor::Build(content::BrowserContext* context) { | 59 scoped_ptr<KeyedService> MockAccountReconcilor::Build( |
| 60 content::BrowserContext* context) { |
60 Profile* profile = Profile::FromBrowserContext(context); | 61 Profile* profile = Profile::FromBrowserContext(context); |
61 AccountReconcilor* reconcilor = new MockAccountReconcilor( | 62 scoped_ptr<AccountReconcilor> reconcilor(new MockAccountReconcilor( |
62 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 63 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
63 SigninManagerFactory::GetForProfile(profile), | 64 SigninManagerFactory::GetForProfile(profile), |
64 ChromeSigninClientFactory::GetForProfile(profile), | 65 ChromeSigninClientFactory::GetForProfile(profile), |
65 GaiaCookieManagerServiceFactory::GetForProfile(profile)); | 66 GaiaCookieManagerServiceFactory::GetForProfile(profile))); |
66 reconcilor->Initialize(false /* start_reconcile_if_tokens_available */); | 67 reconcilor->Initialize(false /* start_reconcile_if_tokens_available */); |
67 return reconcilor; | 68 return reconcilor.Pass(); |
68 } | 69 } |
69 | 70 |
70 MockAccountReconcilor::MockAccountReconcilor( | 71 MockAccountReconcilor::MockAccountReconcilor( |
71 ProfileOAuth2TokenService* token_service, | 72 ProfileOAuth2TokenService* token_service, |
72 SigninManagerBase* signin_manager, | 73 SigninManagerBase* signin_manager, |
73 SigninClient* client, | 74 SigninClient* client, |
74 GaiaCookieManagerService* cookie_manager_service) | 75 GaiaCookieManagerService* cookie_manager_service) |
75 : testing::StrictMock<AccountReconcilor>(token_service, | 76 : testing::StrictMock<AccountReconcilor>(token_service, |
76 signin_manager, | 77 signin_manager, |
77 client, | 78 client, |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 757 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
757 | 758 |
758 SimulateAddAccountToCookieCompleted(reconcilor, account_id, | 759 SimulateAddAccountToCookieCompleted(reconcilor, account_id, |
759 GoogleServiceAuthError::AuthErrorNone()); | 760 GoogleServiceAuthError::AuthErrorNone()); |
760 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 761 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
761 } | 762 } |
762 | 763 |
763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, | 764 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, |
764 AccountReconcilorTest, | 765 AccountReconcilorTest, |
765 testing::Bool()); | 766 testing::Bool()); |
OLD | NEW |