| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 virtual void SetUp() OVERRIDE { | 48 virtual void SetUp() OVERRIDE { |
| 49 CHECK(temp_dir_.CreateUniqueTempDir()); | 49 CHECK(temp_dir_.CreateUniqueTempDir()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void InitManager(SyncManager* manager, StorageOption storage_option) { | 52 void InitManager(SyncManager* manager, StorageOption storage_option) { |
| 53 manager_ = manager; | 53 manager_ = manager; |
| 54 EXPECT_CALL(*this, OnInitializationComplete(_, _, _, _)) | 54 EXPECT_CALL(*this, OnInitializationComplete(_, _, _, _)) |
| 55 .WillOnce(WithArgs<2>(Invoke(this, | 55 .WillOnce(WithArgs<2>(Invoke(this, |
| 56 &SyncBackupManagerTest::HandleInit))); | 56 &SyncBackupManagerTest::HandleInit))); |
| 57 | 57 |
| 58 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), | |
| 59 storage_option); | |
| 60 manager->AddObserver(this); | 58 manager->AddObserver(this); |
| 61 | 59 |
| 62 base::RunLoop run_loop; | 60 base::RunLoop run_loop; |
| 63 manager->Init(temp_dir_.path(), | 61 |
| 64 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), | 62 SyncManager::InitArgs args; |
| 65 GURL("https://example.com/"), | 63 args.database_location = temp_dir_.path(); |
| 66 scoped_ptr<HttpPostProviderFactory>().Pass(), | 64 args.event_handler = MakeWeakHandle(base::WeakPtr<JsEventHandler>()); |
| 67 std::vector<scoped_refptr<ModelSafeWorker> >(), | 65 args.service_url = GURL("https://example.com/"); |
| 68 NULL, | 66 args.post_factory = scoped_ptr<HttpPostProviderFactory>().Pass(); |
| 69 NULL, | 67 args.internal_components_factory.reset(new TestInternalComponentsFactory( |
| 70 SyncCredentials(), | 68 InternalComponentsFactory::Switches(), storage_option)); |
| 71 "", | 69 manager->Init(&args); |
| 72 "", | |
| 73 "", | |
| 74 &factory, | |
| 75 NULL, | |
| 76 scoped_ptr<UnrecoverableErrorHandler>().Pass(), | |
| 77 NULL, | |
| 78 NULL); | |
| 79 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); | 70 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); |
| 80 run_loop.Run(); | 71 run_loop.Run(); |
| 81 } | 72 } |
| 82 | 73 |
| 83 void CreateEntry(UserShare* user_share, ModelType type, | 74 void CreateEntry(UserShare* user_share, ModelType type, |
| 84 const std::string& client_tag) { | 75 const std::string& client_tag) { |
| 85 WriteTransaction trans(FROM_HERE, user_share); | 76 WriteTransaction trans(FROM_HERE, user_share); |
| 86 ReadNode type_root(&trans); | 77 ReadNode type_root(&trans); |
| 87 EXPECT_EQ(BaseNode::INIT_OK, type_root.InitTypeRoot(type)); | 78 EXPECT_EQ(BaseNode::INIT_OK, type_root.InitTypeRoot(type)); |
| 88 | 79 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 151 |
| 161 TEST_F(SyncBackupManagerTest, FailToInitialize) { | 152 TEST_F(SyncBackupManagerTest, FailToInitialize) { |
| 162 // Test graceful shutdown on initialization failure. | 153 // Test graceful shutdown on initialization failure. |
| 163 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); | 154 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); |
| 164 InitManager(manager.get(), STORAGE_INVALID); | 155 InitManager(manager.get(), STORAGE_INVALID); |
| 165 } | 156 } |
| 166 | 157 |
| 167 } // anonymous namespace | 158 } // anonymous namespace |
| 168 | 159 |
| 169 } // namespace syncer | 160 } // namespace syncer |
| OLD | NEW |