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

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

Issue 541743002: Move url_request_mock_http_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 3 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
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/command_line.h" 5 #include "base/command_line.h"
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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/loader/resource_dispatcher_host_impl.h" 10 #include "content/browser/loader/resource_dispatcher_host_impl.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/resource_dispatcher_host_delegate.h" 12 #include "content/public/browser/resource_dispatcher_host_delegate.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
16 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
19 #include "content/shell/common/shell_switches.h" 19 #include "content/shell/common/shell_switches.h"
20 #include "content/test/net/url_request_mock_http_job.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h" 20 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "net/test/url_request/url_request_mock_http_job.h"
22 #include "net/url_request/url_request.h" 22 #include "net/url_request/url_request.h"
23 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include "base/win/registry.h" 26 #include "base/win/registry.h"
27 #endif 27 #endif
28 28
29 // TODO(jschuh): Finish plugins on Win64. crbug.com/180861 29 // TODO(jschuh): Finish plugins on Win64. crbug.com/180861
30 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) 30 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
31 #define MAYBE(x) DISABLED_##x 31 #define MAYBE(x) DISABLED_##x
32 #else 32 #else
33 #define MAYBE(x) x 33 #define MAYBE(x) x
34 #endif 34 #endif
35 35
36 using base::ASCIIToUTF16; 36 using base::ASCIIToUTF16;
37 37
38 namespace content { 38 namespace content {
39 namespace { 39 namespace {
40 40
41 void SetUrlRequestMock(const base::FilePath& path) { 41 void SetUrlRequestMock(const base::FilePath& path) {
42 URLRequestMockHTTPJob::AddUrlHandler(path); 42 net::URLRequestMockHTTPJob::AddUrlHandler(
43 path, content::BrowserThread::GetBlockingPool());
43 } 44 }
44 45
45 } 46 }
46 47
47 class PluginTest : public ContentBrowserTest { 48 class PluginTest : public ContentBrowserTest {
48 protected: 49 protected:
49 PluginTest() {} 50 PluginTest() {}
50 51
51 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
52 // Some NPAPI tests schedule garbage collection to force object tear-down. 53 // Some NPAPI tests schedule garbage collection to force object tear-down.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 #endif 180 #endif
180 181
181 // Flaky, http://crbug.com/302274. 182 // Flaky, http://crbug.com/302274.
182 #if defined(OS_MACOSX) 183 #if defined(OS_MACOSX)
183 #define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response 184 #define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response
184 #else 185 #else
185 #define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response) 186 #define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response)
186 #endif 187 #endif
187 188
188 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) { 189 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) {
189 GURL url(URLRequestMockHTTPJob::GetMockUrl( 190 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(
190 base::FilePath().AppendASCII("npapi"). 191 base::FilePath().AppendASCII("npapi").
191 AppendASCII("plugin_url_request_404.html"))); 192 AppendASCII("plugin_url_request_404.html")));
192 LoadAndWait(url); 193 LoadAndWait(url);
193 } 194 }
194 195
195 // Tests if a plugin executing a self deleting script using Invoke with 196 // Tests if a plugin executing a self deleting script using Invoke with
196 // a modal dialog showing works without crashing or hanging 197 // a modal dialog showing works without crashing or hanging
197 // Disabled, flakily exceeds timeout, http://crbug.com/46257. 198 // Disabled, flakily exceeds timeout, http://crbug.com/46257.
198 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { 199 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) {
199 // Navigate asynchronously because if we waitd until it completes, there's a 200 // Navigate asynchronously because if we waitd until it completes, there's a
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 371
371 // These used to run on Windows: http://crbug.com/396373 372 // These used to run on Windows: http://crbug.com/396373
372 #if defined(OS_MACOSX) 373 #if defined(OS_MACOSX)
373 // Test a browser hang due to special case of multiple 374 // Test a browser hang due to special case of multiple
374 // plugin instances indulged in sync calls across renderer. 375 // plugin instances indulged in sync calls across renderer.
375 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MultipleInstancesSyncCalls)) { 376 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MultipleInstancesSyncCalls)) {
376 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); 377 LoadAndWait(GetURL("multiple_instances_sync_calls.html"));
377 } 378 }
378 379
379 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequestFailWrite)) { 380 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequestFailWrite)) {
380 GURL url(URLRequestMockHTTPJob::GetMockUrl( 381 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(
381 base::FilePath().AppendASCII("npapi"). 382 base::FilePath().AppendASCII("npapi").
382 AppendASCII("plugin_url_request_fail_write.html"))); 383 AppendASCII("plugin_url_request_fail_write.html")));
383 LoadAndWait(url); 384 LoadAndWait(url);
384 } 385 }
385 #endif 386 #endif
386 387
387 #if defined(OS_WIN) 388 #if defined(OS_WIN)
388 // Flaky on Windows x86. http://crbug.com/388245 389 // Flaky on Windows x86. http://crbug.com/388245
389 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_EnsureScriptingWorksInDestroy) { 390 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_EnsureScriptingWorksInDestroy) {
390 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html")); 391 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html"));
391 } 392 }
392 393
393 // This test uses a Windows Event to signal to the plugin that it should crash 394 // This test uses a Windows Event to signal to the plugin that it should crash
394 // on NP_Initialize. 395 // on NP_Initialize.
395 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NoHangIfInitCrashes)) { 396 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NoHangIfInitCrashes)) {
396 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); 397 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit");
397 SetEvent(crash_event); 398 SetEvent(crash_event);
398 LoadAndWait(GetURL("no_hang_if_init_crashes.html")); 399 LoadAndWait(GetURL("no_hang_if_init_crashes.html"));
399 CloseHandle(crash_event); 400 CloseHandle(crash_event);
400 } 401 }
401 #endif 402 #endif
402 403
403 // If this flakes on Mac, use http://crbug.com/111508 404 // If this flakes on Mac, use http://crbug.com/111508
404 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginReferrerTest)) { 405 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginReferrerTest)) {
405 GURL url(URLRequestMockHTTPJob::GetMockUrl( 406 GURL url(net::URLRequestMockHTTPJob::GetMockUrl(
406 base::FilePath().AppendASCII("npapi"). 407 base::FilePath().AppendASCII("npapi").
407 AppendASCII("plugin_url_request_referrer_test.html"))); 408 AppendASCII("plugin_url_request_referrer_test.html")));
408 LoadAndWait(url); 409 LoadAndWait(url);
409 } 410 }
410 411
411 #if defined(OS_MACOSX) 412 #if defined(OS_MACOSX)
412 // Test is flaky, see http://crbug.com/134515. 413 // Test is flaky, see http://crbug.com/134515.
413 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { 414 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) {
414 gfx::Rect bounds(50, 50, 400, 400); 415 gfx::Rect bounds(50, 50, 400, 400);
415 SetWindowBounds(shell()->window(), bounds); 416 SetWindowBounds(shell()->window(), bounds);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 ResourceDispatcherHostDelegate* old_delegate = 558 ResourceDispatcherHostDelegate* old_delegate =
558 ResourceDispatcherHostImpl::Get()->delegate(); 559 ResourceDispatcherHostImpl::Get()->delegate();
559 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); 560 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate);
560 LoadAndWait(url); 561 LoadAndWait(url);
561 test_delegate.WaitForPluginRequest(); 562 test_delegate.WaitForPluginRequest();
562 ASSERT_TRUE(test_delegate.found_cookie()); 563 ASSERT_TRUE(test_delegate.found_cookie());
563 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); 564 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate);
564 } 565 }
565 566
566 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698