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

Side by Side Diff: chrome/test/live_sync/live_sync_test.cc

Issue 7259005: Allow sync integration tests to operate on multiple datatypes: Preferences + Bookmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add BookmarksHelper class. (TODO: Trim lines to 80 chars) Created 9 years, 5 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/test/live_sync/live_sync_test.h" 5 #include "chrome/test/live_sync/live_sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 #include "base/test/test_timeouts.h" 17 #include "base/test/test_timeouts.h"
18 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/password_manager/encryptor.h" 20 #include "chrome/browser/password_manager/encryptor.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/sync/profile_sync_service_harness.h" 23 #include "chrome/browser/sync/profile_sync_service_harness.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/test/live_sync/sync_datatype_helper.h"
27 #include "chrome/test/testing_browser_process.h" 28 #include "chrome/test/testing_browser_process.h"
28 #include "chrome/test/ui_test_utils.h" 29 #include "chrome/test/ui_test_utils.h"
29 #include "content/browser/browser_thread.h" 30 #include "content/browser/browser_thread.h"
30 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/tab_contents.h"
31 #include "content/common/test_url_fetcher_factory.h" 32 #include "content/common/test_url_fetcher_factory.h"
32 #include "content/common/url_fetcher.h" 33 #include "content/common/url_fetcher.h"
33 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
34 #include "net/base/escape.h" 35 #include "net/base/escape.h"
35 #include "net/base/network_change_notifier.h" 36 #include "net/base/network_change_notifier.h"
36 #include "net/proxy/proxy_config.h" 37 #include "net/proxy/proxy_config.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 base::WaitableEvent* done_; 103 base::WaitableEvent* done_;
103 net::URLRequestContextGetter* url_request_context_getter_; 104 net::URLRequestContextGetter* url_request_context_getter_;
104 net::ProxyConfig proxy_config_; 105 net::ProxyConfig proxy_config_;
105 }; 106 };
106 107
107 LiveSyncTest::LiveSyncTest(TestType test_type) 108 LiveSyncTest::LiveSyncTest(TestType test_type)
108 : sync_server_(net::TestServer::TYPE_SYNC, FilePath()), 109 : sync_server_(net::TestServer::TYPE_SYNC, FilePath()),
109 test_type_(test_type), 110 test_type_(test_type),
110 server_type_(SERVER_TYPE_UNDECIDED), 111 server_type_(SERVER_TYPE_UNDECIDED),
111 num_clients_(-1), 112 num_clients_(-1),
113 use_verifier_(true),
112 test_server_handle_(base::kNullProcessHandle) { 114 test_server_handle_(base::kNullProcessHandle) {
113 InProcessBrowserTest::set_show_window(true); 115 InProcessBrowserTest::set_show_window(true);
116 SyncDatatypeHelper::AssociateWithTest(this);
114 switch (test_type_) { 117 switch (test_type_) {
115 case SINGLE_CLIENT: { 118 case SINGLE_CLIENT: {
116 num_clients_ = 1; 119 num_clients_ = 1;
117 break; 120 break;
118 } 121 }
119 case TWO_CLIENT: { 122 case TWO_CLIENT: {
120 num_clients_ = 2; 123 num_clients_ = 2;
121 break; 124 break;
122 } 125 }
123 case MULTIPLE_CLIENT: { 126 case MULTIPLE_CLIENT: {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 LOG(FATAL) << "GetClient(): Index is out of bounds."; 243 LOG(FATAL) << "GetClient(): Index is out of bounds.";
241 return clients_[index]; 244 return clients_[index];
242 } 245 }
243 246
244 Profile* LiveSyncTest::verifier() { 247 Profile* LiveSyncTest::verifier() {
245 if (verifier_.get() == NULL) 248 if (verifier_.get() == NULL)
246 LOG(FATAL) << "SetupClients() has not yet been called."; 249 LOG(FATAL) << "SetupClients() has not yet been called.";
247 return verifier_.get(); 250 return verifier_.get();
248 } 251 }
249 252
253 void LiveSyncTest::DisableVerifier() {
254 use_verifier_ = false;
255 }
256
250 bool LiveSyncTest::SetupClients() { 257 bool LiveSyncTest::SetupClients() {
251 if (num_clients_ <= 0) 258 if (num_clients_ <= 0)
252 LOG(FATAL) << "num_clients_ incorrectly initialized."; 259 LOG(FATAL) << "num_clients_ incorrectly initialized.";
253 if (!profiles_.empty() || !clients_.empty()) 260 if (!profiles_.empty() || !clients_.empty())
254 LOG(FATAL) << "SetupClients() has already been called."; 261 LOG(FATAL) << "SetupClients() has already been called.";
255 262
256 // Start up a sync test server if one is needed. 263 // Start up a sync test server if one is needed.
257 SetUpTestServerIfRequired(); 264 SetUpTestServerIfRequired();
258 265
259 // Create the required number of sync profiles and clients. 266 // Create the required number of sync profiles and clients.
260 for (int i = 0; i < num_clients_; ++i) { 267 for (int i = 0; i < num_clients_; ++i) {
261 profiles_.push_back(MakeProfile( 268 profiles_.push_back(MakeProfile(
262 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), i))); 269 base::StringPrintf(FILE_PATH_LITERAL("Profile%d"), i)));
263 EXPECT_FALSE(GetProfile(i) == NULL) << "GetProfile(" << i << ") failed."; 270 EXPECT_FALSE(GetProfile(i) == NULL) << "GetProfile(" << i << ") failed.";
264 clients_.push_back( 271 clients_.push_back(
265 new ProfileSyncServiceHarness(GetProfile(i), username_, password_)); 272 new ProfileSyncServiceHarness(GetProfile(i), username_, password_));
266 EXPECT_FALSE(GetClient(i) == NULL) << "GetClient(" << i << ") failed."; 273 EXPECT_FALSE(GetClient(i) == NULL) << "GetClient(" << i << ") failed.";
274 ui_test_utils::WaitForBookmarkModelToLoad(
275 GetProfile(i)->GetBookmarkModel());
267 } 276 }
268 277
269 // Create the verifier profile. 278 // Create the verifier profile.
270 verifier_.reset(MakeProfile(FILE_PATH_LITERAL("Verifier"))); 279 verifier_.reset(MakeProfile(FILE_PATH_LITERAL("Verifier")));
280 ui_test_utils::WaitForBookmarkModelToLoad(verifier()->GetBookmarkModel());
271 return (verifier_.get() != NULL); 281 return (verifier_.get() != NULL);
272 } 282 }
273 283
274 bool LiveSyncTest::SetupSync() { 284 bool LiveSyncTest::SetupSync() {
275 // Create sync profiles and clients if they haven't already been created. 285 // Create sync profiles and clients if they haven't already been created.
276 if (profiles_.empty()) { 286 if (profiles_.empty()) {
277 if (!SetupClients()) 287 if (!SetupClients())
278 LOG(FATAL) << "SetupClients() failed."; 288 LOG(FATAL) << "SetupClients() failed.";
279 } 289 }
280 290
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 const net::ProxyConfig& proxy_config) { 520 const net::ProxyConfig& proxy_config) {
511 base::WaitableEvent done(false, false); 521 base::WaitableEvent done(false, false);
512 BrowserThread::PostTask( 522 BrowserThread::PostTask(
513 BrowserThread::IO, 523 BrowserThread::IO,
514 FROM_HERE, 524 FROM_HERE,
515 new SetProxyConfigTask(&done, 525 new SetProxyConfigTask(&done,
516 context_getter, 526 context_getter,
517 proxy_config)); 527 proxy_config));
518 done.Wait(); 528 done.Wait();
519 } 529 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_test.h ('k') | chrome/test/live_sync/many_client_bookmarks_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698