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

Unified Diff: chrome/browser/sync/test_profile_sync_service.h

Issue 3913005: sync: enable password sync by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/debug
Patch Set: fix mac again Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_test_util.h ('k') | chrome/browser/sync/test_profile_sync_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/test_profile_sync_service.h
diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h
index 3cad8dc41774d64417618f497dae57082fc759fd..b4115ad6ba732b30f480a9bb6bf2044e01d85c9b 100644
--- a/chrome/browser/sync/test_profile_sync_service.h
+++ b/chrome/browser/sync/test_profile_sync_service.h
@@ -22,6 +22,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/test/profile_mock.h"
#include "chrome/test/sync/test_http_bridge_factory.h"
+#include "chrome/test/sync/engine/test_id_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
using browser_sync::ModelSafeRoutingInfo;
@@ -33,6 +34,8 @@ using syncable::DirectoryManager;
using syncable::ModelType;
using syncable::ScopedDirLookup;
+class TestProfileSyncService;
+
ACTION_P(CallOnPaused, core) {
core->OnPaused();
};
@@ -60,7 +63,7 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
// this is false, configuring data types will require a syncer nudge.
// |synchronous_init| causes initialization to block until the syncapi has
// completed setting itself up and called us back.
- SyncBackendHostForProfileSyncTest(SyncFrontend* frontend,
+ SyncBackendHostForProfileSyncTest(TestProfileSyncService* service,
Profile* profile,
const FilePath& profile_path,
const DataTypeController::TypeMap& data_type_controllers,
@@ -68,114 +71,33 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
int num_expected_resumes,
int num_expected_pauses,
bool set_initial_sync_ended_on_init,
- bool synchronous_init)
- : browser_sync::SyncBackendHost(frontend, profile, profile_path,
- data_type_controllers),
- initial_condition_setup_task_(initial_condition_setup_task),
- set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init),
- synchronous_init_(synchronous_init) {
- // By default, the RequestPause and RequestResume methods will
- // send the confirmation notification and return true.
- ON_CALL(*this, RequestPause()).
- WillByDefault(testing::DoAll(CallOnPaused(core_),
- testing::Return(true)));
- ON_CALL(*this, RequestResume()).
- WillByDefault(testing::DoAll(CallOnResumed(core_),
- testing::Return(true)));
- ON_CALL(*this, RequestNudge()).WillByDefault(testing::Invoke(this,
- &SyncBackendHostForProfileSyncTest::
- SimulateSyncCycleCompletedInitialSyncEnded));
-
- EXPECT_CALL(*this, RequestPause()).Times(num_expected_pauses);
- EXPECT_CALL(*this, RequestResume()).Times(num_expected_resumes);
- EXPECT_CALL(*this, RequestNudge()).
- Times(set_initial_sync_ended_on_init ? 0 : 1);
- }
+ bool synchronous_init);
MOCK_METHOD0(RequestPause, bool());
MOCK_METHOD0(RequestResume, bool());
MOCK_METHOD0(RequestNudge, void());
- void SetInitialSyncEndedForEnabledTypes() {
- UserShare* user_share = core_->syncapi()->GetUserShare();
- DirectoryManager* dir_manager = user_share->dir_manager.get();
-
- ScopedDirLookup dir(dir_manager, user_share->name);
- if (!dir.good())
- FAIL();
-
- ModelSafeRoutingInfo enabled_types;
- GetModelSafeRoutingInfo(&enabled_types);
- for (ModelSafeRoutingInfo::const_iterator i = enabled_types.begin();
- i != enabled_types.end(); ++i) {
- dir->set_initial_sync_ended_for_type(i->first, true);
- }
- }
+ void SetInitialSyncEndedForEnabledTypes();
- virtual void HandleInitializationCompletedOnFrontendLoop() {
- set_syncapi_initialized(); // Need to do this asap so task below works.
-
- // Set up any nodes the test wants around before model association.
- if (initial_condition_setup_task_) {
- initial_condition_setup_task_->Run();
- }
-
- // Pretend we downloaded initial updates and set initial sync ended bits
- // if we were asked to.
- if (set_initial_sync_ended_on_init_)
- SetInitialSyncEndedForEnabledTypes();
-
- SyncBackendHost::HandleInitializationCompletedOnFrontendLoop();
- }
+ virtual void HandleInitializationCompletedOnFrontendLoop();
// Called when a nudge comes in.
- void SimulateSyncCycleCompletedInitialSyncEnded() {
- syncable::ModelTypeBitSet sync_ended;
- ModelSafeRoutingInfo enabled_types;
- GetModelSafeRoutingInfo(&enabled_types);
- for (ModelSafeRoutingInfo::const_iterator i = enabled_types.begin();
- i != enabled_types.end(); ++i) {
- sync_ended.set(i->first);
- }
- core_->HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot(
- SyncerStatus(), ErrorCounters(), 0, 0, false,
- sync_ended, false, false, 0, 0, false));
- }
+ void SimulateSyncCycleCompletedInitialSyncEnded();
virtual sync_api::HttpPostProviderFactory* MakeHttpBridgeFactory(
URLRequestContextGetter* getter) {
return new browser_sync::TestHttpBridgeFactory;
}
- virtual void InitCore(const Core::DoInitializeOptions& options) {
- std::wstring user = L"testuser";
- core_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(core_.get(),
- &SyncBackendHost::Core::DoInitializeForTest,
- user,
- options.http_bridge_factory,
- options.delete_sync_data_folder));
+ virtual void InitCore(const Core::DoInitializeOptions& options);
- // TODO(akalin): Figure out a better way to do this.
- if (synchronous_init_) {
- // The SyncBackend posts a task to the current loop when
- // initialization completes.
- MessageLoop::current()->Run();
- }
- }
-
- static void SetDefaultExpectationsForWorkerCreation(ProfileMock* profile) {
- EXPECT_CALL(*profile, GetPasswordStore(testing::_)).
- WillOnce(testing::Return((PasswordStore*)NULL));
- EXPECT_CALL(*profile, GetHistoryService(testing::_)).
- WillOnce(testing::Return((HistoryService*)NULL));
- }
+ static void SetDefaultExpectationsForWorkerCreation(ProfileMock* profile);
private:
Task* initial_condition_setup_task_;
bool set_initial_sync_ended_on_init_;
bool synchronous_init_;
-
+ TestProfileSyncService* test_service_;
};
} // namespace browser_sync
@@ -186,49 +108,16 @@ class TestProfileSyncService : public ProfileSyncService {
Profile* profile,
const std::string& test_user,
bool synchronous_backend_initialization,
- Task* initial_condition_setup_task)
- : ProfileSyncService(factory, profile,
- !test_user.empty() ?
- test_user : ""),
- synchronous_backend_initialization_(
- synchronous_backend_initialization),
- synchronous_sync_configuration_(false),
- num_expected_resumes_(1),
- num_expected_pauses_(1),
- initial_condition_setup_task_(initial_condition_setup_task),
- set_initial_sync_ended_on_init_(true) {
- RegisterPreferences();
- SetSyncSetupCompleted();
- }
+ Task* initial_condition_setup_task);
virtual ~TestProfileSyncService() { }
- virtual void CreateBackend() {
- backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest(
- this, profile(),
- profile()->GetPath(), data_type_controllers(),
- initial_condition_setup_task_.release(),
- num_expected_resumes_, num_expected_pauses_,
- set_initial_sync_ended_on_init_,
- synchronous_backend_initialization_));
- }
+ virtual void CreateBackend();
- virtual void OnBackendInitialized() {
- ProfileSyncService::OnBackendInitialized();
- // TODO(akalin): Figure out a better way to do this.
- if (synchronous_backend_initialization_) {
- MessageLoop::current()->Quit();
- }
- }
+ virtual void OnBackendInitialized();
virtual void Observe(NotificationType type,
const NotificationSource& source,
- const NotificationDetails& details) {
- ProfileSyncService::Observe(type, source, details);
- if (type == NotificationType::SYNC_CONFIGURE_DONE &&
- !synchronous_sync_configuration_) {
- MessageLoop::current()->Quit();
- }
- }
+ const NotificationDetails& details);
void set_num_expected_resumes(int times) {
num_expected_resumes_ = times;
@@ -243,6 +132,8 @@ class TestProfileSyncService : public ProfileSyncService {
synchronous_sync_configuration_ = true;
}
+ browser_sync::TestIdFactory* id_factory() { return &id_factory_; }
+
private:
// When testing under ChromiumOS, this method must not return an empty
// value value in order for the profile sync service to start.
@@ -261,6 +152,8 @@ class TestProfileSyncService : public ProfileSyncService {
scoped_ptr<Task> initial_condition_setup_task_;
bool set_initial_sync_ended_on_init_;
+ browser_sync::TestIdFactory id_factory_;
+
};
#endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
« no previous file with comments | « chrome/browser/sync/profile_sync_test_util.h ('k') | chrome/browser/sync/test_profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698