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 <stdint.h> | 11 #include <stdint.h> |
10 | |
11 #include <cstddef> | 12 #include <cstddef> |
12 #include <map> | 13 #include <map> |
| 14 #include <utility> |
13 | 15 |
14 #include "base/callback.h" | 16 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
16 #include "base/files/scoped_temp_dir.h" | 18 #include "base/files/scoped_temp_dir.h" |
17 #include "base/format_macros.h" | 19 #include "base/format_macros.h" |
18 #include "base/location.h" | 20 #include "base/location.h" |
19 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
20 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
21 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
(...skipping 12 matching lines...) Expand all Loading... |
35 #include "sync/internal_api/public/http_post_provider_factory.h" | 37 #include "sync/internal_api/public/http_post_provider_factory.h" |
36 #include "sync/internal_api/public/http_post_provider_interface.h" | 38 #include "sync/internal_api/public/http_post_provider_interface.h" |
37 #include "sync/internal_api/public/read_node.h" | 39 #include "sync/internal_api/public/read_node.h" |
38 #include "sync/internal_api/public/read_transaction.h" | 40 #include "sync/internal_api/public/read_transaction.h" |
39 #include "sync/internal_api/public/test/test_entry_factory.h" | 41 #include "sync/internal_api/public/test/test_entry_factory.h" |
40 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 42 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
41 #include "sync/internal_api/public/test/test_user_share.h" | 43 #include "sync/internal_api/public/test/test_user_share.h" |
42 #include "sync/internal_api/public/write_node.h" | 44 #include "sync/internal_api/public/write_node.h" |
43 #include "sync/internal_api/public/write_transaction.h" | 45 #include "sync/internal_api/public/write_transaction.h" |
44 #include "sync/internal_api/sync_encryption_handler_impl.h" | 46 #include "sync/internal_api/sync_encryption_handler_impl.h" |
45 #include "sync/internal_api/sync_manager_impl.h" | |
46 #include "sync/internal_api/syncapi_internal.h" | 47 #include "sync/internal_api/syncapi_internal.h" |
47 #include "sync/js/js_backend.h" | 48 #include "sync/js/js_backend.h" |
48 #include "sync/js/js_event_handler.h" | 49 #include "sync/js/js_event_handler.h" |
49 #include "sync/js/js_test_util.h" | 50 #include "sync/js/js_test_util.h" |
50 #include "sync/protocol/bookmark_specifics.pb.h" | 51 #include "sync/protocol/bookmark_specifics.pb.h" |
51 #include "sync/protocol/encryption.pb.h" | 52 #include "sync/protocol/encryption.pb.h" |
52 #include "sync/protocol/extension_specifics.pb.h" | 53 #include "sync/protocol/extension_specifics.pb.h" |
53 #include "sync/protocol/password_specifics.pb.h" | 54 #include "sync/protocol/password_specifics.pb.h" |
54 #include "sync/protocol/preference_specifics.pb.h" | 55 #include "sync/protocol/preference_specifics.pb.h" |
55 #include "sync/protocol/proto_value_conversions.h" | 56 #include "sync/protocol/proto_value_conversions.h" |
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used), | 2543 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used), |
2543 scheduler_to_use_(scheduler_to_use), | 2544 scheduler_to_use_(scheduler_to_use), |
2544 session_context_(session_context) {} | 2545 session_context_(session_context) {} |
2545 ~ComponentsFactory() override {} | 2546 ~ComponentsFactory() override {} |
2546 | 2547 |
2547 scoped_ptr<SyncScheduler> BuildScheduler( | 2548 scoped_ptr<SyncScheduler> BuildScheduler( |
2548 const std::string& name, | 2549 const std::string& name, |
2549 sessions::SyncSessionContext* context, | 2550 sessions::SyncSessionContext* context, |
2550 CancelationSignal* stop_handle) override { | 2551 CancelationSignal* stop_handle) override { |
2551 *session_context_ = context; | 2552 *session_context_ = context; |
2552 return scheduler_to_use_.Pass(); | 2553 return std::move(scheduler_to_use_); |
2553 } | 2554 } |
2554 | 2555 |
2555 private: | 2556 private: |
2556 scoped_ptr<SyncScheduler> scheduler_to_use_; | 2557 scoped_ptr<SyncScheduler> scheduler_to_use_; |
2557 sessions::SyncSessionContext** session_context_; | 2558 sessions::SyncSessionContext** session_context_; |
2558 }; | 2559 }; |
2559 | 2560 |
2560 class SyncManagerTestWithMockScheduler : public SyncManagerTest { | 2561 class SyncManagerTestWithMockScheduler : public SyncManagerTest { |
2561 public: | 2562 public: |
2562 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {} | 2563 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {} |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3359 // SyncManagerInitInvalidStorageTest::GetFactory will return |
3359 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3360 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
3360 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3361 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
3361 // task is to ensure that SyncManagerImpl reported initialization failure in | 3362 // task is to ensure that SyncManagerImpl reported initialization failure in |
3362 // OnInitializationComplete callback. | 3363 // OnInitializationComplete callback. |
3363 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3364 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
3364 EXPECT_FALSE(initialization_succeeded_); | 3365 EXPECT_FALSE(initialization_succeeded_); |
3365 } | 3366 } |
3366 | 3367 |
3367 } // namespace syncer | 3368 } // namespace syncer |
OLD | NEW |