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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 bool TestURLLoader::Init() { | 64 bool TestURLLoader::Init() { |
65 file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted*>( | 65 file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted*>( |
66 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); | 66 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); |
67 if (!file_io_trusted_interface_) { | 67 if (!file_io_trusted_interface_) { |
68 instance_->AppendError("FileIOTrusted interface not available"); | 68 instance_->AppendError("FileIOTrusted interface not available"); |
69 } | 69 } |
70 return InitTestingInterface() && EnsureRunningOverHTTP(); | 70 return InitTestingInterface() && EnsureRunningOverHTTP(); |
71 } | 71 } |
72 | 72 |
73 void TestURLLoader::RunTest() { | 73 void TestURLLoader::RunTests(const std::string& filter) { |
74 RUN_TEST_FORCEASYNC_AND_NOT(BasicGET); | 74 RUN_TEST_FORCEASYNC_AND_NOT(BasicGET, filter); |
75 RUN_TEST_FORCEASYNC_AND_NOT(BasicPOST); | 75 RUN_TEST_FORCEASYNC_AND_NOT(BasicPOST, filter); |
76 RUN_TEST_FORCEASYNC_AND_NOT(BasicFilePOST); | 76 RUN_TEST_FORCEASYNC_AND_NOT(BasicFilePOST, filter); |
77 RUN_TEST_FORCEASYNC_AND_NOT(BasicFileRangePOST); | 77 RUN_TEST_FORCEASYNC_AND_NOT(BasicFileRangePOST, filter); |
78 RUN_TEST_FORCEASYNC_AND_NOT(CompoundBodyPOST); | 78 RUN_TEST_FORCEASYNC_AND_NOT(CompoundBodyPOST, filter); |
79 RUN_TEST_FORCEASYNC_AND_NOT(EmptyDataPOST); | 79 RUN_TEST_FORCEASYNC_AND_NOT(EmptyDataPOST, filter); |
80 RUN_TEST_FORCEASYNC_AND_NOT(BinaryDataPOST); | 80 RUN_TEST_FORCEASYNC_AND_NOT(BinaryDataPOST, filter); |
81 RUN_TEST_FORCEASYNC_AND_NOT(CustomRequestHeader); | 81 RUN_TEST_FORCEASYNC_AND_NOT(CustomRequestHeader, filter); |
82 RUN_TEST_FORCEASYNC_AND_NOT(FailsBogusContentLength); | 82 RUN_TEST_FORCEASYNC_AND_NOT(FailsBogusContentLength, filter); |
83 RUN_TEST_FORCEASYNC_AND_NOT(SameOriginRestriction); | 83 RUN_TEST_FORCEASYNC_AND_NOT(SameOriginRestriction, filter); |
84 RUN_TEST_FORCEASYNC_AND_NOT(JavascriptURLRestriction); | 84 RUN_TEST_FORCEASYNC_AND_NOT(JavascriptURLRestriction, filter); |
85 RUN_TEST_FORCEASYNC_AND_NOT(CrossOriginRequest); | 85 RUN_TEST_FORCEASYNC_AND_NOT(CrossOriginRequest, filter); |
86 RUN_TEST_FORCEASYNC_AND_NOT(StreamToFile); | 86 RUN_TEST_FORCEASYNC_AND_NOT(StreamToFile, filter); |
87 RUN_TEST_FORCEASYNC_AND_NOT(AuditURLRedirect); | 87 RUN_TEST_FORCEASYNC_AND_NOT(AuditURLRedirect, filter); |
88 RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls); | 88 RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls, filter); |
89 RUN_TEST_FORCEASYNC_AND_NOT(UntendedLoad); | 89 RUN_TEST_FORCEASYNC_AND_NOT(UntendedLoad, filter); |
90 } | 90 } |
91 | 91 |
92 std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io, | 92 std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io, |
93 std::string* data) { | 93 std::string* data) { |
94 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 94 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
95 char buf[256]; | 95 char buf[256]; |
96 int64_t offset = 0; | 96 int64_t offset = 0; |
97 | 97 |
98 for (;;) { | 98 for (;;) { |
99 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback); | 99 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 return error; | 612 return error; |
613 if (body != "hello\n") | 613 if (body != "hello\n") |
614 return ReportError("Couldn't read data", rv); | 614 return ReportError("Couldn't read data", rv); |
615 | 615 |
616 PASS(); | 616 PASS(); |
617 } | 617 } |
618 | 618 |
619 // TODO(viettrungluu): Add tests for FollowRedirect, | 619 // TODO(viettrungluu): Add tests for FollowRedirect, |
620 // Get{Upload,Download}Progress, Close (including abort tests if applicable). | 620 // Get{Upload,Download}Progress, Close (including abort tests if applicable). |
621 // TODO(darin): Add a test for GrantUniversalAccess. | 621 // TODO(darin): Add a test for GrantUniversalAccess. |
OLD | NEW |