OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ | 5 #ifndef CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ |
6 #define CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ | 6 #define CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 12 #include "content/public/common/resource_type.h" |
11 | 13 |
12 namespace base { | 14 namespace base { |
13 class FilePath; | 15 class FilePath; |
14 } | 16 } |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 namespace test_server { | 19 namespace test_server { |
18 struct HttpRequest; | 20 struct HttpRequest; |
19 class HttpResponse; | 21 class HttpResponse; |
20 } | 22 } |
21 } | 23 } |
22 | 24 |
| 25 using content::ResourceDispatcherHostDelegate; |
| 26 |
| 27 class TestDispatcherHostDelegate : public ResourceDispatcherHostDelegate { |
| 28 public: |
| 29 explicit TestDispatcherHostDelegate() |
| 30 : ResourceDispatcherHostDelegate(), found_pnacl_header_(false) {} |
| 31 |
| 32 virtual ~TestDispatcherHostDelegate() {} |
| 33 |
| 34 virtual void RequestBeginning( |
| 35 net::URLRequest* request, |
| 36 content::ResourceContext* resource_context, |
| 37 content::AppCacheService* appcache_service, |
| 38 content::ResourceType resource_type, |
| 39 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE; |
| 40 |
| 41 bool found_pnacl_header() const { return found_pnacl_header_; } |
| 42 |
| 43 private: |
| 44 bool found_pnacl_header_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TestDispatcherHostDelegate); |
| 47 }; |
| 48 |
23 class PnaclHeaderTest : public InProcessBrowserTest { | 49 class PnaclHeaderTest : public InProcessBrowserTest { |
24 public: | 50 public: |
25 PnaclHeaderTest(); | 51 PnaclHeaderTest(); |
26 virtual ~PnaclHeaderTest(); | 52 virtual ~PnaclHeaderTest(); |
27 | 53 |
28 // Run a simple test that checks that the NaCl plugin sends the right | 54 // Run a simple test that checks that the NaCl plugin sends the right |
29 // headers when doing |expected_noncors| same origin pexe load requests | 55 // headers when doing |expected_noncors| same origin pexe load requests |
30 // and |expected_cors| cross origin pexe load requests. | 56 // and |expected_cors| cross origin pexe load requests. |
31 void RunLoadTest(const std::string& url, | 57 void RunLoadTest(const std::string& url, |
32 int expected_noncors, | 58 int expected_noncors, |
33 int expected_cors); | 59 int expected_cors); |
34 | 60 |
35 private: | 61 private: |
36 void StartServer(); | 62 void StartServer(); |
37 | 63 |
38 scoped_ptr<net::test_server::HttpResponse> WatchForPexeFetch( | 64 scoped_ptr<net::test_server::HttpResponse> WatchForPexeFetch( |
39 const net::test_server::HttpRequest& request); | 65 const net::test_server::HttpRequest& request); |
40 | 66 |
41 int noncors_loads_; | 67 int noncors_loads_; |
42 int cors_loads_; | 68 int cors_loads_; |
| 69 TestDispatcherHostDelegate test_delegate_; |
43 DISALLOW_COPY_AND_ASSIGN(PnaclHeaderTest); | 70 DISALLOW_COPY_AND_ASSIGN(PnaclHeaderTest); |
44 }; | 71 }; |
45 | 72 |
46 #endif // CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ | 73 #endif // CHROME_TEST_NACL_PNACL_HEADER_TEST_H_ |
OLD | NEW |