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

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

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
12 #include "content/shell/shell.h" 12 #include "content/shell/shell.h"
13 #include "content/shell/shell_switches.h" 13 #include "content/shell/shell_switches.h"
14 #include "content/test/content_browser_test.h" 14 #include "content/test/content_browser_test.h"
15 #include "content/test/content_browser_test_utils.h" 15 #include "content/test/content_browser_test_utils.h"
16 #include "content/test/net/url_request_mock_http_job.h" 16 #include "content/test/net/url_request_mock_http_job.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 #include "webkit/plugins/plugin_switches.h" 18 #include "webkit/plugins/plugin_switches.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "base/win/registry.h" 21 #include "base/win/registry.h"
22 #endif 22 #endif
23 23
24 namespace content { 24 namespace content {
25 namespace { 25 namespace {
26 26
27 void SetUrlRequestMock(const FilePath& path) { 27 void SetUrlRequestMock(const base::FilePath& path) {
28 URLRequestMockHTTPJob::AddUrlHandler(path); 28 URLRequestMockHTTPJob::AddUrlHandler(path);
29 } 29 }
30 30
31 } 31 }
32 32
33 class PluginTest : public ContentBrowserTest { 33 class PluginTest : public ContentBrowserTest {
34 protected: 34 protected:
35 PluginTest() {} 35 PluginTest() {}
36 36
37 virtual void SetUpCommandLine(CommandLine* command_line) { 37 virtual void SetUpCommandLine(CommandLine* command_line) {
(...skipping 14 matching lines...) Expand all
52 } 52 }
53 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) { 53 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) {
54 // When testing the old WMP plugin, we need to force Chrome to not load 54 // When testing the old WMP plugin, we need to force Chrome to not load
55 // the new plugin. 55 // the new plugin.
56 command_line->AppendSwitch(switches::kUseOldWMPPlugin); 56 command_line->AppendSwitch(switches::kUseOldWMPPlugin);
57 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { 57 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) {
58 command_line->AppendSwitchASCII(switches::kTestSandbox, 58 command_line->AppendSwitchASCII(switches::kTestSandbox,
59 "security_tests.dll"); 59 "security_tests.dll");
60 } 60 }
61 #elif defined(OS_MACOSX) 61 #elif defined(OS_MACOSX)
62 FilePath plugin_dir; 62 base::FilePath plugin_dir;
63 PathService::Get(base::DIR_MODULE, &plugin_dir); 63 PathService::Get(base::DIR_MODULE, &plugin_dir);
64 plugin_dir = plugin_dir.AppendASCII("plugins"); 64 plugin_dir = plugin_dir.AppendASCII("plugins");
65 // The plugins directory isn't read by default on the Mac, so it needs to be 65 // The plugins directory isn't read by default on the Mac, so it needs to be
66 // explicitly registered. 66 // explicitly registered.
67 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); 67 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir);
68 #endif 68 #endif
69 } 69 }
70 70
71 virtual void SetUpOnMainThread() OVERRIDE { 71 virtual void SetUpOnMainThread() OVERRIDE {
72 FilePath path = GetTestFilePath("", ""); 72 base::FilePath path = GetTestFilePath("", "");
73 BrowserThread::PostTask( 73 BrowserThread::PostTask(
74 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); 74 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path));
75 } 75 }
76 76
77 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { 77 static void LoadAndWaitInWindow(Shell* window, const GURL& url) {
78 string16 expected_title(ASCIIToUTF16("OK")); 78 string16 expected_title(ASCIIToUTF16("OK"));
79 TitleWatcher title_watcher(window->web_contents(), expected_title); 79 TitleWatcher title_watcher(window->web_contents(), expected_title);
80 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 80 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
81 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); 81 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found"));
82 NavigateToURL(window, url); 82 NavigateToURL(window, url);
(...skipping 15 matching lines...) Expand all
98 GURL GetURL(const char* filename) { 98 GURL GetURL(const char* filename) {
99 return GetTestUrl("npapi", filename); 99 return GetTestUrl("npapi", filename);
100 } 100 }
101 101
102 void NavigateAway() { 102 void NavigateAway() {
103 GURL url = GetTestUrl("", "simple_page.html"); 103 GURL url = GetTestUrl("", "simple_page.html");
104 LoadAndWait(url); 104 LoadAndWait(url);
105 } 105 }
106 106
107 void TestPlugin(const char* filename) { 107 void TestPlugin(const char* filename) {
108 FilePath path = GetTestFilePath("plugin", filename); 108 base::FilePath path = GetTestFilePath("plugin", filename);
109 if (!file_util::PathExists(path)) { 109 if (!file_util::PathExists(path)) {
110 const testing::TestInfo* const test_info = 110 const testing::TestInfo* const test_info =
111 testing::UnitTest::GetInstance()->current_test_info(); 111 testing::UnitTest::GetInstance()->current_test_info();
112 LOG(INFO) << "PluginTest." << test_info->name() << 112 LOG(INFO) << "PluginTest." << test_info->name() <<
113 " not running because test data wasn't found."; 113 " not running because test data wasn't found.";
114 return; 114 return;
115 } 115 }
116 116
117 GURL url = GetTestUrl("plugin", filename); 117 GURL url = GetTestUrl("plugin", filename);
118 LoadAndWait(url); 118 LoadAndWait(url);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 167 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
168 SimulateMouseClick(shell()->web_contents(), 0, 168 SimulateMouseClick(shell()->web_contents(), 0,
169 WebKit::WebMouseEvent::ButtonLeft); 169 WebKit::WebMouseEvent::ButtonLeft);
170 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 170 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
171 } 171 }
172 #endif 172 #endif
173 173
174 // Flaky, http://crbug.com/60071. 174 // Flaky, http://crbug.com/60071.
175 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) { 175 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) {
176 GURL url(URLRequestMockHTTPJob::GetMockUrl( 176 GURL url(URLRequestMockHTTPJob::GetMockUrl(
177 FilePath().AppendASCII("npapi"). 177 base::FilePath().AppendASCII("npapi").
178 AppendASCII("plugin_url_request_404.html"))); 178 AppendASCII("plugin_url_request_404.html")));
179 LoadAndWait(url); 179 LoadAndWait(url);
180 } 180 }
181 181
182 // Tests if a plugin executing a self deleting script using Invoke with 182 // Tests if a plugin executing a self deleting script using Invoke with
183 // a modal dialog showing works without crashing or hanging 183 // a modal dialog showing works without crashing or hanging
184 // Disabled, flakily exceeds timeout, http://crbug.com/46257. 184 // Disabled, flakily exceeds timeout, http://crbug.com/46257.
185 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) { 185 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) {
186 // Navigate asynchronously because if we waitd until it completes, there's a 186 // Navigate asynchronously because if we waitd until it completes, there's a
187 // race condition where the alert can come up before we start watching for it. 187 // race condition where the alert can come up before we start watching for it.
188 shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html")); 188 shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html"));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 #if defined(OS_WIN) || defined(OS_MACOSX) 342 #if defined(OS_WIN) || defined(OS_MACOSX)
343 // Test a browser hang due to special case of multiple 343 // Test a browser hang due to special case of multiple
344 // plugin instances indulged in sync calls across renderer. 344 // plugin instances indulged in sync calls across renderer.
345 IN_PROC_BROWSER_TEST_F(PluginTest, MultipleInstancesSyncCalls) { 345 IN_PROC_BROWSER_TEST_F(PluginTest, MultipleInstancesSyncCalls) {
346 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); 346 LoadAndWait(GetURL("multiple_instances_sync_calls.html"));
347 } 347 }
348 #endif 348 #endif
349 349
350 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequestFailWrite) { 350 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequestFailWrite) {
351 GURL url(URLRequestMockHTTPJob::GetMockUrl( 351 GURL url(URLRequestMockHTTPJob::GetMockUrl(
352 FilePath().AppendASCII("npapi"). 352 base::FilePath().AppendASCII("npapi").
353 AppendASCII("plugin_url_request_fail_write.html"))); 353 AppendASCII("plugin_url_request_fail_write.html")));
354 LoadAndWait(url); 354 LoadAndWait(url);
355 } 355 }
356 356
357 #if defined(OS_WIN) 357 #if defined(OS_WIN)
358 IN_PROC_BROWSER_TEST_F(PluginTest, EnsureScriptingWorksInDestroy) { 358 IN_PROC_BROWSER_TEST_F(PluginTest, EnsureScriptingWorksInDestroy) {
359 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html")); 359 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html"));
360 } 360 }
361 361
362 // This test uses a Windows Event to signal to the plugin that it should crash 362 // This test uses a Windows Event to signal to the plugin that it should crash
363 // on NP_Initialize. 363 // on NP_Initialize.
364 IN_PROC_BROWSER_TEST_F(PluginTest, NoHangIfInitCrashes) { 364 IN_PROC_BROWSER_TEST_F(PluginTest, NoHangIfInitCrashes) {
365 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); 365 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit");
366 SetEvent(crash_event); 366 SetEvent(crash_event);
367 LoadAndWait(GetURL("no_hang_if_init_crashes.html")); 367 LoadAndWait(GetURL("no_hang_if_init_crashes.html"));
368 CloseHandle(crash_event); 368 CloseHandle(crash_event);
369 } 369 }
370 #endif 370 #endif
371 371
372 // If this flakes on Mac, use http://crbug.com/111508 372 // If this flakes on Mac, use http://crbug.com/111508
373 IN_PROC_BROWSER_TEST_F(PluginTest, PluginReferrerTest) { 373 IN_PROC_BROWSER_TEST_F(PluginTest, PluginReferrerTest) {
374 GURL url(URLRequestMockHTTPJob::GetMockUrl( 374 GURL url(URLRequestMockHTTPJob::GetMockUrl(
375 FilePath().AppendASCII("npapi"). 375 base::FilePath().AppendASCII("npapi").
376 AppendASCII("plugin_url_request_referrer_test.html"))); 376 AppendASCII("plugin_url_request_referrer_test.html")));
377 LoadAndWait(url); 377 LoadAndWait(url);
378 } 378 }
379 379
380 #if defined(OS_MACOSX) 380 #if defined(OS_MACOSX)
381 // Test is flaky, see http://crbug.com/134515. 381 // Test is flaky, see http://crbug.com/134515.
382 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { 382 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) {
383 gfx::Rect bounds(50, 50, 400, 400); 383 gfx::Rect bounds(50, 50, 400, 400);
384 SetWindowBounds(shell()->window(), bounds); 384 SetWindowBounds(shell()->window(), bounds);
385 385
386 NavigateToURL(shell(), GetURL("convert_point.html")); 386 NavigateToURL(shell(), GetURL("convert_point.html"));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { 450 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) {
451 TestPlugin("Java.html"); 451 TestPlugin("Java.html");
452 } 452 }
453 453
454 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { 454 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) {
455 TestPlugin("silverlight.html"); 455 TestPlugin("silverlight.html");
456 } 456 }
457 #endif // defined(OS_WIN) 457 #endif // defined(OS_WIN)
458 458
459 } // namespace content 459 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/pepper_flash_settings_helper_impl.cc ('k') | content/browser/plugin_data_remover_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698