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

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <stack> 5 #include <stack>
6 #include <vector> 6 #include <vector>
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/browser/chrome_thread.h"
14 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
15 #include "chrome/browser/sync/engine/syncapi.h" 16 #include "chrome/browser/sync/engine/syncapi.h"
16 #include "chrome/browser/sync/glue/model_associator.h" 17 #include "chrome/browser/sync/glue/model_associator.h"
17 #include "chrome/browser/sync/glue/sync_backend_host.h" 18 #include "chrome/browser/sync/glue/sync_backend_host.h"
18 #include "chrome/browser/sync/profile_sync_service.h" 19 #include "chrome/browser/sync/profile_sync_service.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/testing_profile.h" 21 #include "chrome/test/testing_profile.h"
21 #include "chrome/test/sync/test_http_bridge_factory.h" 22 #include "chrome/test/sync/test_http_bridge_factory.h"
22 23
23 using std::vector; 24 using std::vector;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 sync_api::WriteTransaction *trans_; 261 sync_api::WriteTransaction *trans_;
261 262
262 // The change list we construct. 263 // The change list we construct.
263 vector<sync_api::SyncManager::ChangeRecord> changes_; 264 vector<sync_api::SyncManager::ChangeRecord> changes_;
264 }; 265 };
265 266
266 class ProfileSyncServiceTest : public testing::Test { 267 class ProfileSyncServiceTest : public testing::Test {
267 protected: 268 protected:
268 enum LoadOption { LOAD_FROM_STORAGE, DELETE_EXISTING_STORAGE }; 269 enum LoadOption { LOAD_FROM_STORAGE, DELETE_EXISTING_STORAGE };
269 enum SaveOption { SAVE_TO_STORAGE, DONT_SAVE_TO_STORAGE }; 270 enum SaveOption { SAVE_TO_STORAGE, DONT_SAVE_TO_STORAGE };
270 ProfileSyncServiceTest() : model_(NULL) { 271 ProfileSyncServiceTest()
272 : ui_thread_(ChromeThread::UI, &message_loop_),
273 file_thread_(ChromeThread::FILE, &message_loop_),
274 model_(NULL) {
271 profile_.reset(new TestingProfile()); 275 profile_.reset(new TestingProfile());
272 profile_->set_has_history_service(true); 276 profile_->set_has_history_service(true);
273 } 277 }
274 virtual ~ProfileSyncServiceTest() { 278 virtual ~ProfileSyncServiceTest() {
275 // Kill the service before the profile. 279 // Kill the service before the profile.
276 service_.reset(); 280 service_.reset();
277 profile_.reset(); 281 profile_.reset();
278 } 282 }
279 283
280 ModelAssociator* associator() { 284 ModelAssociator* associator() {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 SyncBackendHost* backend() { return service_->backend_.get(); } 461 SyncBackendHost* backend() { return service_->backend_.get(); }
458 462
459 // This serves as the "UI loop" on which the ProfileSyncService lives and 463 // This serves as the "UI loop" on which the ProfileSyncService lives and
460 // operates. It is needed because the SyncBackend can post tasks back to 464 // operates. It is needed because the SyncBackend can post tasks back to
461 // the service, meaning it can't be null. It doesn't have to be running, 465 // the service, meaning it can't be null. It doesn't have to be running,
462 // though -- OnInitializationCompleted is the only example (so far) in this 466 // though -- OnInitializationCompleted is the only example (so far) in this
463 // test where we need to Run the loop to swallow a task and then quit, to 467 // test where we need to Run the loop to swallow a task and then quit, to
464 // avoid leaking the ProfileSyncService (the PostTask will retain the callee 468 // avoid leaking the ProfileSyncService (the PostTask will retain the callee
465 // and caller until the task is run). 469 // and caller until the task is run).
466 MessageLoop message_loop_; 470 MessageLoop message_loop_;
471 ChromeThread ui_thread_;
472 ChromeThread file_thread_;
467 473
468 scoped_ptr<ProfileSyncService> service_; 474 scoped_ptr<ProfileSyncService> service_;
469 scoped_ptr<TestingProfile> profile_; 475 scoped_ptr<TestingProfile> profile_;
470 BookmarkModel* model_; 476 BookmarkModel* model_;
471 }; 477 };
472 478
473 TEST_F(ProfileSyncServiceTest, InitialState) { 479 TEST_F(ProfileSyncServiceTest, InitialState) {
474 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 480 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
475 StartSyncService(); 481 StartSyncService();
476 482
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1299
1294 // Restart the sync service. 1300 // Restart the sync service.
1295 StartSyncService(); 1301 StartSyncService();
1296 1302
1297 // Make sure we're back in sync. In real life, the user would need 1303 // Make sure we're back in sync. In real life, the user would need
1298 // to reauthenticate before this happens, but in the test, authentication 1304 // to reauthenticate before this happens, but in the test, authentication
1299 // is sidestepped. 1305 // is sidestepped.
1300 ExpectBookmarkModelMatchesTestData(); 1306 ExpectBookmarkModelMatchesTestData();
1301 ExpectModelMatch(); 1307 ExpectModelMatch();
1302 } 1308 }
OLDNEW
« no previous file with comments | « chrome/browser/strict_transport_security_persister.cc ('k') | chrome/browser/sync/sync_setup_wizard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698