Chromium Code Reviews| Index: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
| diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
| index 9700e10de3c06a22986710227fd8d5137449976b..5bdddee9a00ad818aac107b72305c054f735d893 100644 |
| --- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
| +++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/test/base/profile_mock.h" |
| #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
| #include "components/webdata/common/web_data_service_test_util.h" |
| +#include "components/webdata/common/web_database_observer.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/notification_types.h" |
| @@ -46,13 +47,15 @@ class FakeWebDataService : public AutofillWebDataService { |
| FakeWebDataService() |
| : AutofillWebDataService( |
| NULL, WebDataServiceBase::ProfileErrorCallback()), |
| - is_database_loaded_(false) {} |
| + is_database_loaded_(false), |
| + observer_(NULL) {} |
| // Mark the database as loaded and send out the appropriate notification. |
| void LoadDatabase() { |
| StartSyncableService(); |
| is_database_loaded_ = true; |
| - NotifyDatabaseLoadedOnUIThread(); |
| + if (observer_) |
| + observer_->WebDatabaseLoaded(); |
| } |
| virtual bool IsDatabaseLoaded() OVERRIDE { |
| @@ -69,6 +72,20 @@ class FakeWebDataService : public AutofillWebDataService { |
| run_loop.Run(); |
| } |
| + // Note: this implementation violates the contract for AddDBObserver (which |
| + // should support having multiple observers at the same time), however, it |
| + // is the simplest thing that works for the purpose of the unit test, which |
| + // only registers one observer. |
| + virtual void AddDBObserver(WebDatabaseObserver* observer) OVERRIDE { |
|
dhollowa
2013/04/18 16:21:17
How about a DCHECK(!observer_) to enforce this.
Cait (Slow)
2013/04/19 19:06:22
Done.
|
| + observer_ = observer; |
| + } |
| + |
| + virtual void RemoveDBObserver(WebDatabaseObserver* observer) OVERRIDE { |
| + if (observer_ == observer) { |
|
dhollowa
2013/04/18 16:21:17
DCHECK_EQ (observer_, observer)
Cait (Slow)
2013/04/19 19:06:22
Done.
|
| + observer_ = NULL; |
| + } |
| + } |
| + |
| void StartSyncableService() { |
| // The |autofill_profile_syncable_service_| must be constructed on the DB |
| // thread. |
| @@ -107,6 +124,8 @@ class FakeWebDataService : public AutofillWebDataService { |
| bool is_database_loaded_; |
| + WebDatabaseObserver* observer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(FakeWebDataService); |
| }; |