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

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

Issue 2772783004: [Sync] Don't display passphrase notification if user dismissed previous one (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/browser/sync/sync_error_notifier_ash.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/sync/sync_error_notifier_ash.h" 5 #include "chrome/browser/sync/sync_error_notifier_ash.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 display::Screen::SetScreenInstance(nullptr); 127 display::Screen::SetScreenInstance(nullptr);
128 test_screen_.reset(); 128 test_screen_.reset();
129 #endif 129 #endif
130 } 130 }
131 131
132 protected: 132 protected:
133 // Utility function to test that SyncErrorNotifier behaves correctly for the 133 // Utility function to test that SyncErrorNotifier behaves correctly for the
134 // given error condition. 134 // given error condition.
135 void VerifySyncErrorNotifierResult(GoogleServiceAuthError::State error_state, 135 void VerifySyncErrorNotifierResult(GoogleServiceAuthError::State error_state,
136 bool is_signed_in, 136 bool is_signed_in,
137 bool is_error) { 137 bool is_error,
138 bool expected_notification) {
138 EXPECT_CALL(*service_, IsFirstSetupComplete()) 139 EXPECT_CALL(*service_, IsFirstSetupComplete())
139 .WillRepeatedly(Return(is_signed_in)); 140 .WillRepeatedly(Return(is_signed_in));
140 141
141 GoogleServiceAuthError auth_error(error_state); 142 GoogleServiceAuthError auth_error(error_state);
142 EXPECT_CALL(*service_, GetAuthError()).WillRepeatedly( 143 EXPECT_CALL(*service_, GetAuthError()).WillRepeatedly(
143 ReturnRef(auth_error)); 144 ReturnRef(auth_error));
144 145
145 error_controller_->OnStateChanged(service_.get()); 146 error_controller_->OnStateChanged(service_.get());
146 EXPECT_EQ(is_error, error_controller_->HasError()); 147 EXPECT_EQ(is_error, error_controller_->HasError());
147 148
148 // If there is an error we should see a notification.
149 const Notification* notification = notification_ui_manager_->FindById( 149 const Notification* notification = notification_ui_manager_->FindById(
150 kNotificationId, NotificationUIManager::GetProfileID(profile_)); 150 kNotificationId, NotificationUIManager::GetProfileID(profile_));
151 if (is_error) { 151 if (expected_notification) {
152 ASSERT_TRUE(notification); 152 ASSERT_TRUE(notification);
153 ASSERT_FALSE(notification->title().empty()); 153 ASSERT_FALSE(notification->title().empty());
154 ASSERT_FALSE(notification->title().empty()); 154 ASSERT_FALSE(notification->message().empty());
skym 2017/03/27 20:56:56 Nice catch
155 ASSERT_EQ((size_t)1, notification->buttons().size()); 155 ASSERT_EQ((size_t)1, notification->buttons().size());
156 } else { 156 } else {
157 ASSERT_FALSE(notification); 157 ASSERT_FALSE(notification);
158 } 158 }
159 } 159 }
160 160
161 #if defined(OS_WIN) 161 #if defined(OS_WIN)
162 std::unique_ptr<display::Screen> test_screen_; 162 std::unique_ptr<display::Screen> test_screen_;
163 #endif 163 #endif
164 std::unique_ptr<TestingProfileManager> profile_manager_; 164 std::unique_ptr<TestingProfileManager> profile_manager_;
(...skipping 30 matching lines...) Expand all
195 EXPECT_CALL(*service_, QueryDetailedSyncStatus(_)) 195 EXPECT_CALL(*service_, QueryDetailedSyncStatus(_))
196 .WillRepeatedly(Return(false)); 196 .WillRepeatedly(Return(false));
197 197
198 EXPECT_CALL(*service_, IsPassphraseRequired()) 198 EXPECT_CALL(*service_, IsPassphraseRequired())
199 .WillRepeatedly(Return(true)); 199 .WillRepeatedly(Return(true));
200 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption()) 200 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption())
201 .WillRepeatedly(Return(true)); 201 .WillRepeatedly(Return(true));
202 { 202 {
203 SCOPED_TRACE("Expected a notification for passphrase error"); 203 SCOPED_TRACE("Expected a notification for passphrase error");
204 VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE, 204 VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE,
205 true /* signed in */, 205 true /* signed in */, true /* error */,
skym 2017/03/27 20:56:56 Did you git cl format this?
pavely 2017/03/27 21:06:54 Yeah, I did. The result is worse than before, but
206 true /* error */); 206 true /* expecting notification */);
207 }
208
209 // Sumulate discarded notification and check that notification is not shown.
210 notification_ui_manager_->CancelById(
211 kNotificationId, NotificationUIManager::GetProfileID(profile_));
212 {
213 SCOPED_TRACE("Not expecting notification, one was already discarded");
214 VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE,
215 true /* signed in */, true /* error */,
216 false /* not expecting notification */);
207 } 217 }
208 218
209 // Check that no notification is shown if there is no error. 219 // Check that no notification is shown if there is no error.
210 EXPECT_CALL(*service_, IsPassphraseRequired()) 220 EXPECT_CALL(*service_, IsPassphraseRequired())
211 .WillRepeatedly(Return(false)); 221 .WillRepeatedly(Return(false));
212 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption()) 222 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption())
213 .WillRepeatedly(Return(false)); 223 .WillRepeatedly(Return(false));
214 { 224 {
215 SCOPED_TRACE("Not expecting notification since no error exists"); 225 SCOPED_TRACE("Not expecting notification since no error exists");
216 VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE, 226 VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE,
217 true /* signed in */, 227 true /* signed in */, false /* no error */,
218 false /* no error */); 228 false /* not expecting notification */);
219 } 229 }
220 230
221 // Check that no notification is shown if sync setup is not completed. 231 // Check that no notification is shown if sync setup is not completed.
222 EXPECT_CALL(*service_, IsPassphraseRequired()) 232 EXPECT_CALL(*service_, IsPassphraseRequired())
223 .WillRepeatedly(Return(true)); 233 .WillRepeatedly(Return(true));
224 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption()) 234 EXPECT_CALL(*service_, IsPassphraseRequiredForDecryption())
225 .WillRepeatedly(Return(true)); 235 .WillRepeatedly(Return(true));
226 { 236 {
227 SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); 237 SCOPED_TRACE("Not expecting notification since sync setup is incomplete");
228 VerifySyncErrorNotifierResult( 238 VerifySyncErrorNotifierResult(
229 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 239 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS,
230 false /* not signed in */, 240 false /* not signed in */, false /* no error */,
231 false /* no error */); 241 false /* not expecting notification */);
232 } 242 }
233 } 243 }
234 244
235 } // namespace test 245 } // namespace test
236 } // namespace ash 246 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_error_notifier_ash.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698