OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "chrome/browser/download/download_prefs.h" | 7 #include "chrome/browser/download/download_prefs.h" |
8 #include "chrome/browser/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_info_map.h" | 10 #include "chrome/browser/extensions/extension_info_map.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 namespace { | 44 namespace { |
45 | 45 |
46 // Test server's request handler. | 46 // Test server's request handler. |
47 // Returns response that should be sent by the test server. | 47 // Returns response that should be sent by the test server. |
48 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 48 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
49 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse()); | 49 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse()); |
50 | 50 |
51 // For relative path "/doc_path.doc", return success response with MIME type | 51 // For relative path "/doc_path.doc", return success response with MIME type |
52 // "application/msword". | 52 // "application/msword". |
53 if (request.relative_url == "/doc_path.doc") { | 53 if (request.relative_url == "/doc_path.doc") { |
54 response->set_code(net::test_server::SUCCESS); | 54 response->set_code(net::HTTP_OK); |
55 response->set_content_type("application/msword"); | 55 response->set_content_type("application/msword"); |
56 return response.PassAs<HttpResponse>(); | 56 return response.PassAs<HttpResponse>(); |
57 } | 57 } |
58 | 58 |
59 // For relative path "/test_path_attch.txt", return success response with | 59 // For relative path "/test_path_attch.txt", return success response with |
60 // MIME type "plain/text" and content "txt content". Also, set content | 60 // MIME type "plain/text" and content "txt content". Also, set content |
61 // disposition to be attachment. | 61 // disposition to be attachment. |
62 if (request.relative_url == "/text_path_attch.txt") { | 62 if (request.relative_url == "/text_path_attch.txt") { |
63 response->set_code(net::test_server::SUCCESS); | 63 response->set_code(net::HTTP_OK); |
64 response->set_content("txt content"); | 64 response->set_content("txt content"); |
65 response->set_content_type("plain/text"); | 65 response->set_content_type("plain/text"); |
66 response->AddCustomHeader("Content-Disposition", | 66 response->AddCustomHeader("Content-Disposition", |
67 "attachment; filename=test_path.txt"); | 67 "attachment; filename=test_path.txt"); |
68 return response.PassAs<HttpResponse>(); | 68 return response.PassAs<HttpResponse>(); |
69 } | 69 } |
70 // For relative path "/test_path_attch.txt", return success response with | 70 // For relative path "/test_path_attch.txt", return success response with |
71 // MIME type "plain/text" and content "txt content". | 71 // MIME type "plain/text" and content "txt content". |
72 if (request.relative_url == "/text_path.txt") { | 72 if (request.relative_url == "/text_path.txt") { |
73 response->set_code(net::test_server::SUCCESS); | 73 response->set_code(net::HTTP_OK); |
74 response->set_content("txt content"); | 74 response->set_content("txt content"); |
75 response->set_content_type("plain/text"); | 75 response->set_content_type("plain/text"); |
76 return response.PassAs<HttpResponse>(); | 76 return response.PassAs<HttpResponse>(); |
77 } | 77 } |
78 | 78 |
79 // No other requests should be handled in the tests. | 79 // No other requests should be handled in the tests. |
80 EXPECT_TRUE(false) << "NOTREACHED!"; | 80 EXPECT_TRUE(false) << "NOTREACHED!"; |
81 response->set_code(net::test_server::NOT_FOUND); | 81 response->set_code(net::HTTP_NOT_FOUND); |
82 return response.PassAs<HttpResponse>(); | 82 return response.PassAs<HttpResponse>(); |
83 } | 83 } |
84 | 84 |
85 // Tests to verify that resources are correctly intercepted by | 85 // Tests to verify that resources are correctly intercepted by |
86 // StreamsResourceThrottle. | 86 // StreamsResourceThrottle. |
87 // The test extension expects the resources that should be handed to the | 87 // The test extension expects the resources that should be handed to the |
88 // extension to have MIME type 'application/msword' and the resources that | 88 // extension to have MIME type 'application/msword' and the resources that |
89 // should be downloaded by the browser to have MIME type 'plain/text'. | 89 // should be downloaded by the browser to have MIME type 'plain/text'. |
90 class StreamsPrivateApiTest : public ExtensionApiTest { | 90 class StreamsPrivateApiTest : public ExtensionApiTest { |
91 public: | 91 public: |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // The test extension should not receive any events by now. Send it an event | 307 // The test extension should not receive any events by now. Send it an event |
308 // with MIME type "test/done", so it stops waiting for the events. (If there | 308 // with MIME type "test/done", so it stops waiting for the events. (If there |
309 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will | 309 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will |
310 // fail regardless of the sent event; chrome.test.notifySuccess will not be | 310 // fail regardless of the sent event; chrome.test.notifySuccess will not be |
311 // called by the extension). | 311 // called by the extension). |
312 SendDoneEvent(); | 312 SendDoneEvent(); |
313 EXPECT_TRUE(catcher.GetNextResult()); | 313 EXPECT_TRUE(catcher.GetNextResult()); |
314 } | 314 } |
315 | 315 |
316 } // namespace | 316 } // namespace |
OLD | NEW |