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_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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 GoogleServiceAuthError::NONE); | 66 GoogleServiceAuthError::NONE); |
67 } | 67 } |
68 | 68 |
69 std::string TestForAuthError::GetDebugMessage() const { | 69 std::string TestForAuthError::GetDebugMessage() const { |
70 return "Waiting for auth error"; | 70 return "Waiting for auth error"; |
71 } | 71 } |
72 | 72 |
73 class SyncAuthTest : public SyncTest { | 73 class SyncAuthTest : public SyncTest { |
74 public: | 74 public: |
75 SyncAuthTest() : SyncTest(SINGLE_CLIENT), bookmark_index_(0) {} | 75 SyncAuthTest() : SyncTest(SINGLE_CLIENT), bookmark_index_(0) {} |
76 virtual ~SyncAuthTest() {} | 76 ~SyncAuthTest() override {} |
77 | 77 |
78 // Helper function that adds a bookmark and waits for either an auth error, or | 78 // Helper function that adds a bookmark and waits for either an auth error, or |
79 // for the bookmark to be committed. Returns true if it detects an auth | 79 // for the bookmark to be committed. Returns true if it detects an auth |
80 // error, false if the bookmark is committed successfully. | 80 // error, false if the bookmark is committed successfully. |
81 bool AttemptToTriggerAuthError() { | 81 bool AttemptToTriggerAuthError() { |
82 int bookmark_index = GetNextBookmarkIndex(); | 82 int bookmark_index = GetNextBookmarkIndex(); |
83 std::string title = base::StringPrintf("Bookmark %d", bookmark_index); | 83 std::string title = base::StringPrintf("Bookmark %d", bookmark_index); |
84 GURL url = GURL(base::StringPrintf("http://www.foo%d.com", bookmark_index)); | 84 GURL url = GURL(base::StringPrintf("http://www.foo%d.com", bookmark_index)); |
85 EXPECT_TRUE(AddURL(0, title, url) != NULL); | 85 EXPECT_TRUE(AddURL(0, title, url) != NULL); |
86 | 86 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |