chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
// Start the autofill DTC without the WDS's database loaded, then
// start the DB.  The Autofill DTC should be in the MODEL_STARTING
// state until the database in loaded, when it should try to start
// association and fail (due to missing DB thread).
Start the autofill DTC without the WDS's database loaded, then
start the DB.  The Autofill DTC should be in the MODEL_STARTING
state until the database in loaded, when it should try to start
association and fail (due to missing DB thread).
Start the autofill DTC without the WDS ' s database loaded then start the DB . The Autofill DTC should be in the MODEL_STARTING state until the database in loaded when it should try to start association and fail ( due to missing DB thread ) .
TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) {
  autofill_dtc_->LoadModels(
    base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished,
               weak_ptr_factory_.GetWeakPtr()));
  EXPECT_EQ(DataTypeController::OK, last_start_result_);
  EXPECT_FALSE(last_start_error_.IsSet());
  EXPECT_EQ(DataTypeController::MODEL_STARTING, autofill_dtc_->state());
  FakeWebDataService* web_db =
      static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile(
          &profile_, Profile::EXPLICIT_ACCESS).get());
  web_db->LoadDatabase();
  EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_))
      .WillOnce(Return(base::WeakPtr<syncer::SyncableService>()));
  autofill_dtc_->StartAssociating(
      base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished,
                 weak_ptr_factory_.GetWeakPtr()));
  BlockForDBThread();
  EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_);
  EXPECT_TRUE(last_start_error_.IsSet());
  EXPECT_EQ(DataTypeController::DISABLED, autofill_dtc_->state());
}
TEST_F ( SyncAutofillDataTypeControllerTest , StartWDSNotReady ) { autofill_dtc_ -> LoadModels ( base :: Bind ( & SyncAutofillDataTypeControllerTest :: OnLoadFinished , weak_ptr_factory_ . GetWeakPtr ( ) ) ) ; EXPECT_EQ ( DataTypeController :: OK , last_start_result_ ) ; EXPECT_FALSE ( last_start_error_ . IsSet ( ) ) ; EXPECT_EQ ( DataTypeController :: MODEL_STARTING , autofill_dtc_ -> state ( ) ) ; FakeWebDataService * web_db = static_cast < FakeWebDataService * > ( WebDataServiceFactory :: GetForProfile ( & profile_ , Profile :: EXPLICIT_ACCESS ) . get ( ) ) ; web_db -> LoadDatabase ( ) ; EXPECT_CALL ( * change_processor_ , Connect ( _ , _ , _ , _ , _ ) ) . WillOnce ( Return ( base :: WeakPtr < syncer :: SyncableService > ( ) ) ) ; autofill_dtc_ -> StartAssociating ( base :: Bind ( & SyncAutofillDataTypeControllerTest :: OnStartFinished , weak_ptr_factory_ . GetWeakPtr ( ) ) ) ; BlockForDBThread ( ) ; EXPECT_EQ ( DataTypeController :: ASSOCIATION_FAILED , last_start_result_ ) ; EXPECT_TRUE ( last_start_error_ . IsSet ( ) ) ; EXPECT_EQ ( DataTypeController :: DISABLED , autofill_dtc_ -> state ( ) ) ; }
Start the autofill DTC without the WDS's database loaded, then
start the DB.
Start the autofill DTC without the WDS ' s database loaded then start the DB .