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

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

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/sync/abstract_profile_sync_service_test.h" 5 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/run_loop.h"
10 #include "chrome/browser/sync/test_profile_sync_service.h" 11 #include "chrome/browser/sync/test_profile_sync_service.h"
12 #include "content/public/test/test_utils.h"
11 #include "sync/internal_api/public/test/test_user_share.h" 13 #include "sync/internal_api/public/test/test_user_share.h"
12 #include "sync/internal_api/public/write_transaction.h" 14 #include "sync/internal_api/public/write_transaction.h"
13 #include "sync/protocol/sync.pb.h" 15 #include "sync/protocol/sync.pb.h"
14 #include "sync/util/cryptographer.h" 16 #include "sync/util/cryptographer.h"
15 17
16 using content::BrowserThread;
17 using syncer::ModelType; 18 using syncer::ModelType;
18 using syncer::UserShare; 19 using syncer::UserShare;
19 20
20 /* static */ 21 /* static */
21 syncer::ImmutableChangeRecordList 22 syncer::ImmutableChangeRecordList
22 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( 23 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList(
23 int64 node_id, syncer::ChangeRecord::Action action) { 24 int64 node_id, syncer::ChangeRecord::Action action) {
24 syncer::ChangeRecord record; 25 syncer::ChangeRecord record;
25 record.action = action; 26 record.action = action;
26 record.id = node_id; 27 record.id = node_id;
27 syncer::ChangeRecordList records(1, record); 28 syncer::ChangeRecordList records(1, record);
28 return syncer::ImmutableChangeRecordList(&records); 29 return syncer::ImmutableChangeRecordList(&records);
29 } 30 }
30 31
31 /* static */ 32 /* static */
32 syncer::ImmutableChangeRecordList 33 syncer::ImmutableChangeRecordList
33 ProfileSyncServiceTestHelper::MakeSingletonDeletionChangeRecordList( 34 ProfileSyncServiceTestHelper::MakeSingletonDeletionChangeRecordList(
34 int64 node_id, const sync_pb::EntitySpecifics& specifics) { 35 int64 node_id, const sync_pb::EntitySpecifics& specifics) {
35 syncer::ChangeRecord record; 36 syncer::ChangeRecord record;
36 record.action = syncer::ChangeRecord::ACTION_DELETE; 37 record.action = syncer::ChangeRecord::ACTION_DELETE;
37 record.id = node_id; 38 record.id = node_id;
38 record.specifics = specifics; 39 record.specifics = specifics;
39 syncer::ChangeRecordList records(1, record); 40 syncer::ChangeRecordList records(1, record);
40 return syncer::ImmutableChangeRecordList(&records); 41 return syncer::ImmutableChangeRecordList(&records);
41 } 42 }
42 43
43 AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest() 44 AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest()
44 : ui_thread_(BrowserThread::UI, &ui_loop_), 45 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD |
45 db_thread_(BrowserThread::DB), 46 content::TestBrowserThreadBundle::REAL_FILE_THREAD |
46 file_thread_(BrowserThread::FILE), 47 content::TestBrowserThreadBundle::REAL_IO_THREAD),
47 io_thread_(BrowserThread::IO),
48 token_service_(NULL), 48 token_service_(NULL),
49 sync_service_(NULL) { 49 sync_service_(NULL) {
50 } 50 }
51 51
52 AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {} 52 AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {}
53 53
54 void AbstractProfileSyncServiceTest::SetUp() { 54 void AbstractProfileSyncServiceTest::SetUp() {
55 db_thread_.Start();
56 file_thread_.Start();
57 io_thread_.StartIOThread();
58 } 55 }
59 56
60 void AbstractProfileSyncServiceTest::TearDown() { 57 void AbstractProfileSyncServiceTest::TearDown() {
61 // Pump messages posted by the sync core thread (which may end up 58 // Pump messages posted by the sync core thread (which may end up
62 // posting on the IO thread). 59 // posting on the IO thread).
63 ui_loop_.RunUntilIdle(); 60 base::RunLoop().RunUntilIdle();
64 io_thread_.Stop(); 61 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
65 file_thread_.Stop(); 62 base::RunLoop().RunUntilIdle();
66 db_thread_.Stop();
67 ui_loop_.RunUntilIdle();
68 } 63 }
69 64
70 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) { 65 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) {
71 return syncer::TestUserShare::CreateRoot(model_type, 66 return syncer::TestUserShare::CreateRoot(model_type,
72 sync_service_->GetUserShare()); 67 sync_service_->GetUserShare());
73 } 68 }
74 69
75 // static 70 // static
76 BrowserContextKeyedService* AbstractProfileSyncServiceTest::BuildTokenService( 71 BrowserContextKeyedService* AbstractProfileSyncServiceTest::BuildTokenService(
77 content::BrowserContext* profile) { 72 content::BrowserContext* profile) {
(...skipping 16 matching lines...) Expand all
94 return callback_; 89 return callback_;
95 } 90 }
96 91
97 bool CreateRootHelper::success() { 92 bool CreateRootHelper::success() {
98 return success_; 93 return success_;
99 } 94 }
100 95
101 void CreateRootHelper::CreateRootCallback() { 96 void CreateRootHelper::CreateRootCallback() {
102 success_ = test_->CreateRoot(model_type_); 97 success_ = test_->CreateRoot(model_type_);
103 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698