| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
| 6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
| 7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
| 8 | 8 |
| 9 #include "sync/internal_api/sync_manager_impl.h" |
| 10 |
| 9 #include <cstddef> | 11 #include <cstddef> |
| 10 #include <map> | 12 #include <map> |
| 13 #include <utility> |
| 11 | 14 |
| 12 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 16 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 18 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/format_macros.h" | 19 #include "base/format_macros.h" |
| 17 #include "base/location.h" | 20 #include "base/location.h" |
| 18 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 20 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 #include "sync/internal_api/public/http_post_provider_factory.h" | 37 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 35 #include "sync/internal_api/public/http_post_provider_interface.h" | 38 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 36 #include "sync/internal_api/public/read_node.h" | 39 #include "sync/internal_api/public/read_node.h" |
| 37 #include "sync/internal_api/public/read_transaction.h" | 40 #include "sync/internal_api/public/read_transaction.h" |
| 38 #include "sync/internal_api/public/test/test_entry_factory.h" | 41 #include "sync/internal_api/public/test/test_entry_factory.h" |
| 39 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 42 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 40 #include "sync/internal_api/public/test/test_user_share.h" | 43 #include "sync/internal_api/public/test/test_user_share.h" |
| 41 #include "sync/internal_api/public/write_node.h" | 44 #include "sync/internal_api/public/write_node.h" |
| 42 #include "sync/internal_api/public/write_transaction.h" | 45 #include "sync/internal_api/public/write_transaction.h" |
| 43 #include "sync/internal_api/sync_encryption_handler_impl.h" | 46 #include "sync/internal_api/sync_encryption_handler_impl.h" |
| 44 #include "sync/internal_api/sync_manager_impl.h" | |
| 45 #include "sync/internal_api/syncapi_internal.h" | 47 #include "sync/internal_api/syncapi_internal.h" |
| 46 #include "sync/js/js_backend.h" | 48 #include "sync/js/js_backend.h" |
| 47 #include "sync/js/js_event_handler.h" | 49 #include "sync/js/js_event_handler.h" |
| 48 #include "sync/js/js_test_util.h" | 50 #include "sync/js/js_test_util.h" |
| 49 #include "sync/protocol/bookmark_specifics.pb.h" | 51 #include "sync/protocol/bookmark_specifics.pb.h" |
| 50 #include "sync/protocol/encryption.pb.h" | 52 #include "sync/protocol/encryption.pb.h" |
| 51 #include "sync/protocol/extension_specifics.pb.h" | 53 #include "sync/protocol/extension_specifics.pb.h" |
| 52 #include "sync/protocol/password_specifics.pb.h" | 54 #include "sync/protocol/password_specifics.pb.h" |
| 53 #include "sync/protocol/preference_specifics.pb.h" | 55 #include "sync/protocol/preference_specifics.pb.h" |
| 54 #include "sync/protocol/proto_value_conversions.h" | 56 #include "sync/protocol/proto_value_conversions.h" |
| (...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used), | 2542 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used), |
| 2541 scheduler_to_use_(scheduler_to_use), | 2543 scheduler_to_use_(scheduler_to_use), |
| 2542 session_context_(session_context) {} | 2544 session_context_(session_context) {} |
| 2543 ~ComponentsFactory() override {} | 2545 ~ComponentsFactory() override {} |
| 2544 | 2546 |
| 2545 scoped_ptr<SyncScheduler> BuildScheduler( | 2547 scoped_ptr<SyncScheduler> BuildScheduler( |
| 2546 const std::string& name, | 2548 const std::string& name, |
| 2547 sessions::SyncSessionContext* context, | 2549 sessions::SyncSessionContext* context, |
| 2548 CancelationSignal* stop_handle) override { | 2550 CancelationSignal* stop_handle) override { |
| 2549 *session_context_ = context; | 2551 *session_context_ = context; |
| 2550 return scheduler_to_use_.Pass(); | 2552 return std::move(scheduler_to_use_); |
| 2551 } | 2553 } |
| 2552 | 2554 |
| 2553 private: | 2555 private: |
| 2554 scoped_ptr<SyncScheduler> scheduler_to_use_; | 2556 scoped_ptr<SyncScheduler> scheduler_to_use_; |
| 2555 sessions::SyncSessionContext** session_context_; | 2557 sessions::SyncSessionContext** session_context_; |
| 2556 }; | 2558 }; |
| 2557 | 2559 |
| 2558 class SyncManagerTestWithMockScheduler : public SyncManagerTest { | 2560 class SyncManagerTestWithMockScheduler : public SyncManagerTest { |
| 2559 public: | 2561 public: |
| 2560 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {} | 2562 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {} |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3356 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3358 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3357 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3359 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3358 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3360 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3359 // task is to ensure that SyncManagerImpl reported initialization failure in | 3361 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3360 // OnInitializationComplete callback. | 3362 // OnInitializationComplete callback. |
| 3361 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3363 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3362 EXPECT_FALSE(initialization_succeeded_); | 3364 EXPECT_FALSE(initialization_succeeded_); |
| 3363 } | 3365 } |
| 3364 | 3366 |
| 3365 } // namespace syncer | 3367 } // namespace syncer |
| OLD | NEW |