| 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 | 13 |
| 13 namespace syncer { | 14 namespace syncer { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 void OnConfigDone(bool success) { | 18 void OnConfigDone(bool success) { |
| 18 EXPECT_TRUE(success); | 19 EXPECT_TRUE(success); |
| 19 } | 20 } |
| 20 | 21 |
| 21 class SyncTestRollbackManager : public SyncRollbackManagerBase { | 22 class SyncTestRollbackManager : public SyncRollbackManagerBase { |
| 22 public: | 23 public: |
| 23 virtual void Init( | 24 virtual void Init( |
| 24 const base::FilePath& database_location, | 25 const base::FilePath& database_location, |
| 25 const WeakHandle<JsEventHandler>& event_handler, | 26 const WeakHandle<JsEventHandler>& event_handler, |
| 26 const std::string& sync_server_and_path, | 27 const GURL& service_url, |
| 27 int sync_server_port, | |
| 28 bool use_ssl, | |
| 29 scoped_ptr<HttpPostProviderFactory> post_factory, | 28 scoped_ptr<HttpPostProviderFactory> post_factory, |
| 30 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | 29 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, |
| 31 ExtensionsActivity* extensions_activity, | 30 ExtensionsActivity* extensions_activity, |
| 32 ChangeDelegate* change_delegate, | 31 ChangeDelegate* change_delegate, |
| 33 const SyncCredentials& credentials, | 32 const SyncCredentials& credentials, |
| 34 const std::string& invalidator_client_id, | 33 const std::string& invalidator_client_id, |
| 35 const std::string& restored_key_for_bootstrapping, | 34 const std::string& restored_key_for_bootstrapping, |
| 36 const std::string& restored_keystore_key_for_bootstrapping, | 35 const std::string& restored_keystore_key_for_bootstrapping, |
| 37 InternalComponentsFactory* internal_components_factory, | 36 InternalComponentsFactory* internal_components_factory, |
| 38 Encryptor* encryptor, | 37 Encryptor* encryptor, |
| 39 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | 38 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, |
| 40 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | 39 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, |
| 41 CancelationSignal* cancelation_signal) OVERRIDE { | 40 CancelationSignal* cancelation_signal) OVERRIDE { |
| 42 SyncRollbackManagerBase::InitInternal(database_location, | 41 SyncRollbackManagerBase::InitInternal(database_location, |
| 43 internal_components_factory, | 42 internal_components_factory, |
| 44 unrecoverable_error_handler.Pass(), | 43 unrecoverable_error_handler.Pass(), |
| 45 report_unrecoverable_error_function); | 44 report_unrecoverable_error_function); |
| 46 } | 45 } |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 class SyncRollbackManagerBaseTest : public testing::Test { | 48 class SyncRollbackManagerBaseTest : public testing::Test { |
| 50 protected: | 49 protected: |
| 51 virtual void SetUp() OVERRIDE { | 50 virtual void SetUp() OVERRIDE { |
| 52 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), | 51 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), |
| 53 STORAGE_IN_MEMORY); | 52 STORAGE_IN_MEMORY); |
| 54 manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory), | 53 manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory), |
| 55 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), | 54 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), |
| 56 "", 0, true, scoped_ptr<HttpPostProviderFactory>().Pass(), | 55 GURL("https://example.com/"), |
| 56 scoped_ptr<HttpPostProviderFactory>().Pass(), |
| 57 std::vector<scoped_refptr<ModelSafeWorker> >(), | 57 std::vector<scoped_refptr<ModelSafeWorker> >(), |
| 58 NULL, NULL, SyncCredentials(), "", "", "", &factory, | 58 NULL, |
| 59 NULL, scoped_ptr<UnrecoverableErrorHandler>().Pass(), | 59 NULL, |
| 60 NULL, NULL); | 60 SyncCredentials(), |
| 61 "", |
| 62 "", |
| 63 "", |
| 64 &factory, |
| 65 NULL, |
| 66 scoped_ptr<UnrecoverableErrorHandler>().Pass(), |
| 67 NULL, |
| 68 NULL); |
| 61 } | 69 } |
| 62 | 70 |
| 63 SyncTestRollbackManager manager_; | 71 SyncTestRollbackManager manager_; |
| 64 base::MessageLoop loop_; // Needed for WeakHandle | 72 base::MessageLoop loop_; // Needed for WeakHandle |
| 65 }; | 73 }; |
| 66 | 74 |
| 67 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { | 75 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { |
| 68 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); | 76 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); |
| 69 | 77 |
| 70 manager_.ConfigureSyncer( | 78 manager_.ConfigureSyncer( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 89 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, | 97 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, |
| 90 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); | 98 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); |
| 91 ReadNode bookmark_other(&trans); | 99 ReadNode bookmark_other(&trans); |
| 92 EXPECT_EQ(BaseNode::INIT_OK, | 100 EXPECT_EQ(BaseNode::INIT_OK, |
| 93 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); | 101 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); |
| 94 } | 102 } |
| 95 | 103 |
| 96 } // anonymous namespace | 104 } // anonymous namespace |
| 97 | 105 |
| 98 } // namespace syncer | 106 } // namespace syncer |
| OLD | NEW |