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

Side by Side Diff: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // thread). 240 // thread).
241 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) { 241 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) {
242 FakeWebDataService* web_db = 242 FakeWebDataService* web_db =
243 static_cast<FakeWebDataService*>( 243 static_cast<FakeWebDataService*>(
244 AutofillWebDataService::FromBrowserContext(&profile_).get()); 244 AutofillWebDataService::FromBrowserContext(&profile_).get());
245 web_db->LoadDatabase(); 245 web_db->LoadDatabase();
246 autofill_dtc_->LoadModels( 246 autofill_dtc_->LoadModels(
247 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished, 247 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished,
248 weak_ptr_factory_.GetWeakPtr())); 248 weak_ptr_factory_.GetWeakPtr()));
249 249
250 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)) 250 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
251 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>())); 251 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>()));
252 autofill_dtc_->StartAssociating( 252 autofill_dtc_->StartAssociating(
253 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished, 253 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished,
254 weak_ptr_factory_.GetWeakPtr())); 254 weak_ptr_factory_.GetWeakPtr()));
255 BlockForDBThread(); 255 BlockForDBThread();
256 256
257 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_); 257 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_);
258 EXPECT_TRUE(last_start_error_.IsSet()); 258 EXPECT_TRUE(last_start_error_.IsSet());
259 EXPECT_EQ(DataTypeController::DISABLED, autofill_dtc_->state()); 259 EXPECT_EQ(DataTypeController::DISABLED, autofill_dtc_->state());
260 } 260 }
261 261
262 // Start the autofill DTC without the WDS's database loaded, then 262 // Start the autofill DTC without the WDS's database loaded, then
263 // start the DB. The Autofill DTC should be in the MODEL_STARTING 263 // start the DB. The Autofill DTC should be in the MODEL_STARTING
264 // state until the database in loaded, when it should try to start 264 // state until the database in loaded, when it should try to start
265 // association and fail (due to missing DB thread). 265 // association and fail (due to missing DB thread).
266 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) { 266 TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) {
267 autofill_dtc_->LoadModels( 267 autofill_dtc_->LoadModels(
268 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished, 268 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished,
269 weak_ptr_factory_.GetWeakPtr())); 269 weak_ptr_factory_.GetWeakPtr()));
270 270
271 EXPECT_EQ(DataTypeController::OK, last_start_result_); 271 EXPECT_EQ(DataTypeController::OK, last_start_result_);
272 EXPECT_FALSE(last_start_error_.IsSet()); 272 EXPECT_FALSE(last_start_error_.IsSet());
273 EXPECT_EQ(DataTypeController::MODEL_STARTING, autofill_dtc_->state()); 273 EXPECT_EQ(DataTypeController::MODEL_STARTING, autofill_dtc_->state());
274 274
275 FakeWebDataService* web_db = 275 FakeWebDataService* web_db =
276 static_cast<FakeWebDataService*>( 276 static_cast<FakeWebDataService*>(
277 AutofillWebDataService::FromBrowserContext(&profile_).get()); 277 AutofillWebDataService::FromBrowserContext(&profile_).get());
278 web_db->LoadDatabase(); 278 web_db->LoadDatabase();
279 279
280 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)) 280 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
281 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>())); 281 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>()));
282 autofill_dtc_->StartAssociating( 282 autofill_dtc_->StartAssociating(
283 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished, 283 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished,
284 weak_ptr_factory_.GetWeakPtr())); 284 weak_ptr_factory_.GetWeakPtr()));
285 BlockForDBThread(); 285 BlockForDBThread();
286 286
287 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_); 287 EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_);
288 EXPECT_TRUE(last_start_error_.IsSet()); 288 EXPECT_TRUE(last_start_error_.IsSet());
289 289
290 EXPECT_EQ(DataTypeController::DISABLED, autofill_dtc_->state()); 290 EXPECT_EQ(DataTypeController::DISABLED, autofill_dtc_->state());
(...skipping 11 matching lines...) Expand all
302 experiments.autofill_culling = true; 302 experiments.autofill_culling = true;
303 sync->OnExperimentsChanged(experiments); 303 sync->OnExperimentsChanged(experiments);
304 304
305 web_db->LoadDatabase(); 305 web_db->LoadDatabase();
306 autofill_dtc_->LoadModels( 306 autofill_dtc_->LoadModels(
307 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished, 307 base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished,
308 weak_ptr_factory_.GetWeakPtr())); 308 weak_ptr_factory_.GetWeakPtr()));
309 309
310 EXPECT_FALSE(web_db->CheckAutofillCullingValue()); 310 EXPECT_FALSE(web_db->CheckAutofillCullingValue());
311 311
312 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)) 312 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
313 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>())); 313 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>()));
314 autofill_dtc_->StartAssociating( 314 autofill_dtc_->StartAssociating(
315 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished, 315 base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished,
316 weak_ptr_factory_.GetWeakPtr())); 316 weak_ptr_factory_.GetWeakPtr()));
317 BlockForDBThread(); 317 BlockForDBThread();
318 318
319 EXPECT_TRUE(web_db->CheckAutofillCullingValue()); 319 EXPECT_TRUE(web_db->CheckAutofillCullingValue());
320 } 320 }
321 321
322 } // namespace 322 } // namespace
323 323
324 } // namespace browser_sync 324 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698