OLD | NEW |
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 Loading... |
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 new ProfileSyncComponentsFactoryImpl( | 109 scoped_ptr<ProfileSyncComponentsFactory>( |
110 profile_.get(), | 110 new ProfileSyncComponentsFactoryImpl( |
111 command_line_.get(), | 111 profile_.get(), |
112 ProfileSyncService::GetSyncServiceURL(*command_line_), | 112 command_line_.get(), |
113 token_service, | 113 ProfileSyncService::GetSyncServiceURL(*command_line_), |
114 profile_->GetRequestContext()), | 114 token_service, |
| 115 profile_->GetRequestContext())), |
115 profile_.get(), | 116 profile_.get(), |
116 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), | 117 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), |
117 token_service, | 118 token_service, |
118 browser_sync::MANUAL_START)); | 119 browser_sync::MANUAL_START)); |
119 pss->factory()->RegisterDataTypes(pss.get()); | 120 pss->factory()->RegisterDataTypes(pss.get()); |
120 DataTypeController::StateMap controller_states; | 121 DataTypeController::StateMap controller_states; |
121 pss->GetDataTypeControllerStates(&controller_states); | 122 pss->GetDataTypeControllerStates(&controller_states); |
122 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size()); | 123 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size()); |
123 CheckDefaultDatatypesInMapExcept(&controller_states, types); | 124 CheckDefaultDatatypesInMapExcept(&controller_states, types); |
124 } | 125 } |
125 | 126 |
126 content::TestBrowserThreadBundle thread_bundle_; | 127 content::TestBrowserThreadBundle thread_bundle_; |
127 scoped_ptr<Profile> profile_; | 128 scoped_ptr<Profile> profile_; |
128 scoped_ptr<CommandLine> command_line_; | 129 scoped_ptr<CommandLine> command_line_; |
129 OAuth2TokenService::ScopeSet scope_set_; | 130 OAuth2TokenService::ScopeSet scope_set_; |
130 }; | 131 }; |
131 | 132 |
132 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { | 133 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { |
133 ProfileOAuth2TokenService* token_service = | 134 ProfileOAuth2TokenService* token_service = |
134 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 135 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); |
135 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( | 136 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( |
136 new ProfileSyncComponentsFactoryImpl( | 137 scoped_ptr<ProfileSyncComponentsFactory>( |
137 profile_.get(), | 138 new ProfileSyncComponentsFactoryImpl( |
138 command_line_.get(), | 139 profile_.get(), |
139 ProfileSyncService::GetSyncServiceURL(*command_line_), | 140 command_line_.get(), |
140 token_service, | 141 ProfileSyncService::GetSyncServiceURL(*command_line_), |
141 profile_->GetRequestContext()), | 142 token_service, |
| 143 profile_->GetRequestContext())), |
142 profile_.get(), | 144 profile_.get(), |
143 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), | 145 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), |
144 token_service, | 146 token_service, |
145 browser_sync::MANUAL_START)); | 147 browser_sync::MANUAL_START)); |
146 pss->factory()->RegisterDataTypes(pss.get()); | 148 pss->factory()->RegisterDataTypes(pss.get()); |
147 DataTypeController::StateMap controller_states; | 149 DataTypeController::StateMap controller_states; |
148 pss->GetDataTypeControllerStates(&controller_states); | 150 pss->GetDataTypeControllerStates(&controller_states); |
149 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); | 151 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); |
150 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet()); | 152 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet()); |
151 } | 153 } |
152 | 154 |
153 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) { | 155 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) { |
154 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL)); | 156 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL)); |
155 } | 157 } |
156 | 158 |
157 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) { | 159 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) { |
158 TestSwitchDisablesType( | 160 TestSwitchDisablesType( |
159 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS)); | 161 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS)); |
160 } | 162 } |
OLD | NEW |