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

Side by Side Diff: chrome/browser/sync/sync_ui_util_unittest.cc

Issue 11886079: Revert 177136 due to memory error on Mac ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/sync_ui_util.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
OLDNEW
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/signin_manager.h" 9 #include "chrome/browser/signin/signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_fake.h" 10 #include "chrome/browser/signin/signin_manager_fake.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 EXPECT_CALL(service, IsPassphraseRequired()) 86 EXPECT_CALL(service, IsPassphraseRequired())
87 .WillRepeatedly(Return(true)); 87 .WillRepeatedly(Return(true));
88 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) 88 EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
89 .WillRepeatedly(Return(true)); 89 .WillRepeatedly(Return(true));
90 VerifySyncGlobalErrorResult( 90 VerifySyncGlobalErrorResult(
91 &service, signin, GoogleServiceAuthError::NONE, true, true); 91 &service, signin, GoogleServiceAuthError::NONE, true, true);
92 } 92 }
93 93
94 // Test that GetStatusLabelsForSyncGlobalError returns an error if a 94 // Test that GetStatusLabelsForSyncGlobalError returns an error if a
95 // passphrase is required and not for auth errors. 95 // passphrase is required.
96 TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) { 96 TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) {
97 MessageLoopForUI message_loop; 97 MessageLoopForUI message_loop;
98 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 98 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
99 scoped_ptr<Profile> profile( 99 scoped_ptr<Profile> profile(
100 ProfileSyncServiceMock::MakeSignedInTestingProfile()); 100 ProfileSyncServiceMock::MakeSignedInTestingProfile());
101 NiceMock<ProfileSyncServiceMock> service(profile.get()); 101 NiceMock<ProfileSyncServiceMock> service(profile.get());
102 FakeSigninManager signin(profile.get()); 102 FakeSigninManager signin(profile.get());
103 browser_sync::SyncBackendHost::Status status; 103 browser_sync::SyncBackendHost::Status status;
104 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) 104 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
105 .WillRepeatedly(Return(false)); 105 .WillRepeatedly(Return(false));
106 106
107 EXPECT_CALL(service, IsPassphraseRequired()) 107 EXPECT_CALL(service, IsPassphraseRequired())
108 .WillRepeatedly(Return(true)); 108 .WillRepeatedly(Return(true));
109 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) 109 EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
110 .WillRepeatedly(Return(true)); 110 .WillRepeatedly(Return(true));
111 EXPECT_CALL(service, HasSyncSetupCompleted()) 111 EXPECT_CALL(service, HasSyncSetupCompleted())
112 .WillRepeatedly(Return(true)); 112 .WillRepeatedly(Return(true));
113 113
114 GoogleServiceAuthError auth_error( 114 GoogleServiceAuthError auth_error(
115 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 115 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
116 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error)); 116 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error));
117 string16 menu_label, label2, label3; 117 string16 menu_label, label2, label3;
118 sync_ui_util::GetStatusLabelsForSyncGlobalError( 118 sync_ui_util::GetStatusLabelsForSyncGlobalError(
119 &service, signin, &menu_label, &label2, &label3); 119 &service, signin, &menu_label, &label2, &label3);
120 // Make sure we are still displaying the passphrase error badge (don't show 120 // Make sure we aren't displaying the passphrase error badge.
121 // auth errors through SyncUIUtil). 121 EXPECT_NE(menu_label, l10n_util::GetStringUTF16(
122 EXPECT_EQ(menu_label, l10n_util::GetStringUTF16(
123 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM)); 122 IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM));
124 } 123 }
125 124
126 // Test that GetStatusLabelsForSyncGlobalError does not indicate errors for 125 // Test that GetStatusLabelsForSyncGlobalError indicates errors for conditions
127 // auth errors (these are reported through SigninGlobalError). 126 // that can be resolved by the user and suppresses errors for conditions that
127 // cannot be resolved by the user.
128 TEST(SyncUIUtilTest, AuthStateGlobalError) { 128 TEST(SyncUIUtilTest, AuthStateGlobalError) {
129 MessageLoopForUI message_loop; 129 MessageLoopForUI message_loop;
130 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 130 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
131 scoped_ptr<Profile> profile( 131 scoped_ptr<Profile> profile(
132 ProfileSyncServiceMock::MakeSignedInTestingProfile()); 132 ProfileSyncServiceMock::MakeSignedInTestingProfile());
133 NiceMock<ProfileSyncServiceMock> service(profile.get()); 133 NiceMock<ProfileSyncServiceMock> service(profile.get());
134 134
135 browser_sync::SyncBackendHost::Status status; 135 browser_sync::SyncBackendHost::Status status;
136 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) 136 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
137 .WillRepeatedly(Return(false)); 137 .WillRepeatedly(Return(false));
138 138
139 GoogleServiceAuthError::State table[] = { 139 struct {
140 GoogleServiceAuthError::NONE, 140 GoogleServiceAuthError::State error_state;
141 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 141 bool is_error;
142 GoogleServiceAuthError::USER_NOT_SIGNED_UP, 142 } table[] = {
143 GoogleServiceAuthError::CONNECTION_FAILED, 143 { GoogleServiceAuthError::NONE, false },
144 GoogleServiceAuthError::CAPTCHA_REQUIRED, 144 { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, true },
145 GoogleServiceAuthError::ACCOUNT_DELETED, 145 { GoogleServiceAuthError::USER_NOT_SIGNED_UP, true },
146 GoogleServiceAuthError::ACCOUNT_DISABLED, 146 { GoogleServiceAuthError::CONNECTION_FAILED, false },
147 GoogleServiceAuthError::SERVICE_UNAVAILABLE, 147 { GoogleServiceAuthError::CAPTCHA_REQUIRED, true },
148 GoogleServiceAuthError::TWO_FACTOR, 148 { GoogleServiceAuthError::ACCOUNT_DELETED, true },
149 GoogleServiceAuthError::REQUEST_CANCELED, 149 { GoogleServiceAuthError::ACCOUNT_DISABLED, true },
150 GoogleServiceAuthError::HOSTED_NOT_ALLOWED 150 { GoogleServiceAuthError::SERVICE_UNAVAILABLE, true },
151 { GoogleServiceAuthError::TWO_FACTOR, true },
152 { GoogleServiceAuthError::REQUEST_CANCELED, true },
153 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true },
151 }; 154 };
152 155
153 FakeSigninManager signin(profile.get()); 156 FakeSigninManager signin(profile.get());
154 for (size_t i = 0; i < arraysize(table); ++i) { 157 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
155 VerifySyncGlobalErrorResult(&service, signin, table[i], true, false); 158 VerifySyncGlobalErrorResult(
156 VerifySyncGlobalErrorResult(&service, signin, table[i], false, false); 159 &service, signin, table[i].error_state, true, table[i].is_error);
160 VerifySyncGlobalErrorResult(
161 &service, signin, table[i].error_state, false, false);
157 } 162 }
158 } 163 }
159 // Loads a ProfileSyncServiceMock to emulate one of a number of distinct cases 164 // Loads a ProfileSyncServiceMock to emulate one of a number of distinct cases
160 // in order to perform tests on the generated messages. 165 // in order to perform tests on the generated messages.
161 void GetDistinctCase(ProfileSyncServiceMock& service, 166 void GetDistinctCase(ProfileSyncServiceMock& service,
162 SigninManagerMock& signin, 167 SigninManagerMock& signin,
163 GoogleServiceAuthError** auth_error, 168 GoogleServiceAuthError** auth_error,
164 int caseNumber) { 169 int caseNumber) {
165 // Auth Error object is returned by reference in mock and needs to stay in 170 // Auth Error object is returned by reference in mock and needs to stay in
166 // scope throughout test, so it is owned by calling method. However it is 171 // scope throughout test, so it is owned by calling method. However it is
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // Ensures a search for string 'href' (found in links, not a string to be 341 // Ensures a search for string 'href' (found in links, not a string to be
337 // found in an English language message) fails when links are excluded from 342 // found in an English language message) fails when links are excluded from
338 // the status label. 343 // the status label.
339 EXPECT_EQ(status_label.find(string16(ASCIIToUTF16("href"))), 344 EXPECT_EQ(status_label.find(string16(ASCIIToUTF16("href"))),
340 string16::npos); 345 string16::npos);
341 if (auth_error) { 346 if (auth_error) {
342 delete auth_error; 347 delete auth_error;
343 } 348 }
344 } 349 }
345 } 350 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_ui_util.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698