| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "sync/internal_api/sync_rollback_manager_base.h" | 5 #include "sync/internal_api/sync_rollback_manager_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "sync/internal_api/public/read_node.h" | 8 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" | 9 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 10 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void OnConfigDone(bool success) { | 18 void OnConfigDone(bool success) { |
| 19 EXPECT_TRUE(success); | 19 EXPECT_TRUE(success); |
| 20 } | 20 } |
| 21 | 21 |
| 22 class SyncTestRollbackManager : public SyncRollbackManagerBase { | 22 class SyncTestRollbackManager : public SyncRollbackManagerBase { |
| 23 public: | 23 public: |
| 24 virtual void Init( | 24 virtual void Init(InitArgs* args) OVERRIDE { |
| 25 const base::FilePath& database_location, | 25 SyncRollbackManagerBase::InitInternal( |
| 26 const WeakHandle<JsEventHandler>& event_handler, | 26 args->database_location, |
| 27 const GURL& service_url, | 27 args->internal_components_factory, |
| 28 scoped_ptr<HttpPostProviderFactory> post_factory, | 28 args->unrecoverable_error_handler.Pass(), |
| 29 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | 29 args->report_unrecoverable_error_function); |
| 30 ExtensionsActivity* extensions_activity, | |
| 31 ChangeDelegate* change_delegate, | |
| 32 const SyncCredentials& credentials, | |
| 33 const std::string& invalidator_client_id, | |
| 34 const std::string& restored_key_for_bootstrapping, | |
| 35 const std::string& restored_keystore_key_for_bootstrapping, | |
| 36 InternalComponentsFactory* internal_components_factory, | |
| 37 Encryptor* encryptor, | |
| 38 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | |
| 39 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | |
| 40 CancelationSignal* cancelation_signal) OVERRIDE { | |
| 41 SyncRollbackManagerBase::InitInternal(database_location, | |
| 42 internal_components_factory, | |
| 43 unrecoverable_error_handler.Pass(), | |
| 44 report_unrecoverable_error_function); | |
| 45 } | 30 } |
| 46 }; | 31 }; |
| 47 | 32 |
| 48 class SyncRollbackManagerBaseTest : public testing::Test { | 33 class SyncRollbackManagerBaseTest : public testing::Test { |
| 49 protected: | 34 protected: |
| 50 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
| 51 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), | 36 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), |
| 52 STORAGE_IN_MEMORY); | 37 STORAGE_IN_MEMORY); |
| 53 manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory), | 38 |
| 54 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), | 39 SyncManager::InitArgs args; |
| 55 GURL("https://example.com/"), | 40 args.database_location = base::FilePath(base::FilePath::kCurrentDirectory); |
| 56 scoped_ptr<HttpPostProviderFactory>().Pass(), | 41 args.service_url = GURL("https://example.com/"); |
| 57 std::vector<scoped_refptr<ModelSafeWorker> >(), | 42 args.internal_components_factory = &factory; |
| 58 NULL, | 43 manager_.Init(&args); |
| 59 NULL, | |
| 60 SyncCredentials(), | |
| 61 "", | |
| 62 "", | |
| 63 "", | |
| 64 &factory, | |
| 65 NULL, | |
| 66 scoped_ptr<UnrecoverableErrorHandler>().Pass(), | |
| 67 NULL, | |
| 68 NULL); | |
| 69 } | 44 } |
| 70 | 45 |
| 71 SyncTestRollbackManager manager_; | 46 SyncTestRollbackManager manager_; |
| 72 base::MessageLoop loop_; // Needed for WeakHandle | 47 base::MessageLoop loop_; // Needed for WeakHandle |
| 73 }; | 48 }; |
| 74 | 49 |
| 75 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { | 50 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { |
| 76 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); | 51 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); |
| 77 | 52 |
| 78 manager_.ConfigureSyncer( | 53 manager_.ConfigureSyncer( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 97 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, | 72 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, |
| 98 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); | 73 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); |
| 99 ReadNode bookmark_other(&trans); | 74 ReadNode bookmark_other(&trans); |
| 100 EXPECT_EQ(BaseNode::INIT_OK, | 75 EXPECT_EQ(BaseNode::INIT_OK, |
| 101 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); | 76 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); |
| 102 } | 77 } |
| 103 | 78 |
| 104 } // anonymous namespace | 79 } // anonymous namespace |
| 105 | 80 |
| 106 } // namespace syncer | 81 } // namespace syncer |
| OLD | NEW |