[email protected] | 72a31b4 | 2010-02-17 22:26:33 | [diff] [blame^] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/message_loop.h" |
| 11 | #include "chrome/browser/profile.h" |
| 12 | #include "chrome/browser/sync/profile_sync_service.h" |
| 13 | #include "chrome/test/sync/test_http_bridge_factory.h" |
| 14 | |
| 15 | class TestProfileSyncService : public ProfileSyncService { |
| 16 | public: |
| 17 | explicit TestProfileSyncService(Profile* profile, |
| 18 | bool bootstrap_sync_authentication) |
| 19 | : ProfileSyncService(profile, bootstrap_sync_authentication) { |
| 20 | RegisterPreferences(); |
| 21 | SetSyncSetupCompleted(); |
| 22 | } |
| 23 | virtual ~TestProfileSyncService() { |
| 24 | } |
| 25 | |
| 26 | virtual void InitializeBackend(bool delete_sync_data_folder) { |
| 27 | browser_sync::TestHttpBridgeFactory* factory = |
| 28 | new browser_sync::TestHttpBridgeFactory(); |
| 29 | browser_sync::TestHttpBridgeFactory* factory2 = |
| 30 | new browser_sync::TestHttpBridgeFactory(); |
| 31 | backend()->InitializeForTestMode(L"testuser", factory, factory2, |
| 32 | delete_sync_data_folder, browser_sync::kDefaultNotificationMethod); |
| 33 | // The SyncBackend posts a task to the current loop when initialization |
| 34 | // completes. |
| 35 | MessageLoop::current()->Run(); |
| 36 | // Initialization is synchronous for test mode, so we should be good to go. |
| 37 | DCHECK(sync_initialized()); |
| 38 | } |
| 39 | |
| 40 | virtual void OnBackendInitialized() { |
| 41 | ProfileSyncService::OnBackendInitialized(); |
| 42 | MessageLoop::current()->Quit(); |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | // When testing under ChromiumOS, this method must not return an empty |
| 47 | // value value in order for the profile sync service to start. |
| 48 | virtual std::string GetLsidForAuthBootstraping() { |
| 49 | return "foo"; |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |