| 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_backup_manager.h" | 5 #include "sync/internal_api/sync_backup_manager.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "sync/internal_api/public/read_node.h" | 9 #include "sync/internal_api/public/read_node.h" |
| 10 #include "sync/internal_api/public/read_transaction.h" | 10 #include "sync/internal_api/public/read_transaction.h" |
| 11 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 11 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 12 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 12 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 13 #include "sync/internal_api/public/write_node.h" | 13 #include "sync/internal_api/public/write_node.h" |
| 14 #include "sync/internal_api/public/write_transaction.h" | 14 #include "sync/internal_api/public/write_transaction.h" |
| 15 #include "sync/syncable/entry.h" | 15 #include "sync/syncable/entry.h" |
| 16 #include "sync/test/test_directory_backing_store.h" | 16 #include "sync/test/test_directory_backing_store.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 using ::testing::Invoke; | 22 using ::testing::Invoke; |
| 22 using ::testing::WithArgs; | 23 using ::testing::WithArgs; |
| 23 | 24 |
| 24 namespace syncer { | 25 namespace syncer { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 void OnConfigDone(bool success) { | 29 void OnConfigDone(bool success) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 54 .WillOnce(WithArgs<2>(Invoke(this, | 55 .WillOnce(WithArgs<2>(Invoke(this, |
| 55 &SyncBackupManagerTest::HandleInit))); | 56 &SyncBackupManagerTest::HandleInit))); |
| 56 | 57 |
| 57 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), | 58 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), |
| 58 storage_option); | 59 storage_option); |
| 59 manager->AddObserver(this); | 60 manager->AddObserver(this); |
| 60 | 61 |
| 61 base::RunLoop run_loop; | 62 base::RunLoop run_loop; |
| 62 manager->Init(temp_dir_.path(), | 63 manager->Init(temp_dir_.path(), |
| 63 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), | 64 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), |
| 64 "", 0, true, scoped_ptr<HttpPostProviderFactory>().Pass(), | 65 GURL("https://example.com/"), |
| 66 scoped_ptr<HttpPostProviderFactory>().Pass(), |
| 65 std::vector<scoped_refptr<ModelSafeWorker> >(), | 67 std::vector<scoped_refptr<ModelSafeWorker> >(), |
| 66 NULL, NULL, SyncCredentials(), "", "", "", &factory, | 68 NULL, |
| 67 NULL, scoped_ptr<UnrecoverableErrorHandler>().Pass(), | 69 NULL, |
| 68 NULL, NULL); | 70 SyncCredentials(), |
| 71 "", |
| 72 "", |
| 73 "", |
| 74 &factory, |
| 75 NULL, |
| 76 scoped_ptr<UnrecoverableErrorHandler>().Pass(), |
| 77 NULL, |
| 78 NULL); |
| 69 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); | 79 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); |
| 70 run_loop.Run(); | 80 run_loop.Run(); |
| 71 } | 81 } |
| 72 | 82 |
| 73 void CreateEntry(UserShare* user_share, ModelType type, | 83 void CreateEntry(UserShare* user_share, ModelType type, |
| 74 const std::string& client_tag) { | 84 const std::string& client_tag) { |
| 75 WriteTransaction trans(FROM_HERE, user_share); | 85 WriteTransaction trans(FROM_HERE, user_share); |
| 76 ReadNode type_root(&trans); | 86 ReadNode type_root(&trans); |
| 77 EXPECT_EQ(BaseNode::INIT_OK, type_root.InitTypeRoot(type)); | 87 EXPECT_EQ(BaseNode::INIT_OK, type_root.InitTypeRoot(type)); |
| 78 | 88 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 160 |
| 151 TEST_F(SyncBackupManagerTest, FailToInitialize) { | 161 TEST_F(SyncBackupManagerTest, FailToInitialize) { |
| 152 // Test graceful shutdown on initialization failure. | 162 // Test graceful shutdown on initialization failure. |
| 153 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); | 163 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); |
| 154 InitManager(manager.get(), STORAGE_INVALID); | 164 InitManager(manager.get(), STORAGE_INVALID); |
| 155 } | 165 } |
| 156 | 166 |
| 157 } // anonymous namespace | 167 } // anonymous namespace |
| 158 | 168 |
| 159 } // namespace syncer | 169 } // namespace syncer |
| 160 | |
| OLD | NEW |