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