| OLD | NEW |
| 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.h" | 8 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 10 #include "chrome/browser/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 SyncAuthTest() : SyncTest(SINGLE_CLIENT) {} | 49 SyncAuthTest() : SyncTest(SINGLE_CLIENT) {} |
| 50 virtual ~SyncAuthTest() {} | 50 virtual ~SyncAuthTest() {} |
| 51 | 51 |
| 52 // Helper function that adds a bookmark with index |bookmark_index| and waits | 52 // Helper function that adds a bookmark with index |bookmark_index| and waits |
| 53 // for sync to complete. The return value indicates whether the sync cycle | 53 // for sync to complete. The return value indicates whether the sync cycle |
| 54 // completed successfully (true) or encountered an auth error (false). | 54 // completed successfully (true) or encountered an auth error (false). |
| 55 bool AddBookmarkAndWaitForSync(int bookmark_index) { | 55 bool AddBookmarkAndWaitForSync(int bookmark_index) { |
| 56 std::wstring title = base::StringPrintf(L"Bookmark %d", bookmark_index); | 56 std::wstring title = base::StringPrintf(L"Bookmark %d", bookmark_index); |
| 57 GURL url = GURL(base::StringPrintf("http://www.foo%d.com", bookmark_index)); | 57 GURL url = GURL(base::StringPrintf("http://www.foo%d.com", bookmark_index)); |
| 58 EXPECT_TRUE(AddURL(0, title, url) != NULL); | 58 EXPECT_TRUE(AddURL(0, title, url) != NULL); |
| 59 return GetClient(0)->AwaitFullSyncCompletion(); | 59 return GetClient(0)->AwaitCommitActivityCompletion(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Sets the authenticated state of the python sync server to |auth_state| and | 62 // Sets the authenticated state of the python sync server to |auth_state| and |
| 63 // sets the canned response that will be returned to the OAuth2TokenService | 63 // sets the canned response that will be returned to the OAuth2TokenService |
| 64 // when it tries to fetch an access token. | 64 // when it tries to fetch an access token. |
| 65 void SetAuthStateAndTokenResponse(PythonServerAuthState auth_state, | 65 void SetAuthStateAndTokenResponse(PythonServerAuthState auth_state, |
| 66 const std::string& response_data, | 66 const std::string& response_data, |
| 67 net::HttpStatusCode response_code, | 67 net::HttpStatusCode response_code, |
| 68 net::URLRequestStatus::Status status) { | 68 net::URLRequestStatus::Status status) { |
| 69 TriggerAuthState(auth_state); | 69 TriggerAuthState(auth_state); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 ASSERT_TRUE( | 253 ASSERT_TRUE( |
| 254 GetClient(0)->service()->IsRetryingAccessTokenFetchForTest()); | 254 GetClient(0)->service()->IsRetryingAccessTokenFetchForTest()); |
| 255 | 255 |
| 256 // Trigger an auth success state and set up a new valid OAuth2 token. | 256 // Trigger an auth success state and set up a new valid OAuth2 token. |
| 257 SetAuthStateAndTokenResponse(AUTHENTICATED_TRUE, | 257 SetAuthStateAndTokenResponse(AUTHENTICATED_TRUE, |
| 258 kValidOAuth2Token, | 258 kValidOAuth2Token, |
| 259 net::HTTP_OK, | 259 net::HTTP_OK, |
| 260 net::URLRequestStatus::SUCCESS); | 260 net::URLRequestStatus::SUCCESS); |
| 261 | 261 |
| 262 // Verify that the next sync cycle is successful, and uses the new auth token. | 262 // Verify that the next sync cycle is successful, and uses the new auth token. |
| 263 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); | 263 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion()); |
| 264 std::string new_token = GetClient(0)->service()->GetAccessTokenForTest(); | 264 std::string new_token = GetClient(0)->service()->GetAccessTokenForTest(); |
| 265 ASSERT_NE(old_token, new_token); | 265 ASSERT_NE(old_token, new_token); |
| 266 } | 266 } |
| OLD | NEW |