| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 return false; | 716 return false; |
| 717 } | 717 } |
| 718 virtual int GetResponseContentLength() const OVERRIDE { | 718 virtual int GetResponseContentLength() const OVERRIDE { |
| 719 return 0; | 719 return 0; |
| 720 } | 720 } |
| 721 virtual const char* GetResponseContent() const OVERRIDE { | 721 virtual const char* GetResponseContent() const OVERRIDE { |
| 722 return ""; | 722 return ""; |
| 723 } | 723 } |
| 724 virtual const std::string GetResponseHeaderValue( | 724 virtual const std::string GetResponseHeaderValue( |
| 725 const std::string& name) const OVERRIDE { | 725 const std::string& name) const OVERRIDE { |
| 726 return ""; | 726 return std::string(); |
| 727 } | 727 } |
| 728 virtual void Abort() OVERRIDE {} | 728 virtual void Abort() OVERRIDE {} |
| 729 }; | 729 }; |
| 730 | 730 |
| 731 class TestHttpPostProviderFactory : public HttpPostProviderFactory { | 731 class TestHttpPostProviderFactory : public HttpPostProviderFactory { |
| 732 public: | 732 public: |
| 733 virtual ~TestHttpPostProviderFactory() {} | 733 virtual ~TestHttpPostProviderFactory() {} |
| 734 virtual HttpPostProviderInterface* Create() OVERRIDE { | 734 virtual HttpPostProviderInterface* Create() OVERRIDE { |
| 735 return new TestHttpPostProviderInterface(); | 735 return new TestHttpPostProviderInterface(); |
| 736 } | 736 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _)). | 813 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _)). |
| 814 WillOnce(SaveArg<0>(&js_backend_)); | 814 WillOnce(SaveArg<0>(&js_backend_)); |
| 815 | 815 |
| 816 EXPECT_FALSE(js_backend_.IsInitialized()); | 816 EXPECT_FALSE(js_backend_.IsInitialized()); |
| 817 | 817 |
| 818 std::vector<ModelSafeWorker*> workers; | 818 std::vector<ModelSafeWorker*> workers; |
| 819 ModelSafeRoutingInfo routing_info; | 819 ModelSafeRoutingInfo routing_info; |
| 820 GetModelSafeRoutingInfo(&routing_info); | 820 GetModelSafeRoutingInfo(&routing_info); |
| 821 | 821 |
| 822 // Takes ownership of |fake_invalidator_|. | 822 // Takes ownership of |fake_invalidator_|. |
| 823 sync_manager_.Init(temp_dir_.path(), | 823 sync_manager_.Init( |
| 824 WeakHandle<JsEventHandler>(), | 824 temp_dir_.path(), |
| 825 "bogus", 0, false, | 825 WeakHandle<JsEventHandler>(), |
| 826 scoped_ptr<HttpPostProviderFactory>( | 826 "bogus", |
| 827 new TestHttpPostProviderFactory()), | 827 0, |
| 828 workers, &extensions_activity_monitor_, this, | 828 false, |
| 829 credentials, | 829 scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory()), |
| 830 scoped_ptr<Invalidator>(fake_invalidator_), | 830 workers, |
| 831 "fake_invalidator_client_id", | 831 &extensions_activity_monitor_, |
| 832 "", "", // bootstrap tokens | 832 this, |
| 833 scoped_ptr<InternalComponentsFactory>(GetFactory()), | 833 credentials, |
| 834 &encryptor_, | 834 scoped_ptr<Invalidator>(fake_invalidator_), |
| 835 &handler_, | 835 "fake_invalidator_client_id", |
| 836 NULL); | 836 std::string(), |
| 837 std::string(), // bootstrap tokens |
| 838 scoped_ptr<InternalComponentsFactory>(GetFactory()), |
| 839 &encryptor_, |
| 840 &handler_, |
| 841 NULL); |
| 837 | 842 |
| 838 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); | 843 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); |
| 839 | 844 |
| 840 EXPECT_TRUE(js_backend_.IsInitialized()); | 845 EXPECT_TRUE(js_backend_.IsInitialized()); |
| 841 | 846 |
| 842 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); | 847 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); |
| 843 i != routing_info.end(); ++i) { | 848 i != routing_info.end(); ++i) { |
| 844 type_roots_[i->first] = MakeServerNodeForType( | 849 type_roots_[i->first] = MakeServerNodeForType( |
| 845 sync_manager_.GetUserShare(), i->first); | 850 sync_manager_.GetUserShare(), i->first); |
| 846 } | 851 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 base::ListValue args; | 1179 base::ListValue args; |
| 1175 args.Append(new base::ListValue()); | 1180 args.Append(new base::ListValue()); |
| 1176 SendJsMessage(message_name, | 1181 SendJsMessage(message_name, |
| 1177 JsArgList(&args), reply_handler.AsWeakHandle()); | 1182 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1178 } | 1183 } |
| 1179 | 1184 |
| 1180 { | 1185 { |
| 1181 base::ListValue args; | 1186 base::ListValue args; |
| 1182 base::ListValue* ids = new base::ListValue(); | 1187 base::ListValue* ids = new base::ListValue(); |
| 1183 args.Append(ids); | 1188 args.Append(ids); |
| 1184 ids->Append(new base::StringValue("")); | 1189 ids->Append(new base::StringValue(std::string())); |
| 1185 SendJsMessage(message_name, | 1190 SendJsMessage( |
| 1186 JsArgList(&args), reply_handler.AsWeakHandle()); | 1191 message_name, JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1187 } | 1192 } |
| 1188 | 1193 |
| 1189 { | 1194 { |
| 1190 base::ListValue args; | 1195 base::ListValue args; |
| 1191 base::ListValue* ids = new base::ListValue(); | 1196 base::ListValue* ids = new base::ListValue(); |
| 1192 args.Append(ids); | 1197 args.Append(ids); |
| 1193 ids->Append(new base::StringValue("nonsense")); | 1198 ids->Append(new base::StringValue("nonsense")); |
| 1194 SendJsMessage(message_name, | 1199 SendJsMessage(message_name, |
| 1195 JsArgList(&args), reply_handler.AsWeakHandle()); | 1200 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1196 } | 1201 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 .Times(5); | 1271 .Times(5); |
| 1267 | 1272 |
| 1268 { | 1273 { |
| 1269 base::ListValue args; | 1274 base::ListValue args; |
| 1270 SendJsMessage("getChildNodeIds", | 1275 SendJsMessage("getChildNodeIds", |
| 1271 JsArgList(&args), reply_handler.AsWeakHandle()); | 1276 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1272 } | 1277 } |
| 1273 | 1278 |
| 1274 { | 1279 { |
| 1275 base::ListValue args; | 1280 base::ListValue args; |
| 1276 args.Append(new base::StringValue("")); | 1281 args.Append(new base::StringValue(std::string())); |
| 1277 SendJsMessage("getChildNodeIds", | 1282 SendJsMessage( |
| 1278 JsArgList(&args), reply_handler.AsWeakHandle()); | 1283 "getChildNodeIds", JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1279 } | 1284 } |
| 1280 | 1285 |
| 1281 { | 1286 { |
| 1282 base::ListValue args; | 1287 base::ListValue args; |
| 1283 args.Append(new base::StringValue("nonsense")); | 1288 args.Append(new base::StringValue("nonsense")); |
| 1284 SendJsMessage("getChildNodeIds", | 1289 SendJsMessage("getChildNodeIds", |
| 1285 JsArgList(&args), reply_handler.AsWeakHandle()); | 1290 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1286 } | 1291 } |
| 1287 | 1292 |
| 1288 { | 1293 { |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 size_t folder_b_pos = | 3368 size_t folder_b_pos = |
| 3364 FindChangeInList(folder_b_id, ChangeRecord::ACTION_DELETE); | 3369 FindChangeInList(folder_b_id, ChangeRecord::ACTION_DELETE); |
| 3365 size_t child_pos = FindChangeInList(child_id, ChangeRecord::ACTION_DELETE); | 3370 size_t child_pos = FindChangeInList(child_id, ChangeRecord::ACTION_DELETE); |
| 3366 | 3371 |
| 3367 // Deletes should appear before updates. | 3372 // Deletes should appear before updates. |
| 3368 EXPECT_LT(child_pos, folder_a_pos); | 3373 EXPECT_LT(child_pos, folder_a_pos); |
| 3369 EXPECT_LT(folder_b_pos, folder_a_pos); | 3374 EXPECT_LT(folder_b_pos, folder_a_pos); |
| 3370 } | 3375 } |
| 3371 | 3376 |
| 3372 } // namespace | 3377 } // namespace |
| OLD | NEW |