| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
| 6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
| 7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 EXPECT_FALSE(js_backend_.IsInitialized()); | 746 EXPECT_FALSE(js_backend_.IsInitialized()); |
| 747 | 747 |
| 748 std::vector<ModelSafeWorker*> workers; | 748 std::vector<ModelSafeWorker*> workers; |
| 749 ModelSafeRoutingInfo routing_info; | 749 ModelSafeRoutingInfo routing_info; |
| 750 GetModelSafeRoutingInfo(&routing_info); | 750 GetModelSafeRoutingInfo(&routing_info); |
| 751 | 751 |
| 752 // Takes ownership of |fake_invalidator_|. | 752 // Takes ownership of |fake_invalidator_|. |
| 753 sync_manager_.Init(temp_dir_.path(), | 753 sync_manager_.Init(temp_dir_.path(), |
| 754 WeakHandle<JsEventHandler>(), | 754 WeakHandle<JsEventHandler>(), |
| 755 "bogus", 0, false, | 755 "bogus", 0, false, |
| 756 base::MessageLoopProxy::current(), | |
| 757 scoped_ptr<HttpPostProviderFactory>( | 756 scoped_ptr<HttpPostProviderFactory>( |
| 758 new TestHttpPostProviderFactory()), | 757 new TestHttpPostProviderFactory()), |
| 759 workers, &extensions_activity_monitor_, this, | 758 workers, &extensions_activity_monitor_, this, |
| 760 credentials, | 759 credentials, |
| 761 scoped_ptr<Invalidator>(fake_invalidator_), | 760 scoped_ptr<Invalidator>(fake_invalidator_), |
| 762 "", "", // bootstrap tokens | 761 "", "", // bootstrap tokens |
| 763 scoped_ptr<InternalComponentsFactory>(GetFactory()), | 762 scoped_ptr<InternalComponentsFactory>(GetFactory()), |
| 764 &encryptor_, | 763 &encryptor_, |
| 765 &handler_, | 764 &handler_, |
| 766 NULL); | 765 NULL); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 784 sync_manager_.ShutdownOnSyncThread(); | 783 sync_manager_.ShutdownOnSyncThread(); |
| 785 // We can't assert that |sync_manager_| isn't registered with | 784 // We can't assert that |sync_manager_| isn't registered with |
| 786 // |fake_invalidator_| anymore because |fake_invalidator_| is now | 785 // |fake_invalidator_| anymore because |fake_invalidator_| is now |
| 787 // destroyed. | 786 // destroyed. |
| 788 fake_invalidator_ = NULL; | 787 fake_invalidator_ = NULL; |
| 789 PumpLoop(); | 788 PumpLoop(); |
| 790 } | 789 } |
| 791 | 790 |
| 792 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 791 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
| 793 (*out)[NIGORI] = GROUP_PASSIVE; | 792 (*out)[NIGORI] = GROUP_PASSIVE; |
| 793 (*out)[DEVICE_INFO] = GROUP_PASSIVE; |
| 794 (*out)[BOOKMARKS] = GROUP_PASSIVE; | 794 (*out)[BOOKMARKS] = GROUP_PASSIVE; |
| 795 (*out)[THEMES] = GROUP_PASSIVE; | 795 (*out)[THEMES] = GROUP_PASSIVE; |
| 796 (*out)[SESSIONS] = GROUP_PASSIVE; | 796 (*out)[SESSIONS] = GROUP_PASSIVE; |
| 797 (*out)[PASSWORDS] = GROUP_PASSIVE; | 797 (*out)[PASSWORDS] = GROUP_PASSIVE; |
| 798 (*out)[PREFERENCES] = GROUP_PASSIVE; | 798 (*out)[PREFERENCES] = GROUP_PASSIVE; |
| 799 } | 799 } |
| 800 | 800 |
| 801 virtual void OnChangesApplied( | 801 virtual void OnChangesApplied( |
| 802 ModelType model_type, | 802 ModelType model_type, |
| 803 const BaseTransaction* trans, | 803 const BaseTransaction* trans, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 ListValue args; | 1176 ListValue args; |
| 1177 args.Append(Value::CreateStringValue("1")); | 1177 args.Append(Value::CreateStringValue("1")); |
| 1178 SendJsMessage("getChildNodeIds", | 1178 SendJsMessage("getChildNodeIds", |
| 1179 JsArgList(&args), reply_handler.AsWeakHandle()); | 1179 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 EXPECT_EQ(1u, return_args.Get().GetSize()); | 1182 EXPECT_EQ(1u, return_args.Get().GetSize()); |
| 1183 const ListValue* nodes = NULL; | 1183 const ListValue* nodes = NULL; |
| 1184 ASSERT_TRUE(return_args.Get().GetList(0, &nodes)); | 1184 ASSERT_TRUE(return_args.Get().GetList(0, &nodes)); |
| 1185 ASSERT_TRUE(nodes); | 1185 ASSERT_TRUE(nodes); |
| 1186 EXPECT_EQ(6u, nodes->GetSize()); | 1186 EXPECT_EQ(7u, nodes->GetSize()); |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 TEST_F(SyncManagerTest, GetChildNodeIdsFailure) { | 1189 TEST_F(SyncManagerTest, GetChildNodeIdsFailure) { |
| 1190 StrictMock<MockJsReplyHandler> reply_handler; | 1190 StrictMock<MockJsReplyHandler> reply_handler; |
| 1191 | 1191 |
| 1192 ListValue empty_list_args; | 1192 ListValue empty_list_args; |
| 1193 empty_list_args.Append(new ListValue()); | 1193 empty_list_args.Append(new ListValue()); |
| 1194 | 1194 |
| 1195 EXPECT_CALL(reply_handler, | 1195 EXPECT_CALL(reply_handler, |
| 1196 HandleJsReply("getChildNodeIds", | 1196 HandleJsReply("getChildNodeIds", |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2880 | 2880 |
| 2881 // Verify only the non-disabled types remain after cleanup. | 2881 // Verify only the non-disabled types remain after cleanup. |
| 2882 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); | 2882 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); |
| 2883 EXPECT_TRUE(new_enabled_types.Equals( | 2883 EXPECT_TRUE(new_enabled_types.Equals( |
| 2884 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); | 2884 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); |
| 2885 EXPECT_TRUE(disabled_types.Equals( | 2885 EXPECT_TRUE(disabled_types.Equals( |
| 2886 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 2886 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
| 2887 } | 2887 } |
| 2888 | 2888 |
| 2889 } // namespace | 2889 } // namespace |
| OLD | NEW |