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(InitArgs* args) OVERRIDE { | 24 virtual void Init(InitArgs* args) OVERRIDE { |
25 SyncRollbackManagerBase::InitInternal( | 25 SyncRollbackManagerBase::InitInternal( |
26 args->database_location, | 26 args->database_location, |
27 args->internal_components_factory.get(), | 27 args->internal_components_factory.get(), |
| 28 InternalComponentsFactory::STORAGE_IN_MEMORY, |
28 args->unrecoverable_error_handler.Pass(), | 29 args->unrecoverable_error_handler.Pass(), |
29 args->report_unrecoverable_error_function); | 30 args->report_unrecoverable_error_function); |
30 } | 31 } |
31 }; | 32 }; |
32 | 33 |
33 class SyncRollbackManagerBaseTest : public testing::Test { | 34 class SyncRollbackManagerBaseTest : public testing::Test { |
34 protected: | 35 protected: |
35 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
36 SyncManager::InitArgs args; | 37 SyncManager::InitArgs args; |
37 args.database_location = base::FilePath(base::FilePath::kCurrentDirectory); | 38 args.database_location = base::FilePath(base::FilePath::kCurrentDirectory); |
38 args.service_url = GURL("https://example.com/"); | 39 args.service_url = GURL("https://example.com/"); |
39 args.internal_components_factory.reset(new TestInternalComponentsFactory( | 40 args.internal_components_factory.reset(new TestInternalComponentsFactory( |
40 InternalComponentsFactory::Switches(), STORAGE_IN_MEMORY)); | 41 InternalComponentsFactory::Switches(), |
| 42 InternalComponentsFactory::STORAGE_IN_MEMORY, |
| 43 &storage_used_)); |
41 manager_.Init(&args); | 44 manager_.Init(&args); |
| 45 EXPECT_EQ(InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used_); |
42 } | 46 } |
43 | 47 |
44 SyncTestRollbackManager manager_; | 48 SyncTestRollbackManager manager_; |
45 base::MessageLoop loop_; // Needed for WeakHandle | 49 base::MessageLoop loop_; // Needed for WeakHandle |
| 50 InternalComponentsFactory::StorageOption storage_used_; |
46 }; | 51 }; |
47 | 52 |
48 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { | 53 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { |
49 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); | 54 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); |
50 | 55 |
51 manager_.ConfigureSyncer( | 56 manager_.ConfigureSyncer( |
52 CONFIGURE_REASON_NEW_CLIENT, | 57 CONFIGURE_REASON_NEW_CLIENT, |
53 ModelTypeSet(PREFERENCES, BOOKMARKS), | 58 ModelTypeSet(PREFERENCES, BOOKMARKS), |
54 ModelTypeSet(), ModelTypeSet(), ModelTypeSet(), ModelSafeRoutingInfo(), | 59 ModelTypeSet(), ModelTypeSet(), ModelTypeSet(), ModelSafeRoutingInfo(), |
55 base::Bind(&OnConfigDone, true), | 60 base::Bind(&OnConfigDone, true), |
(...skipping 14 matching lines...) Expand all Loading... |
70 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, | 75 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, |
71 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); | 76 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); |
72 ReadNode bookmark_other(&trans); | 77 ReadNode bookmark_other(&trans); |
73 EXPECT_EQ(BaseNode::INIT_OK, | 78 EXPECT_EQ(BaseNode::INIT_OK, |
74 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); | 79 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); |
75 } | 80 } |
76 | 81 |
77 } // anonymous namespace | 82 } // anonymous namespace |
78 | 83 |
79 } // namespace syncer | 84 } // namespace syncer |
OLD | NEW |