| OLD | NEW |
| 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 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
| 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 AbstractProfileSyncServiceTest(); | 45 AbstractProfileSyncServiceTest(); |
| 46 ~AbstractProfileSyncServiceTest() override; | 46 ~AbstractProfileSyncServiceTest() override; |
| 47 | 47 |
| 48 bool CreateRoot(syncer::ModelType model_type); | 48 bool CreateRoot(syncer::ModelType model_type); |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 // Creates a TestProfileSyncService instance based on | 51 // Creates a TestProfileSyncService instance based on |
| 52 // |profile_sync_service_bundle_|, with start behavior | 52 // |profile_sync_service_bundle_|, with start behavior |
| 53 // browser_sync::AUTO_START. Passes |callback| down to | 53 // browser_sync::AUTO_START. Passes |callback| down to |
| 54 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess. | 54 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess. |
| 55 // |sync_client| is passed to the service. | 55 // |sync_client| is passed to the service. The created service is stored in |
| 56 scoped_ptr<TestProfileSyncService> CreateSyncService( | 56 // |sync_service_|. |
| 57 scoped_ptr<sync_driver::SyncClient> sync_client, | 57 void CreateSyncService(scoped_ptr<sync_driver::SyncClient> sync_client, |
| 58 const base::Closure& initialization_success_callback); | 58 const base::Closure& initialization_success_callback); |
| 59 | 59 |
| 60 base::Thread* data_type_thread() { return &data_type_thread_; } |
| 61 |
| 62 TestProfileSyncService* sync_service() { return sync_service_.get(); } |
| 63 |
| 64 // Returns the callback for the FakeSyncClient builder. It is not possible to |
| 65 // just Bind() sync_service(), because of Callback not understanding the |
| 66 // inheritance of its template arguments. |
| 67 base::Callback<sync_driver::SyncService*(void)> GetSyncServiceCallback(); |
| 68 |
| 69 browser_sync::ProfileSyncServiceBundle* profile_sync_service_bundle() { |
| 70 return &profile_sync_service_bundle_; |
| 71 } |
| 72 |
| 73 private: |
| 60 // Use |data_type_thread_| for code disallowed on the UI thread. | 74 // Use |data_type_thread_| for code disallowed on the UI thread. |
| 61 base::Thread data_type_thread_; | 75 base::Thread data_type_thread_; |
| 62 | 76 |
| 63 base::MessageLoop message_loop_; | 77 base::MessageLoop message_loop_; |
| 64 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_; | 78 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_; |
| 65 scoped_ptr<TestProfileSyncService> sync_service_; | 79 scoped_ptr<TestProfileSyncService> sync_service_; |
| 66 | 80 |
| 67 private: | |
| 68 base::ScopedTempDir temp_dir_; // To pass to the backend host. | 81 base::ScopedTempDir temp_dir_; // To pass to the backend host. |
| 69 | 82 |
| 70 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest); | 83 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest); |
| 71 }; | 84 }; |
| 72 | 85 |
| 73 class CreateRootHelper { | 86 class CreateRootHelper { |
| 74 public: | 87 public: |
| 75 CreateRootHelper(AbstractProfileSyncServiceTest* test, | 88 CreateRootHelper(AbstractProfileSyncServiceTest* test, |
| 76 syncer::ModelType model_type); | 89 syncer::ModelType model_type); |
| 77 virtual ~CreateRootHelper(); | 90 virtual ~CreateRootHelper(); |
| 78 | 91 |
| 79 const base::Closure& callback() const; | 92 const base::Closure& callback() const; |
| 80 bool success(); | 93 bool success(); |
| 81 | 94 |
| 82 private: | 95 private: |
| 83 void CreateRootCallback(); | 96 void CreateRootCallback(); |
| 84 | 97 |
| 85 base::Closure callback_; | 98 base::Closure callback_; |
| 86 AbstractProfileSyncServiceTest* test_; | 99 AbstractProfileSyncServiceTest* test_; |
| 87 syncer::ModelType model_type_; | 100 syncer::ModelType model_type_; |
| 88 bool success_; | 101 bool success_; |
| 89 | 102 |
| 90 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper); | 103 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper); |
| 91 }; | 104 }; |
| 92 | 105 |
| 93 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 106 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
| OLD | NEW |