| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sync/internal_api/public/test/model_type_store_test_util.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/run_loop.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 | |
| 13 namespace syncer_v2 { | |
| 14 | |
| 15 using Result = ModelTypeStore::Result; | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 void MoveStoreToScopedPtr(std::unique_ptr<ModelTypeStore>* out_store, | |
| 20 Result result, | |
| 21 std::unique_ptr<ModelTypeStore> in_store) { | |
| 22 ASSERT_EQ(Result::SUCCESS, result); | |
| 23 std::swap(*out_store, in_store); | |
| 24 } | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 // static | |
| 29 std::unique_ptr<ModelTypeStore> | |
| 30 ModelTypeStoreTestUtil::CreateInMemoryStoreForTest() { | |
| 31 std::unique_ptr<ModelTypeStore> store; | |
| 32 ModelTypeStore::CreateInMemoryStoreForTest( | |
| 33 base::Bind(&MoveStoreToScopedPtr, &store)); | |
| 34 | |
| 35 // Force the initialization to run now, synchronously. | |
| 36 base::RunLoop().RunUntilIdle(); | |
| 37 | |
| 38 EXPECT_TRUE(store); | |
| 39 return store; | |
| 40 } | |
| 41 | |
| 42 // static | |
| 43 void ModelTypeStoreTestUtil::MoveStoreToCallback( | |
| 44 std::unique_ptr<ModelTypeStore> store, | |
| 45 const ModelTypeStore::InitCallback& callback) { | |
| 46 ASSERT_TRUE(store); | |
| 47 callback.Run(Result::SUCCESS, std::move(store)); | |
| 48 } | |
| 49 | |
| 50 } // namespace syncer_v2 | |
| OLD | NEW |