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

Side by Side Diff: chrome/common/chrome_plugin_unittest.cc

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Tests exercising the Chrome Plugin API. 4 // Tests exercising the Chrome Plugin API.
5 5
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/chrome_plugin_host.h" 9 #include "chrome/browser/chrome_plugin_host.h"
10 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/net/url_request_context_getter.h" 11 #include "chrome/browser/net/url_request_context_getter.h"
11 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
12 #include "chrome/common/chrome_plugin_lib.h" 13 #include "chrome/common/chrome_plugin_lib.h"
13 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" 14 #include "chrome/test/chrome_plugin/test_chrome_plugin.h"
14 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
15 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
16 #include "net/url_request/url_request_test_job.h" 17 #include "net/url_request/url_request_test_job.h"
17 #include "net/url_request/url_request_unittest.h" 18 #include "net/url_request/url_request_unittest.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
(...skipping 10 matching lines...) Expand all
30 context_ = new TestURLRequestContext(); 31 context_ = new TestURLRequestContext();
31 return context_; 32 return context_;
32 } 33 }
33 private: 34 private:
34 scoped_refptr<URLRequestContext> context_; 35 scoped_refptr<URLRequestContext> context_;
35 }; 36 };
36 37
37 class ChromePluginTest : public testing::Test, public URLRequest::Delegate { 38 class ChromePluginTest : public testing::Test, public URLRequest::Delegate {
38 public: 39 public:
39 ChromePluginTest() 40 ChromePluginTest()
40 : request_(NULL), 41 : io_thread_(ChromeThread::IO, &message_loop_),
42 request_(NULL),
41 response_buffer_(new net::IOBuffer(kResponseBufferSize)), 43 response_buffer_(new net::IOBuffer(kResponseBufferSize)),
42 plugin_(NULL), 44 plugin_(NULL),
43 expected_payload_(NULL), 45 expected_payload_(NULL),
44 request_context_getter_(new TestURLRequestContextGetter()) { 46 request_context_getter_(new TestURLRequestContextGetter()) {
45 test_funcs_.test_make_request = NULL; 47 test_funcs_.test_make_request = NULL;
46 } 48 }
47 49
48 // Loads/unloads the chrome test plugin. 50 // Loads/unloads the chrome test plugin.
49 void LoadPlugin(); 51 void LoadPlugin();
50 void UnloadPlugin(); 52 void UnloadPlugin();
(...skipping 27 matching lines...) Expand all
78 80
79 // Clear the request before flushing the message loop since killing the 81 // Clear the request before flushing the message loop since killing the
80 // request can result in the generation of more tasks. 82 // request can result in the generation of more tasks.
81 request_.reset(); 83 request_.reset();
82 84
83 // Flush the message loop to make Purify happy. 85 // Flush the message loop to make Purify happy.
84 message_loop_.RunAllPending(); 86 message_loop_.RunAllPending();
85 } 87 }
86 protected: 88 protected:
87 MessageLoopForIO message_loop_; 89 MessageLoopForIO message_loop_;
90 ChromeThread io_thread_;
88 91
89 // Note: we use URLRequest (instead of URLFetcher) because this allows the 92 // Note: we use URLRequest (instead of URLFetcher) because this allows the
90 // request to be intercepted. 93 // request to be intercepted.
91 scoped_ptr<URLRequest> request_; 94 scoped_ptr<URLRequest> request_;
92 scoped_refptr<net::IOBuffer> response_buffer_; 95 scoped_refptr<net::IOBuffer> response_buffer_;
93 std::string response_data_; 96 std::string response_data_;
94 97
95 ChromePluginLib* plugin_; 98 ChromePluginLib* plugin_;
96 TestFuncParams::PluginFuncs test_funcs_; 99 TestFuncParams::PluginFuncs test_funcs_;
97 const TestResponsePayload* expected_payload_; 100 const TestResponsePayload* expected_payload_;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 292
290 // Tests that the plugin does not intercept its own requests. 293 // Tests that the plugin does not intercept its own requests.
291 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { 294 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) {
292 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; 295 const TestResponsePayload& payload = kChromeTestPluginPayloads[0];
293 296
294 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( 297 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request(
295 "GET", GURL(payload.url))); 298 "GET", GURL(payload.url)));
296 299
297 MessageLoop::current()->Run(); 300 MessageLoop::current()->Run();
298 } 301 }
OLDNEW
« chrome/browser/in_process_webkit/webkit_thread.cc ('K') | « chrome/common/child_process_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698