Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_apitest.cc

Issue 15505003: GTTF: Convert most tests in content to use EmbeddedTestServer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 17 matching lines...) Expand all
28 28
29 using content::BrowserContext; 29 using content::BrowserContext;
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using content::DownloadItem; 31 using content::DownloadItem;
32 using content::DownloadManager; 32 using content::DownloadManager;
33 using content::DownloadUrlParameters; 33 using content::DownloadUrlParameters;
34 using content::ResourceController; 34 using content::ResourceController;
35 using content::WebContents; 35 using content::WebContents;
36 using extensions::Event; 36 using extensions::Event;
37 using extensions::ExtensionSystem; 37 using extensions::ExtensionSystem;
38 using net::test_server::BasicHttpResponse;
38 using net::test_server::HttpRequest; 39 using net::test_server::HttpRequest;
39 using net::test_server::HttpResponse; 40 using net::test_server::HttpResponse;
40 using net::test_server::EmbeddedTestServer; 41 using net::test_server::EmbeddedTestServer;
41 using testing::_; 42 using testing::_;
42 43
43 namespace { 44 namespace {
44 45
45 // Test server's request handler. 46 // Test server's request handler.
46 // Returns response that should be sent by the test server. 47 // Returns response that should be sent by the test server.
47 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { 48 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
48 scoped_ptr<HttpResponse> response(new HttpResponse()); 49 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse());
49 50
50 // 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
51 // "application/msword". 52 // "application/msword".
52 if (request.relative_url == "/doc_path.doc") { 53 if (request.relative_url == "/doc_path.doc") {
53 response->set_code(net::test_server::SUCCESS); 54 response->set_code(net::test_server::SUCCESS);
54 response->set_content_type("application/msword"); 55 response->set_content_type("application/msword");
55 return response.Pass(); 56 return response.PassAs<HttpResponse>();
56 } 57 }
57 58
58 // For relative path "/test_path_attch.txt", return success response with 59 // For relative path "/test_path_attch.txt", return success response with
59 // MIME type "plain/text" and content "txt content". Also, set content 60 // MIME type "plain/text" and content "txt content". Also, set content
60 // disposition to be attachment. 61 // disposition to be attachment.
61 if (request.relative_url == "/text_path_attch.txt") { 62 if (request.relative_url == "/text_path_attch.txt") {
62 response->set_code(net::test_server::SUCCESS); 63 response->set_code(net::test_server::SUCCESS);
63 response->set_content("txt content"); 64 response->set_content("txt content");
64 response->set_content_type("plain/text"); 65 response->set_content_type("plain/text");
65 response->AddCustomHeader("Content-Disposition", 66 response->AddCustomHeader("Content-Disposition",
66 "attachment; filename=test_path.txt"); 67 "attachment; filename=test_path.txt");
67 return response.Pass(); 68 return response.PassAs<HttpResponse>();
68 } 69 }
69 // For relative path "/test_path_attch.txt", return success response with 70 // For relative path "/test_path_attch.txt", return success response with
70 // MIME type "plain/text" and content "txt content". 71 // MIME type "plain/text" and content "txt content".
71 if (request.relative_url == "/text_path.txt") { 72 if (request.relative_url == "/text_path.txt") {
72 response->set_code(net::test_server::SUCCESS); 73 response->set_code(net::test_server::SUCCESS);
73 response->set_content("txt content"); 74 response->set_content("txt content");
74 response->set_content_type("plain/text"); 75 response->set_content_type("plain/text");
75 return response.Pass(); 76 return response.PassAs<HttpResponse>();
76 } 77 }
77 78
78 // No other requests should be handled in the tests. 79 // No other requests should be handled in the tests.
79 EXPECT_TRUE(false) << "NOTREACHED!"; 80 EXPECT_TRUE(false) << "NOTREACHED!";
80 response->set_code(net::test_server::NOT_FOUND); 81 response->set_code(net::test_server::NOT_FOUND);
81 return response.Pass(); 82 return response.PassAs<HttpResponse>();
82 } 83 }
83 84
84 // Tests to verify that resources are correctly intercepted by 85 // Tests to verify that resources are correctly intercepted by
85 // StreamsResourceThrottle. 86 // StreamsResourceThrottle.
86 // 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
87 // extension to have MIME type 'application/msword' and the resources that 88 // extension to have MIME type 'application/msword' and the resources that
88 // 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'.
89 class StreamsPrivateApiTest : public ExtensionApiTest { 90 class StreamsPrivateApiTest : public ExtensionApiTest {
90 public: 91 public:
91 StreamsPrivateApiTest() {} 92 StreamsPrivateApiTest() {}
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // 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
307 // 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
308 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will 309 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will
309 // 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
310 // called by the extension). 311 // called by the extension).
311 SendDoneEvent(); 312 SendDoneEvent();
312 EXPECT_TRUE(catcher.GetNextResult()); 313 EXPECT_TRUE(catcher.GetNextResult());
313 } 314 }
314 315
315 } // namespace 316 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/oobe_browsertest.cc ('k') | chrome/browser/google_apis/drive_api_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698