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

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

Issue 401433003: Revert of Sync: Refactoring of DEVICE_INFO syncable type - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Asserts that if you disable types via the command line, all other types 99 // Asserts that if you disable types via the command line, all other types
100 // are enabled. 100 // are enabled.
101 void TestSwitchDisablesType(syncer::ModelTypeSet types) { 101 void TestSwitchDisablesType(syncer::ModelTypeSet types) {
102 command_line_->AppendSwitchASCII(switches::kDisableSyncTypes, 102 command_line_->AppendSwitchASCII(switches::kDisableSyncTypes,
103 syncer::ModelTypeSetToString(types)); 103 syncer::ModelTypeSetToString(types));
104 GURL sync_service_url = 104 GURL sync_service_url =
105 ProfileSyncService::GetSyncServiceURL(*command_line_); 105 ProfileSyncService::GetSyncServiceURL(*command_line_);
106 ProfileOAuth2TokenService* token_service = 106 ProfileOAuth2TokenService* token_service =
107 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); 107 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
108 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( 108 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService(
109 scoped_ptr<ProfileSyncComponentsFactory>( 109 new ProfileSyncComponentsFactoryImpl(
110 new ProfileSyncComponentsFactoryImpl( 110 profile_.get(),
111 profile_.get(), 111 command_line_.get(),
112 command_line_.get(), 112 ProfileSyncService::GetSyncServiceURL(*command_line_),
113 ProfileSyncService::GetSyncServiceURL(*command_line_), 113 token_service,
114 token_service, 114 profile_->GetRequestContext()),
115 profile_->GetRequestContext())),
116 profile_.get(), 115 profile_.get(),
117 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), 116 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL),
118 token_service, 117 token_service,
119 browser_sync::MANUAL_START)); 118 browser_sync::MANUAL_START));
120 pss->factory()->RegisterDataTypes(pss.get()); 119 pss->factory()->RegisterDataTypes(pss.get());
121 DataTypeController::StateMap controller_states; 120 DataTypeController::StateMap controller_states;
122 pss->GetDataTypeControllerStates(&controller_states); 121 pss->GetDataTypeControllerStates(&controller_states);
123 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size()); 122 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size());
124 CheckDefaultDatatypesInMapExcept(&controller_states, types); 123 CheckDefaultDatatypesInMapExcept(&controller_states, types);
125 } 124 }
126 125
127 content::TestBrowserThreadBundle thread_bundle_; 126 content::TestBrowserThreadBundle thread_bundle_;
128 scoped_ptr<Profile> profile_; 127 scoped_ptr<Profile> profile_;
129 scoped_ptr<CommandLine> command_line_; 128 scoped_ptr<CommandLine> command_line_;
130 OAuth2TokenService::ScopeSet scope_set_; 129 OAuth2TokenService::ScopeSet scope_set_;
131 }; 130 };
132 131
133 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { 132 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) {
134 ProfileOAuth2TokenService* token_service = 133 ProfileOAuth2TokenService* token_service =
135 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); 134 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
136 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( 135 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService(
137 scoped_ptr<ProfileSyncComponentsFactory>( 136 new ProfileSyncComponentsFactoryImpl(
138 new ProfileSyncComponentsFactoryImpl( 137 profile_.get(),
139 profile_.get(), 138 command_line_.get(),
140 command_line_.get(), 139 ProfileSyncService::GetSyncServiceURL(*command_line_),
141 ProfileSyncService::GetSyncServiceURL(*command_line_), 140 token_service,
142 token_service, 141 profile_->GetRequestContext()),
143 profile_->GetRequestContext())),
144 profile_.get(), 142 profile_.get(),
145 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), 143 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL),
146 token_service, 144 token_service,
147 browser_sync::MANUAL_START)); 145 browser_sync::MANUAL_START));
148 pss->factory()->RegisterDataTypes(pss.get()); 146 pss->factory()->RegisterDataTypes(pss.get());
149 DataTypeController::StateMap controller_states; 147 DataTypeController::StateMap controller_states;
150 pss->GetDataTypeControllerStates(&controller_states); 148 pss->GetDataTypeControllerStates(&controller_states);
151 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); 149 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size());
152 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet()); 150 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet());
153 } 151 }
154 152
155 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) { 153 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) {
156 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL)); 154 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL));
157 } 155 }
158 156
159 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) { 157 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) {
160 TestSwitchDisablesType( 158 TestSwitchDisablesType(
161 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS)); 159 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS));
162 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698