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

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

Issue 936673002: DCHECK that ProfileSyncService is created on the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove snap_. Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/backend_migrator.h" 5 #include "chrome/browser/sync/backend_migrator.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h"
8 #include "base/tracked_objects.h" 9 #include "base/tracked_objects.h"
9 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/sync/profile_sync_service_mock.h" 11 #include "chrome/browser/sync/profile_sync_service_mock.h"
11 #include "components/sync_driver/data_type_manager_mock.h" 12 #include "components/sync_driver/data_type_manager_mock.h"
13 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "sync/internal_api/public/base/model_type_test_util.h" 14 #include "sync/internal_api/public/base/model_type_test_util.h"
13 #include "sync/internal_api/public/test/test_user_share.h" 15 #include "sync/internal_api/public/test/test_user_share.h"
14 #include "sync/internal_api/public/write_transaction.h" 16 #include "sync/internal_api/public/write_transaction.h"
15 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
16 #include "sync/syncable/directory.h" // TODO(tim): Remove. Bug 131130. 18 #include "sync/syncable/directory.h" // TODO(tim): Remove. Bug 131130.
17 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 using ::testing::_; 22 using ::testing::_;
21 using ::testing::Eq; 23 using ::testing::Eq;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 syncer::ModelTypeSet requested_types) { 79 syncer::ModelTypeSet requested_types) {
78 if (status == DataTypeManager::OK) { 80 if (status == DataTypeManager::OK) {
79 DataTypeManager::ConfigureResult result(status, requested_types); 81 DataTypeManager::ConfigureResult result(status, requested_types);
80 migrator_->OnConfigureDone(result); 82 migrator_->OnConfigureDone(result);
81 } else { 83 } else {
82 DataTypeManager::ConfigureResult result( 84 DataTypeManager::ConfigureResult result(
83 status, 85 status,
84 requested_types); 86 requested_types);
85 migrator_->OnConfigureDone(result); 87 migrator_->OnConfigureDone(result);
86 } 88 }
87 message_loop_.RunUntilIdle(); 89 base::RunLoop run_loop;
90 run_loop.RunUntilIdle();
88 } 91 }
89 92
90 ProfileSyncService* service() { return &service_; } 93 ProfileSyncService* service() { return &service_; }
91 DataTypeManagerMock* manager() { return &manager_; } 94 DataTypeManagerMock* manager() { return &manager_; }
92 syncer::ModelTypeSet preferred_types() { return preferred_types_; } 95 syncer::ModelTypeSet preferred_types() { return preferred_types_; }
93 BackendMigrator* migrator() { return migrator_.get(); } 96 BackendMigrator* migrator() { return migrator_.get(); }
94 void RemovePreferredType(syncer::ModelType type) { 97 void RemovePreferredType(syncer::ModelType type) {
95 preferred_types_.Remove(type); 98 preferred_types_.Remove(type);
96 Mock::VerifyAndClear(&service_); 99 Mock::VerifyAndClear(&service_);
97 ON_CALL(service_, GetPreferredDataTypes()). 100 ON_CALL(service_, GetPreferredDataTypes()).
98 WillByDefault(Return(preferred_types_)); 101 WillByDefault(Return(preferred_types_));
99 } 102 }
100 103
101 private: 104 private:
102 scoped_ptr<SyncSessionSnapshot> snap_; 105 content::TestBrowserThreadBundle thread_bundle_;
103 base::MessageLoop message_loop_;
104 syncer::ModelTypeSet preferred_types_; 106 syncer::ModelTypeSet preferred_types_;
105 TestingProfile profile_; 107 TestingProfile profile_;
106 NiceMock<ProfileSyncServiceMock> service_; 108 NiceMock<ProfileSyncServiceMock> service_;
107 NiceMock<DataTypeManagerMock> manager_; 109 NiceMock<DataTypeManagerMock> manager_;
108 syncer::TestUserShare test_user_share_; 110 syncer::TestUserShare test_user_share_;
109 scoped_ptr<BackendMigrator> migrator_; 111 scoped_ptr<BackendMigrator> migrator_;
110 }; 112 };
111 113
112 class MockMigrationObserver : public MigrationObserver { 114 class MockMigrationObserver : public MigrationObserver {
113 public: 115 public:
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 EXPECT_CALL( 333 EXPECT_CALL(
332 *manager(), 334 *manager(),
333 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION)).Times(1); 335 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION)).Times(1);
334 migrator()->MigrateTypes(to_migrate); 336 migrator()->MigrateTypes(to_migrate);
335 SetUnsyncedTypes(syncer::ModelTypeSet()); 337 SetUnsyncedTypes(syncer::ModelTypeSet());
336 SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet()); 338 SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet());
337 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); 339 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
338 } 340 }
339 341
340 }; // namespace browser_sync 342 }; // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698