| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_url_loader.h" | 5 #include "ppapi/tests/test_url_loader.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 void TestURLLoader::RunTest() { | 43 void TestURLLoader::RunTest() { |
| 44 RUN_TEST(BasicGET); | 44 RUN_TEST(BasicGET); |
| 45 RUN_TEST(BasicPOST); | 45 RUN_TEST(BasicPOST); |
| 46 RUN_TEST(CompoundBodyPOST); | 46 RUN_TEST(CompoundBodyPOST); |
| 47 RUN_TEST(EmptyDataPOST); | 47 RUN_TEST(EmptyDataPOST); |
| 48 RUN_TEST(BinaryDataPOST); | 48 RUN_TEST(BinaryDataPOST); |
| 49 RUN_TEST(CustomRequestHeader); | 49 RUN_TEST(CustomRequestHeader); |
| 50 RUN_TEST(IgnoresBogusContentLength); | 50 RUN_TEST(IgnoresBogusContentLength); |
| 51 RUN_TEST(SameOriginRestriction); | 51 RUN_TEST(SameOriginRestriction); |
| 52 RUN_TEST(CrossOriginRequest); | 52 // TODO(bbudge) Find out how to create a request that URL loaders would |
| 53 // consider cross-origin, but that can be served by test server. |
| 54 //RUN_TEST(CrossOriginRequest); |
| 53 RUN_TEST(StreamToFile); | 55 RUN_TEST(StreamToFile); |
| 54 RUN_TEST(AuditURLRedirect); | 56 RUN_TEST(AuditURLRedirect); |
| 55 RUN_TEST(AbortCalls); | 57 RUN_TEST(AbortCalls); |
| 56 } | 58 } |
| 57 | 59 |
| 58 std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, | 60 std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, |
| 59 std::string* data) { | 61 std::string* data) { |
| 60 TestCompletionCallback callback(instance_->pp_instance()); | 62 TestCompletionCallback callback(instance_->pp_instance()); |
| 61 char buf[256]; | 63 char buf[256]; |
| 62 int64_t offset = 0; | 64 int64_t offset = 0; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 request.SetAllowCrossOriginRequests(true); | 279 request.SetAllowCrossOriginRequests(true); |
| 278 | 280 |
| 279 TestCompletionCallback callback(instance_->pp_instance()); | 281 TestCompletionCallback callback(instance_->pp_instance()); |
| 280 | 282 |
| 281 pp::URLLoader loader(*instance_); | 283 pp::URLLoader loader(*instance_); |
| 282 int32_t rv = loader.Open(request, callback); | 284 int32_t rv = loader.Open(request, callback); |
| 283 if (rv == PP_ERROR_WOULDBLOCK) | 285 if (rv == PP_ERROR_WOULDBLOCK) |
| 284 rv = callback.WaitForResult(); | 286 rv = callback.WaitForResult(); |
| 285 | 287 |
| 286 // We expect success since we allowed a cross-origin request. | 288 // We expect success since we allowed a cross-origin request. |
| 287 if (rv == PP_ERROR_NOACCESS) | 289 if (rv != PP_OK) |
| 288 return ReportError("URLLoader::Open()", rv); | 290 return ReportError("URLLoader::Open()", rv); |
| 289 | 291 |
| 290 PASS(); | 292 PASS(); |
| 291 } | 293 } |
| 292 | 294 |
| 293 // This test should cause a redirect and ensure that the loader runs | 295 // This test should cause a redirect and ensure that the loader runs |
| 294 // the callback, rather than following the redirect. | 296 // the callback, rather than following the redirect. |
| 295 std::string TestURLLoader::TestAuditURLRedirect() { | 297 std::string TestURLLoader::TestAuditURLRedirect() { |
| 296 pp::URLRequestInfo request(instance_); | 298 pp::URLRequestInfo request(instance_); |
| 297 // This path will cause the server to return a 301 redirect. | 299 // This path will cause the server to return a 301 redirect. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 376 |
| 375 // TODO(viettrungluu): More abort tests (but add basic tests first). | 377 // TODO(viettrungluu): More abort tests (but add basic tests first). |
| 376 // Also test that Close() aborts properly. crbug.com/69457 | 378 // Also test that Close() aborts properly. crbug.com/69457 |
| 377 | 379 |
| 378 PASS(); | 380 PASS(); |
| 379 } | 381 } |
| 380 | 382 |
| 381 // TODO(viettrungluu): Add tests for FollowRedirect, | 383 // TODO(viettrungluu): Add tests for FollowRedirect, |
| 382 // Get{Upload,Download}Progress, Close (including abort tests if applicable). | 384 // Get{Upload,Download}Progress, Close (including abort tests if applicable). |
| 383 // TODO(darin): Add a test for GrantUniversalAccess. | 385 // TODO(darin): Add a test for GrantUniversalAccess. |
| OLD | NEW |