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

Side by Side Diff: chrome/browser/sync/test/integration/sync_auth_test.cc

Issue 1155443009: [Sync] Rename SyncActive to IsSyncActive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More non-android cases. Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/threading/platform_thread.h" 6 #include "base/threading/platform_thread.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // an invalid_grant error is returned by OAuth2TokenService with an 240 // an invalid_grant error is returned by OAuth2TokenService with an
241 // HTTP_BAD_REQUEST (400) response code. 241 // HTTP_BAD_REQUEST (400) response code.
242 IN_PROC_BROWSER_TEST_F(SyncAuthTest, FailInitialSetupWithPersistentError) { 242 IN_PROC_BROWSER_TEST_F(SyncAuthTest, FailInitialSetupWithPersistentError) {
243 ASSERT_TRUE(SetupClients()); 243 ASSERT_TRUE(SetupClients());
244 GetFakeServer()->SetUnauthenticated(); 244 GetFakeServer()->SetUnauthenticated();
245 DisableTokenFetchRetries(); 245 DisableTokenFetchRetries();
246 SetOAuth2TokenResponse(kInvalidGrantOAuth2Token, 246 SetOAuth2TokenResponse(kInvalidGrantOAuth2Token,
247 net::HTTP_BAD_REQUEST, 247 net::HTTP_BAD_REQUEST,
248 net::URLRequestStatus::SUCCESS); 248 net::URLRequestStatus::SUCCESS);
249 ASSERT_FALSE(GetClient(0)->SetupSync()); 249 ASSERT_FALSE(GetClient(0)->SetupSync());
250 ASSERT_FALSE(GetSyncService((0))->SyncActive()); 250 ASSERT_FALSE(GetSyncService((0))->IsSyncActive());
251 ASSERT_EQ(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 251 ASSERT_EQ(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS,
252 GetSyncService((0))->GetAuthError().state()); 252 GetSyncService((0))->GetAuthError().state());
253 } 253 }
254 254
255 // Verify that ProfileSyncService fails initial sync setup during backend 255 // Verify that ProfileSyncService fails initial sync setup during backend
256 // initialization, but continues trying to fetch access tokens when 256 // initialization, but continues trying to fetch access tokens when
257 // OAuth2TokenService receives an HTTP_INTERNAL_SERVER_ERROR (500) response 257 // OAuth2TokenService receives an HTTP_INTERNAL_SERVER_ERROR (500) response
258 // code. 258 // code.
259 IN_PROC_BROWSER_TEST_F(SyncAuthTest, RetryInitialSetupWithTransientError) { 259 IN_PROC_BROWSER_TEST_F(SyncAuthTest, RetryInitialSetupWithTransientError) {
260 ASSERT_TRUE(SetupClients()); 260 ASSERT_TRUE(SetupClients());
261 GetFakeServer()->SetUnauthenticated(); 261 GetFakeServer()->SetUnauthenticated();
262 DisableTokenFetchRetries(); 262 DisableTokenFetchRetries();
263 SetOAuth2TokenResponse(kEmptyOAuth2Token, 263 SetOAuth2TokenResponse(kEmptyOAuth2Token,
264 net::HTTP_INTERNAL_SERVER_ERROR, 264 net::HTTP_INTERNAL_SERVER_ERROR,
265 net::URLRequestStatus::SUCCESS); 265 net::URLRequestStatus::SUCCESS);
266 ASSERT_FALSE(GetClient(0)->SetupSync()); 266 ASSERT_FALSE(GetClient(0)->SetupSync());
267 ASSERT_FALSE(GetSyncService((0))->SyncActive()); 267 ASSERT_FALSE(GetSyncService((0))->IsSyncActive());
268 ASSERT_TRUE( 268 ASSERT_TRUE(
269 GetSyncService((0))->IsRetryingAccessTokenFetchForTest()); 269 GetSyncService((0))->IsRetryingAccessTokenFetchForTest());
270 } 270 }
271 271
272 // Verify that ProfileSyncService fetches a new token when an old token expires. 272 // Verify that ProfileSyncService fetches a new token when an old token expires.
273 IN_PROC_BROWSER_TEST_F(SyncAuthTest, TokenExpiry) { 273 IN_PROC_BROWSER_TEST_F(SyncAuthTest, TokenExpiry) {
274 // Initial sync succeeds with a short lived OAuth2 Token. 274 // Initial sync succeeds with a short lived OAuth2 Token.
275 ASSERT_TRUE(SetupClients()); 275 ASSERT_TRUE(SetupClients());
276 GetFakeServer()->SetAuthenticated(); 276 GetFakeServer()->SetAuthenticated();
277 DisableTokenFetchRetries(); 277 DisableTokenFetchRetries();
(...skipping 20 matching lines...) Expand all
298 GetFakeServer()->SetAuthenticated(); 298 GetFakeServer()->SetAuthenticated();
299 SetOAuth2TokenResponse(kValidOAuth2Token, 299 SetOAuth2TokenResponse(kValidOAuth2Token,
300 net::HTTP_OK, 300 net::HTTP_OK,
301 net::URLRequestStatus::SUCCESS); 301 net::URLRequestStatus::SUCCESS);
302 302
303 // Verify that the next sync cycle is successful, and uses the new auth token. 303 // Verify that the next sync cycle is successful, and uses the new auth token.
304 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 304 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
305 std::string new_token = GetSyncService((0))->GetAccessTokenForTest(); 305 std::string new_token = GetSyncService((0))->GetAccessTokenForTest();
306 ASSERT_NE(old_token, new_token); 306 ASSERT_NE(old_token, new_token);
307 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698