OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sync/internal_api/sync_rollback_manager_base.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace syncer { |
| 14 |
| 15 namespace { |
| 16 |
| 17 void OnConfigDone(bool success) { |
| 18 EXPECT_TRUE(success); |
| 19 } |
| 20 |
| 21 class SyncRollbackManagerBaseTest : public testing::Test { |
| 22 protected: |
| 23 virtual void SetUp() OVERRIDE { |
| 24 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), |
| 25 STORAGE_IN_MEMORY); |
| 26 manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory), |
| 27 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), |
| 28 "", 0, true, scoped_ptr<HttpPostProviderFactory>().Pass(), |
| 29 std::vector<scoped_refptr<ModelSafeWorker> >(), |
| 30 NULL, NULL, SyncCredentials(), "", "", "", &factory, |
| 31 NULL, scoped_ptr<UnrecoverableErrorHandler>().Pass(), |
| 32 NULL, NULL); |
| 33 } |
| 34 |
| 35 SyncRollbackManagerBase manager_; |
| 36 base::MessageLoop loop_; // Needed for WeakHandle |
| 37 }; |
| 38 |
| 39 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { |
| 40 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); |
| 41 |
| 42 manager_.ConfigureSyncer( |
| 43 CONFIGURE_REASON_NEW_CLIENT, |
| 44 ModelTypeSet(PREFERENCES, BOOKMARKS), |
| 45 ModelTypeSet(), ModelTypeSet(), ModelTypeSet(), ModelSafeRoutingInfo(), |
| 46 base::Bind(&OnConfigDone, true), |
| 47 base::Bind(&OnConfigDone, false)); |
| 48 |
| 49 ReadTransaction trans(FROM_HERE, manager_.GetUserShare()); |
| 50 ReadNode pref_root(&trans); |
| 51 EXPECT_EQ(BaseNode::INIT_OK, |
| 52 pref_root.InitByTagLookup(ModelTypeToRootTag(PREFERENCES))); |
| 53 |
| 54 ReadNode bookmark_root(&trans); |
| 55 EXPECT_EQ(BaseNode::INIT_OK, |
| 56 bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS))); |
| 57 ReadNode bookmark_bar(&trans); |
| 58 EXPECT_EQ(BaseNode::INIT_OK, |
| 59 bookmark_bar.InitByTagLookup("bookmark_bar")); |
| 60 ReadNode bookmark_mobile(&trans); |
| 61 EXPECT_EQ(BaseNode::INIT_OK, |
| 62 bookmark_mobile.InitByTagLookup("synced_bookmarks")); |
| 63 ReadNode bookmark_other(&trans); |
| 64 EXPECT_EQ(BaseNode::INIT_OK, |
| 65 bookmark_other.InitByTagLookup("other_bookmarks")); |
| 66 } |
| 67 |
| 68 } // anonymous namespace |
| 69 |
| 70 } // namespace syncer |
OLD | NEW |