| 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 <cstddef> | 9 #include <cstddef> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "sync/sessions/sync_session.h" | 59 #include "sync/sessions/sync_session.h" |
| 60 #include "sync/syncable/directory.h" | 60 #include "sync/syncable/directory.h" |
| 61 #include "sync/syncable/entry.h" | 61 #include "sync/syncable/entry.h" |
| 62 #include "sync/syncable/mutable_entry.h" | 62 #include "sync/syncable/mutable_entry.h" |
| 63 #include "sync/syncable/nigori_util.h" | 63 #include "sync/syncable/nigori_util.h" |
| 64 #include "sync/syncable/syncable_id.h" | 64 #include "sync/syncable/syncable_id.h" |
| 65 #include "sync/syncable/syncable_read_transaction.h" | 65 #include "sync/syncable/syncable_read_transaction.h" |
| 66 #include "sync/syncable/syncable_util.h" | 66 #include "sync/syncable/syncable_util.h" |
| 67 #include "sync/syncable/syncable_write_transaction.h" | 67 #include "sync/syncable/syncable_write_transaction.h" |
| 68 #include "sync/test/callback_counter.h" | 68 #include "sync/test/callback_counter.h" |
| 69 #include "sync/test/engine/fake_model_worker.h" |
| 69 #include "sync/test/engine/fake_sync_scheduler.h" | 70 #include "sync/test/engine/fake_sync_scheduler.h" |
| 70 #include "sync/test/engine/test_id_factory.h" | 71 #include "sync/test/engine/test_id_factory.h" |
| 71 #include "sync/test/fake_encryptor.h" | 72 #include "sync/test/fake_encryptor.h" |
| 72 #include "sync/util/cryptographer.h" | 73 #include "sync/util/cryptographer.h" |
| 73 #include "sync/util/extensions_activity.h" | 74 #include "sync/util/extensions_activity.h" |
| 74 #include "sync/util/test_unrecoverable_error_handler.h" | 75 #include "sync/util/test_unrecoverable_error_handler.h" |
| 75 #include "sync/util/time.h" | 76 #include "sync/util/time.h" |
| 76 #include "testing/gmock/include/gmock/gmock.h" | 77 #include "testing/gmock/include/gmock/gmock.h" |
| 77 #include "testing/gtest/include/gtest/gtest.h" | 78 #include "testing/gtest/include/gtest/gtest.h" |
| 78 | 79 |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _)). | 810 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _)). |
| 810 WillOnce(DoAll(SaveArg<0>(&js_backend_), | 811 WillOnce(DoAll(SaveArg<0>(&js_backend_), |
| 811 SaveArg<2>(&initialization_succeeded_))); | 812 SaveArg<2>(&initialization_succeeded_))); |
| 812 | 813 |
| 813 EXPECT_FALSE(js_backend_.IsInitialized()); | 814 EXPECT_FALSE(js_backend_.IsInitialized()); |
| 814 | 815 |
| 815 std::vector<ModelSafeWorker*> workers; | 816 std::vector<ModelSafeWorker*> workers; |
| 816 ModelSafeRoutingInfo routing_info; | 817 ModelSafeRoutingInfo routing_info; |
| 817 GetModelSafeRoutingInfo(&routing_info); | 818 GetModelSafeRoutingInfo(&routing_info); |
| 818 | 819 |
| 820 // This works only because all routing info types are GROUP_PASSIVE. |
| 821 // If we had types in other groups, we would need additional workers |
| 822 // to support them. |
| 823 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(GROUP_PASSIVE); |
| 824 workers.push_back(worker.get()); |
| 825 |
| 819 // Takes ownership of |fake_invalidator_|. | 826 // Takes ownership of |fake_invalidator_|. |
| 820 sync_manager_.Init( | 827 sync_manager_.Init( |
| 821 temp_dir_.path(), | 828 temp_dir_.path(), |
| 822 WeakHandle<JsEventHandler>(), | 829 WeakHandle<JsEventHandler>(), |
| 823 "bogus", | 830 "bogus", |
| 824 0, | 831 0, |
| 825 false, | 832 false, |
| 826 scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory()), | 833 scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory()), |
| 827 workers, | 834 workers, |
| 828 extensions_activity_.get(), | 835 extensions_activity_.get(), |
| (...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3511 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3505 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3512 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3506 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3513 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3507 // task is to ensure that SyncManagerImpl reported initialization failure in | 3514 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3508 // OnInitializationComplete callback. | 3515 // OnInitializationComplete callback. |
| 3509 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3516 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3510 EXPECT_FALSE(initialization_succeeded_); | 3517 EXPECT_FALSE(initialization_succeeded_); |
| 3511 } | 3518 } |
| 3512 | 3519 |
| 3513 } // namespace | 3520 } // namespace |
| OLD | NEW |