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

Side by Side Diff: content/browser/plugin_service_impl_browsertest.cc

Issue 9114020: Remove task.h and finish base::Bind() migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/browser/resource_context.h" 15 #include "content/browser/resource_context.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "content/test/test_browser_thread.h" 17 #include "content/test/test_browser_thread.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return get_resource_context_called_; 142 return get_resource_context_called_;
142 } 143 }
143 144
144 private: 145 private:
145 const content::ResourceContext& context_; 146 const content::ResourceContext& context_;
146 bool get_resource_context_called_; 147 bool get_resource_context_called_;
147 148
148 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); 149 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient);
149 }; 150 };
150 151
151 void DoNothing() {}
152
153 void QuitUIMessageLoopFromIOThread() { 152 void QuitUIMessageLoopFromIOThread() {
154 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 153 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
155 MessageLoop::QuitClosure()); 154 MessageLoop::QuitClosure());
156 } 155 }
157 156
158 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { 157 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
160 // Start opening the channel 159 // Start opening the channel
161 PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin( 160 PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin(
162 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client); 161 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client);
163 // Immediately cancel it. This is guaranteed to work since PluginService needs 162 // Immediately cancel it. This is guaranteed to work since PluginService needs
164 // to consult its filter on the FILE thread. 163 // to consult its filter on the FILE thread.
165 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client); 164 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client);
166 // Before we terminate the test, add a roundtrip through the FILE thread to 165 // Before we terminate the test, add a roundtrip through the FILE thread to
167 // make sure that it's had a chance to post back to the IO thread. Then signal 166 // make sure that it's had a chance to post back to the IO thread. Then signal
168 // the UI thread to stop and exit the test. 167 // the UI thread to stop and exit the test.
169 BrowserThread::PostTaskAndReply( 168 BrowserThread::PostTaskAndReply(
170 BrowserThread::FILE, FROM_HERE, 169 BrowserThread::FILE, FROM_HERE,
171 base::Bind(&DoNothing), 170 base::Bind(&base::DoNothing),
172 base::Bind(&QuitUIMessageLoopFromIOThread)); 171 base::Bind(&QuitUIMessageLoopFromIOThread));
173 } 172 }
174 173
175 // Should not attempt to open a channel, since it should be canceled early on. 174 // Should not attempt to open a channel, since it should be canceled early on.
176 IN_PROC_BROWSER_TEST_F(PluginServiceTest, CancelOpenChannelToPluginService) { 175 IN_PROC_BROWSER_TEST_F(PluginServiceTest, CancelOpenChannelToPluginService) {
177 ::testing::StrictMock<MockCanceledPluginServiceClient> mock_client( 176 ::testing::StrictMock<MockCanceledPluginServiceClient> mock_client(
178 browser()->profile()->GetResourceContext()); 177 browser()->profile()->GetResourceContext());
179 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 178 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
180 base::Bind(OpenChannelAndThenCancel, &mock_client)); 179 base::Bind(OpenChannelAndThenCancel, &mock_client));
181 ui_test_utils::RunMessageLoop(); 180 ui_test_utils::RunMessageLoop();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 BrowserThread::IO, FROM_HERE, 301 BrowserThread::IO, FROM_HERE,
303 base::Bind(&OpenChannel, &mock_client)); 302 base::Bind(&OpenChannel, &mock_client));
304 ui_test_utils::RunMessageLoop(); 303 ui_test_utils::RunMessageLoop();
305 EXPECT_TRUE(mock_client.get_resource_context_called()); 304 EXPECT_TRUE(mock_client.get_resource_context_called());
306 EXPECT_TRUE(mock_client.set_plugin_info_called()); 305 EXPECT_TRUE(mock_client.set_plugin_info_called());
307 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 306 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
308 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); 307 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called());
309 } 308 }
310 309
311 } // namespace 310 } // namespace
OLDNEW
« no previous file with comments | « content/browser/net/url_request_abort_on_end_job.cc ('k') | content/browser/renderer_host/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698