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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/signin/fake_auth_status_provider.h" | 9 #include "chrome/browser/signin/fake_auth_status_provider.h" |
10 #include "chrome/browser/signin/fake_signin_manager.h" | 10 #include "chrome/browser/signin/fake_signin_manager.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 EXPECT_EQ(label2.empty(), !is_error); | 62 EXPECT_EQ(label2.empty(), !is_error); |
63 EXPECT_EQ(label3.empty(), !is_error); | 63 EXPECT_EQ(label3.empty(), !is_error); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 | 68 |
69 // Test that GetStatusLabelsForSyncGlobalError returns an error if a | 69 // Test that GetStatusLabelsForSyncGlobalError returns an error if a |
70 // passphrase is required. | 70 // passphrase is required. |
71 TEST(SyncUIUtilTest, PassphraseGlobalError) { | 71 TEST(SyncUIUtilTest, PassphraseGlobalError) { |
72 MessageLoopForUI message_loop; | 72 base::MessageLoopForUI message_loop; |
73 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 73 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
74 scoped_ptr<Profile> profile( | 74 scoped_ptr<Profile> profile( |
75 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 75 ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
76 NiceMock<ProfileSyncServiceMock> service(profile.get()); | 76 NiceMock<ProfileSyncServiceMock> service(profile.get()); |
77 FakeSigninManagerBase signin; | 77 FakeSigninManagerBase signin; |
78 browser_sync::SyncBackendHost::Status status; | 78 browser_sync::SyncBackendHost::Status status; |
79 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) | 79 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
80 .WillRepeatedly(Return(false)); | 80 .WillRepeatedly(Return(false)); |
81 EXPECT_CALL(service, IsPassphraseRequired()) | 81 EXPECT_CALL(service, IsPassphraseRequired()) |
82 .WillRepeatedly(Return(true)); | 82 .WillRepeatedly(Return(true)); |
83 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) | 83 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) |
84 .WillRepeatedly(Return(true)); | 84 .WillRepeatedly(Return(true)); |
85 VerifySyncGlobalErrorResult( | 85 VerifySyncGlobalErrorResult( |
86 &service, signin, GoogleServiceAuthError::NONE, true, true); | 86 &service, signin, GoogleServiceAuthError::NONE, true, true); |
87 } | 87 } |
88 | 88 |
89 // Test that GetStatusLabelsForSyncGlobalError returns an error if a | 89 // Test that GetStatusLabelsForSyncGlobalError returns an error if a |
90 // passphrase is required and not for auth errors. | 90 // passphrase is required and not for auth errors. |
91 TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) { | 91 TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) { |
92 MessageLoopForUI message_loop; | 92 base::MessageLoopForUI message_loop; |
93 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 93 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
94 scoped_ptr<Profile> profile( | 94 scoped_ptr<Profile> profile( |
95 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 95 ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
96 NiceMock<ProfileSyncServiceMock> service(profile.get()); | 96 NiceMock<ProfileSyncServiceMock> service(profile.get()); |
97 FakeSigninManagerBase signin; | 97 FakeSigninManagerBase signin; |
98 browser_sync::SyncBackendHost::Status status; | 98 browser_sync::SyncBackendHost::Status status; |
99 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) | 99 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
100 .WillRepeatedly(Return(false)); | 100 .WillRepeatedly(Return(false)); |
101 | 101 |
102 EXPECT_CALL(service, IsPassphraseRequired()) | 102 EXPECT_CALL(service, IsPassphraseRequired()) |
(...skipping 11 matching lines...) Expand all Loading... |
114 &service, signin, &menu_label, &label2, &label3); | 114 &service, signin, &menu_label, &label2, &label3); |
115 // Make sure we are still displaying the passphrase error badge (don't show | 115 // Make sure we are still displaying the passphrase error badge (don't show |
116 // auth errors through SyncUIUtil). | 116 // auth errors through SyncUIUtil). |
117 EXPECT_EQ(menu_label, l10n_util::GetStringUTF16( | 117 EXPECT_EQ(menu_label, l10n_util::GetStringUTF16( |
118 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM)); | 118 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM)); |
119 } | 119 } |
120 | 120 |
121 // Test that GetStatusLabelsForSyncGlobalError does not indicate errors for | 121 // Test that GetStatusLabelsForSyncGlobalError does not indicate errors for |
122 // auth errors (these are reported through SigninGlobalError). | 122 // auth errors (these are reported through SigninGlobalError). |
123 TEST(SyncUIUtilTest, AuthStateGlobalError) { | 123 TEST(SyncUIUtilTest, AuthStateGlobalError) { |
124 MessageLoopForUI message_loop; | 124 base::MessageLoopForUI message_loop; |
125 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 125 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
126 scoped_ptr<Profile> profile( | 126 scoped_ptr<Profile> profile( |
127 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 127 ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
128 NiceMock<ProfileSyncServiceMock> service(profile.get()); | 128 NiceMock<ProfileSyncServiceMock> service(profile.get()); |
129 | 129 |
130 browser_sync::SyncBackendHost::Status status; | 130 browser_sync::SyncBackendHost::Status status; |
131 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) | 131 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
132 .WillRepeatedly(Return(false)); | 132 .WillRepeatedly(Return(false)); |
133 | 133 |
134 GoogleServiceAuthError::State table[] = { | 134 GoogleServiceAuthError::State table[] = { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // the status label. | 378 // the status label. |
379 EXPECT_FALSE(status_label.empty()); | 379 EXPECT_FALSE(status_label.empty()); |
380 EXPECT_EQ(status_label.find(string16(ASCIIToUTF16("href"))), | 380 EXPECT_EQ(status_label.find(string16(ASCIIToUTF16("href"))), |
381 string16::npos); | 381 string16::npos); |
382 testing::Mock::VerifyAndClearExpectations(&service); | 382 testing::Mock::VerifyAndClearExpectations(&service); |
383 testing::Mock::VerifyAndClearExpectations(&signin); | 383 testing::Mock::VerifyAndClearExpectations(&signin); |
384 provider.reset(); | 384 provider.reset(); |
385 signin.Shutdown(); | 385 signin.Shutdown(); |
386 } | 386 } |
387 } | 387 } |
OLD | NEW |