- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / tests / test_url_loader.h
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
3 // found in the LICENSE file.
4
5 #ifndef PAPPI_TESTS_TEST_URL_LOADER_H_
6 #define PAPPI_TESTS_TEST_URL_LOADER_H_
7
8 #include <string>
9
10 #include "ppapi/c/private/ppb_file_io_private.h"
11 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
12 #include "ppapi/tests/test_case.h"
13
14 namespace pp {
15 class FileIO;
16 class FileRef;
17 class FileSystem;
18 class URLLoader;
19 class URLRequestInfo;
20 }
21
22 class TestURLLoader : public TestCase {
23  public:
24   explicit TestURLLoader(TestingInstance* instance);
25
26   // TestCase implementation.
27   virtual bool Init();
28   virtual void RunTests(const std::string& filter);
29
30  private:
31   std::string ReadEntireFile(pp::FileIO* file_io, std::string* data);
32   std::string ReadEntireResponseBody(pp::URLLoader* loader,
33                                      std::string* body);
34   std::string LoadAndCompareBody(const pp::URLRequestInfo& request,
35                                  const std::string& expected_body);
36   int32_t OpenFileSystem(pp::FileSystem* file_system, std::string* message);
37   int32_t PrepareFileForPost(const pp::FileRef& file_ref,
38                              const std::string& data,
39                              std::string* message);
40   std::string GetReachableAbsoluteURL(const std::string& file_name);
41   std::string GetReachableCrossOriginURL(const std::string& file_name);
42   int32_t OpenUntrusted(const pp::URLRequestInfo& request);
43   int32_t OpenTrusted(const pp::URLRequestInfo& request);
44   int32_t OpenUntrusted(const std::string& method,
45                         const std::string& header);
46   int32_t OpenTrusted(const std::string& method,
47                       const std::string& header);
48   int32_t Open(const pp::URLRequestInfo& request,
49                bool with_universal_access);
50   int32_t OpenWithPrefetchBufferThreshold(int32_t lower, int32_t upper);
51
52   std::string TestBasicGET();
53   std::string TestBasicPOST();
54   std::string TestBasicFilePOST();
55   std::string TestBasicFileRangePOST();
56   std::string TestCompoundBodyPOST();
57   std::string TestEmptyDataPOST();
58   std::string TestBinaryDataPOST();
59   std::string TestCustomRequestHeader();
60   std::string TestFailsBogusContentLength();
61   std::string TestStreamToFile();
62   std::string TestUntrustedSameOriginRestriction();
63   std::string TestTrustedSameOriginRestriction();
64   std::string TestUntrustedCrossOriginRequest();
65   std::string TestTrustedCrossOriginRequest();
66   std::string TestUntrustedJavascriptURLRestriction();
67   std::string TestTrustedJavascriptURLRestriction();
68   std::string TestUntrustedHttpRequests();
69   std::string TestTrustedHttpRequests();
70   std::string TestFollowURLRedirect();
71   std::string TestAuditURLRedirect();
72   std::string TestAbortCalls();
73   std::string TestUntendedLoad();
74   std::string TestPrefetchBufferThreshold();
75
76   const PPB_FileIO_Private* file_io_private_interface_;
77   const PPB_URLLoaderTrusted* url_loader_trusted_interface_;
78 };
79
80 #endif  // PAPPI_TESTS_TEST_URL_LOADER_H_