| 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/fake_signin_manager.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/signin_error_controller_factory.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_mock.h" | 11 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 12 #include "chrome/browser/sync/sync_ui_util.h" | 12 #include "chrome/browser/sync/sync_ui_util.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "components/signin/core/browser/fake_auth_status_provider.h" | 14 #include "components/signin/core/browser/fake_auth_status_provider.h" |
| 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | |
| 16 #include "components/signin/core/browser/signin_manager.h" | 15 #include "components/signin/core/browser/signin_manager.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 19 #include "testing/gmock/include/gmock/gmock-actions.h" | 18 #include "testing/gmock/include/gmock/gmock-actions.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 | 22 |
| 24 using ::testing::AtMost; | 23 using ::testing::AtMost; |
| 25 using ::testing::NiceMock; | 24 using ::testing::NiceMock; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { | 334 TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { |
| 336 std::set<base::string16> messages; | 335 std::set<base::string16> messages; |
| 337 for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { | 336 for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { |
| 338 scoped_ptr<Profile> profile(new TestingProfile()); | 337 scoped_ptr<Profile> profile(new TestingProfile()); |
| 339 ProfileSyncServiceMock service(profile.get()); | 338 ProfileSyncServiceMock service(profile.get()); |
| 340 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); | 339 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); |
| 341 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 340 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
| 342 FakeSigninManagerForSyncUIUtilTest signin(profile.get()); | 341 FakeSigninManagerForSyncUIUtilTest signin(profile.get()); |
| 343 signin.SetAuthenticatedUsername(kTestUser); | 342 signin.SetAuthenticatedUsername(kTestUser); |
| 344 scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider( | 343 scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider( |
| 345 ProfileOAuth2TokenServiceFactory::GetForProfile(profile.get())-> | 344 SigninErrorControllerFactory::GetForProfile(profile.get()))); |
| 346 signin_error_controller())); | |
| 347 GetDistinctCase(service, &signin, provider.get(), idx); | 345 GetDistinctCase(service, &signin, provider.get(), idx); |
| 348 base::string16 status_label; | 346 base::string16 status_label; |
| 349 base::string16 link_label; | 347 base::string16 link_label; |
| 350 sync_ui_util::GetStatusLabels(&service, | 348 sync_ui_util::GetStatusLabels(&service, |
| 351 signin, | 349 signin, |
| 352 sync_ui_util::WITH_HTML, | 350 sync_ui_util::WITH_HTML, |
| 353 &status_label, | 351 &status_label, |
| 354 &link_label); | 352 &link_label); |
| 355 // If the status and link message combination is already present in the set | 353 // If the status and link message combination is already present in the set |
| 356 // of messages already seen, this is a duplicate rather than a unique | 354 // of messages already seen, this is a duplicate rather than a unique |
| (...skipping 18 matching lines...) Expand all Loading... |
| 375 TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { | 373 TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { |
| 376 for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { | 374 for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { |
| 377 scoped_ptr<Profile> profile( | 375 scoped_ptr<Profile> profile( |
| 378 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 376 ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
| 379 ProfileSyncServiceMock service(profile.get()); | 377 ProfileSyncServiceMock service(profile.get()); |
| 380 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); | 378 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); |
| 381 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 379 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
| 382 FakeSigninManagerForSyncUIUtilTest signin(profile.get()); | 380 FakeSigninManagerForSyncUIUtilTest signin(profile.get()); |
| 383 signin.SetAuthenticatedUsername(kTestUser); | 381 signin.SetAuthenticatedUsername(kTestUser); |
| 384 scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider( | 382 scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider( |
| 385 ProfileOAuth2TokenServiceFactory::GetForProfile(profile.get())-> | 383 SigninErrorControllerFactory::GetForProfile(profile.get()))); |
| 386 signin_error_controller())); | |
| 387 GetDistinctCase(service, &signin, provider.get(), idx); | 384 GetDistinctCase(service, &signin, provider.get(), idx); |
| 388 base::string16 status_label; | 385 base::string16 status_label; |
| 389 base::string16 link_label; | 386 base::string16 link_label; |
| 390 sync_ui_util::GetStatusLabels(&service, | 387 sync_ui_util::GetStatusLabels(&service, |
| 391 signin, | 388 signin, |
| 392 sync_ui_util::PLAIN_TEXT, | 389 sync_ui_util::PLAIN_TEXT, |
| 393 &status_label, | 390 &status_label, |
| 394 &link_label); | 391 &link_label); |
| 395 | 392 |
| 396 // Ensures a search for string 'href' (found in links, not a string to be | 393 // Ensures a search for string 'href' (found in links, not a string to be |
| 397 // found in an English language message) fails when links are excluded from | 394 // found in an English language message) fails when links are excluded from |
| 398 // the status label. | 395 // the status label. |
| 399 EXPECT_FALSE(status_label.empty()); | 396 EXPECT_FALSE(status_label.empty()); |
| 400 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")), | 397 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")), |
| 401 base::string16::npos); | 398 base::string16::npos); |
| 402 testing::Mock::VerifyAndClearExpectations(&service); | 399 testing::Mock::VerifyAndClearExpectations(&service); |
| 403 testing::Mock::VerifyAndClearExpectations(&signin); | 400 testing::Mock::VerifyAndClearExpectations(&signin); |
| 404 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 401 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
| 405 provider.reset(); | 402 provider.reset(); |
| 406 signin.Shutdown(); | 403 signin.Shutdown(); |
| 407 } | 404 } |
| 408 } | 405 } |
| OLD | NEW |