OLD | NEW |
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 <set> | 5 #include <set> |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/signin/fake_signin_manager.h" | 9 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
10 #include "chrome/browser/signin/signin_error_controller_factory.h" | 11 #include "chrome/browser/signin/signin_error_controller_factory.h" |
11 #include "chrome/browser/sync/profile_sync_service_mock.h" | 12 #include "chrome/browser/sync/profile_sync_service_mock.h" |
12 #include "chrome/browser/sync/sync_ui_util.h" | 13 #include "chrome/browser/sync/sync_ui_util.h" |
13 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
14 #include "components/signin/core/browser/fake_auth_status_provider.h" | 15 #include "components/signin/core/browser/fake_auth_status_provider.h" |
| 16 #include "components/signin/core/browser/fake_signin_manager.h" |
15 #include "components/signin/core/browser/signin_manager.h" | 17 #include "components/signin/core/browser/signin_manager.h" |
16 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "testing/gmock/include/gmock/gmock-actions.h" | 20 #include "testing/gmock/include/gmock/gmock-actions.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 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
22 | 24 |
23 using ::testing::AtMost; | 25 using ::testing::AtMost; |
24 using ::testing::NiceMock; | 26 using ::testing::NiceMock; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 GoogleServiceAuthError::CONNECTION_FAILED, | 147 GoogleServiceAuthError::CONNECTION_FAILED, |
146 GoogleServiceAuthError::CAPTCHA_REQUIRED, | 148 GoogleServiceAuthError::CAPTCHA_REQUIRED, |
147 GoogleServiceAuthError::ACCOUNT_DELETED, | 149 GoogleServiceAuthError::ACCOUNT_DELETED, |
148 GoogleServiceAuthError::ACCOUNT_DISABLED, | 150 GoogleServiceAuthError::ACCOUNT_DISABLED, |
149 GoogleServiceAuthError::SERVICE_UNAVAILABLE, | 151 GoogleServiceAuthError::SERVICE_UNAVAILABLE, |
150 GoogleServiceAuthError::TWO_FACTOR, | 152 GoogleServiceAuthError::TWO_FACTOR, |
151 GoogleServiceAuthError::REQUEST_CANCELED, | 153 GoogleServiceAuthError::REQUEST_CANCELED, |
152 GoogleServiceAuthError::HOSTED_NOT_ALLOWED | 154 GoogleServiceAuthError::HOSTED_NOT_ALLOWED |
153 }; | 155 }; |
154 | 156 |
155 FakeSigninManagerBase signin(profile.get()); | 157 FakeSigninManagerBase signin( |
| 158 ChromeSigninClientFactory::GetForProfile(profile.get()), |
| 159 AccountTrackerServiceFactory::GetForProfile(profile.get())); |
156 for (size_t i = 0; i < arraysize(table); ++i) { | 160 for (size_t i = 0; i < arraysize(table); ++i) { |
157 VerifySyncGlobalErrorResult(&service, | 161 VerifySyncGlobalErrorResult(&service, |
158 table[i], | 162 table[i], |
159 true /* signed in */, | 163 true /* signed in */, |
160 false /* no error */); | 164 false /* no error */); |
161 VerifySyncGlobalErrorResult(&service, | 165 VerifySyncGlobalErrorResult(&service, |
162 table[i], | 166 table[i], |
163 false /* not signed in */, | 167 false /* not signed in */, |
164 false /* no error */); | 168 false /* no error */); |
165 } | 169 } |
166 } | 170 } |
167 #endif | 171 #endif |
168 | 172 |
169 // TODO(tim): This shouldn't be required. r194857 removed the | 173 // TODO(tim): This shouldn't be required. r194857 removed the |
170 // AuthInProgress override from FakeSigninManager, which meant this test started | 174 // AuthInProgress override from FakeSigninManager, which meant this test started |
171 // using the "real" SigninManager AuthInProgress logic. Without that override, | 175 // using the "real" SigninManager AuthInProgress logic. Without that override, |
172 // it's no longer possible to test both chrome os + desktop flows as part of the | 176 // it's no longer possible to test both chrome os + desktop flows as part of the |
173 // same test, because AuthInProgress is always false on chrome os. Most of the | 177 // same test, because AuthInProgress is always false on chrome os. Most of the |
174 // tests are unaffected, but STATUS_CASE_AUTHENTICATING can't exist in both | 178 // tests are unaffected, but STATUS_CASE_AUTHENTICATING can't exist in both |
175 // versions, so it we will require two separate tests, one using SigninManager | 179 // versions, so it we will require two separate tests, one using SigninManager |
176 // and one using SigninManagerBase (which require different setup procedures. | 180 // and one using SigninManagerBase (which require different setup procedures. |
177 class FakeSigninManagerForSyncUIUtilTest : public FakeSigninManagerBase { | 181 class FakeSigninManagerForSyncUIUtilTest : public FakeSigninManagerBase { |
178 public: | 182 public: |
179 explicit FakeSigninManagerForSyncUIUtilTest(Profile* profile) | 183 explicit FakeSigninManagerForSyncUIUtilTest(Profile* profile) |
180 : FakeSigninManagerBase(profile), auth_in_progress_(false) { | 184 : FakeSigninManagerBase( |
| 185 ChromeSigninClientFactory::GetForProfile(profile), |
| 186 AccountTrackerServiceFactory::GetForProfile(profile)), |
| 187 auth_in_progress_(false) { |
181 Initialize(NULL); | 188 Initialize(NULL); |
182 } | 189 } |
183 | 190 |
184 ~FakeSigninManagerForSyncUIUtilTest() override {} | 191 ~FakeSigninManagerForSyncUIUtilTest() override {} |
185 | 192 |
186 bool AuthInProgress() const override { return auth_in_progress_; } | 193 bool AuthInProgress() const override { return auth_in_progress_; } |
187 | 194 |
188 void set_auth_in_progress() { | 195 void set_auth_in_progress() { |
189 auth_in_progress_ = true; | 196 auth_in_progress_ = true; |
190 } | 197 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 EXPECT_FALSE(status_label.empty()); | 403 EXPECT_FALSE(status_label.empty()); |
397 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")), | 404 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")), |
398 base::string16::npos); | 405 base::string16::npos); |
399 testing::Mock::VerifyAndClearExpectations(&service); | 406 testing::Mock::VerifyAndClearExpectations(&service); |
400 testing::Mock::VerifyAndClearExpectations(&signin); | 407 testing::Mock::VerifyAndClearExpectations(&signin); |
401 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 408 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
402 provider.reset(); | 409 provider.reset(); |
403 signin.Shutdown(); | 410 signin.Shutdown(); |
404 } | 411 } |
405 } | 412 } |
OLD | NEW |