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

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

Issue 310103004: Add integraton test for sync backup/rollback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual ~SyncAuthTest() {}
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::wstring title = base::StringPrintf(L"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
87 // Run until the bookmark is committed or an auth error is encountered. 87 // Run until the bookmark is committed or an auth error is encountered.
88 TestForAuthError checker_(GetSyncService((0))); 88 TestForAuthError checker_(GetSyncService((0)));
89 checker_.Wait(); 89 checker_.Wait();
90 90
91 GoogleServiceAuthError oauth_error = 91 GoogleServiceAuthError oauth_error =
92 GetSyncService((0))->GetSyncTokenStatus().last_get_token_error; 92 GetSyncService((0))->GetSyncTokenStatus().last_get_token_error;
93 93
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 GetFakeServer()->SetAuthenticated(); 300 GetFakeServer()->SetAuthenticated();
301 SetOAuth2TokenResponse(kValidOAuth2Token, 301 SetOAuth2TokenResponse(kValidOAuth2Token,
302 net::HTTP_OK, 302 net::HTTP_OK,
303 net::URLRequestStatus::SUCCESS); 303 net::URLRequestStatus::SUCCESS);
304 304
305 // Verify that the next sync cycle is successful, and uses the new auth token. 305 // Verify that the next sync cycle is successful, and uses the new auth token.
306 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 306 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
307 std::string new_token = GetSyncService((0))->GetAccessTokenForTest(); 307 std::string new_token = GetSyncService((0))->GetAccessTokenForTest();
308 ASSERT_NE(old_token, new_token); 308 ASSERT_NE(old_token, new_token);
309 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698