| OLD | NEW |
| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 namespace content { | 32 namespace content { |
| 33 | 33 |
| 34 class PluginTest : public ContentBrowserTest { | 34 class PluginTest : public ContentBrowserTest { |
| 35 protected: | 35 protected: |
| 36 PluginTest() {} | 36 PluginTest() {} |
| 37 | 37 |
| 38 virtual void SetUpCommandLine(CommandLine* command_line) { | 38 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 39 // Some NPAPI tests schedule garbage collection to force object tear-down. | 39 // Some NPAPI tests schedule garbage collection to force object tear-down. |
| 40 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); | 40 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); |
| 41 | 41 |
| 42 #if defined(OS_WIN) |
| 42 const testing::TestInfo* const test_info = | 43 const testing::TestInfo* const test_info = |
| 43 testing::UnitTest::GetInstance()->current_test_info(); | 44 testing::UnitTest::GetInstance()->current_test_info(); |
| 44 if (strcmp(test_info->name(), "PrivateEnabled") == 0) { | 45 if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { |
| 45 command_line->AppendSwitch(switches::kOffTheRecord); | |
| 46 } | |
| 47 #if defined(OS_WIN) | |
| 48 else if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { | |
| 49 // The installer adds our process names to the registry key below. Since | 46 // The installer adds our process names to the registry key below. Since |
| 50 // the installer might not have run on this machine, add it manually. | 47 // the installer might not have run on this machine, add it manually. |
| 51 base::win::RegKey regkey; | 48 base::win::RegKey regkey; |
| 52 if (regkey.Open(HKEY_LOCAL_MACHINE, | 49 if (regkey.Open(HKEY_LOCAL_MACHINE, |
| 53 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", | 50 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", |
| 54 KEY_WRITE) == ERROR_SUCCESS) { | 51 KEY_WRITE) == ERROR_SUCCESS) { |
| 55 regkey.CreateKey(L"BROWSER_TESTS.EXE", KEY_READ); | 52 regkey.CreateKey(L"BROWSER_TESTS.EXE", KEY_READ); |
| 56 } | 53 } |
| 57 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) { | 54 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) { |
| 58 // When testing the old WMP plugin, we need to force Chrome to not load | 55 // When testing the old WMP plugin, we need to force Chrome to not load |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); | 68 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); |
| 72 #endif | 69 #endif |
| 73 } | 70 } |
| 74 | 71 |
| 75 virtual void SetUpOnMainThread() OVERRIDE { | 72 virtual void SetUpOnMainThread() OVERRIDE { |
| 76 FilePath path = GetTestFilePath("", ""); | 73 FilePath path = GetTestFilePath("", ""); |
| 77 BrowserThread::PostTask( | 74 BrowserThread::PostTask( |
| 78 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); | 75 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); |
| 79 } | 76 } |
| 80 | 77 |
| 81 void LoadAndWait(const GURL& url) { | 78 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { |
| 82 string16 expected_title(ASCIIToUTF16("OK")); | 79 string16 expected_title(ASCIIToUTF16("OK")); |
| 83 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 80 TitleWatcher title_watcher(window->web_contents(), expected_title); |
| 84 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 81 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
| 85 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); | 82 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); |
| 86 NavigateToURL(shell(), url); | 83 NavigateToURL(window, url); |
| 87 string16 title = title_watcher.WaitAndGetTitle(); | 84 string16 title = title_watcher.WaitAndGetTitle(); |
| 88 if (title == ASCIIToUTF16("plugin_not_found")) { | 85 if (title == ASCIIToUTF16("plugin_not_found")) { |
| 89 const testing::TestInfo* const test_info = | 86 const testing::TestInfo* const test_info = |
| 90 testing::UnitTest::GetInstance()->current_test_info(); | 87 testing::UnitTest::GetInstance()->current_test_info(); |
| 91 LOG(INFO) << "PluginTest." << test_info->name() << | 88 LOG(INFO) << "PluginTest." << test_info->name() << |
| 92 " not running because plugin not installed."; | 89 " not running because plugin not installed."; |
| 93 } else { | 90 } else { |
| 94 EXPECT_EQ(expected_title, title); | 91 EXPECT_EQ(expected_title, title); |
| 95 } | 92 } |
| 96 } | 93 } |
| 97 | 94 |
| 95 void LoadAndWait(const GURL& url) { |
| 96 LoadAndWaitInWindow(shell(), url); |
| 97 } |
| 98 |
| 98 GURL GetURL(const char* filename) { | 99 GURL GetURL(const char* filename) { |
| 99 return GetTestUrl("npapi", filename); | 100 return GetTestUrl("npapi", filename); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void NavigateAway() { | 103 void NavigateAway() { |
| 103 GURL url = GetTestUrl(".", "simple_page.html"); | 104 GURL url = GetTestUrl(".", "simple_page.html"); |
| 104 LoadAndWait(url); | 105 LoadAndWait(url); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void TestPlugin(const char* filename) { | 108 void TestPlugin(const char* filename) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 327 |
| 327 IN_PROC_BROWSER_TEST_F(PluginTest, PluginThreadAsyncCall) { | 328 IN_PROC_BROWSER_TEST_F(PluginTest, PluginThreadAsyncCall) { |
| 328 LoadAndWait(GetURL("plugin_thread_async_call.html")); | 329 LoadAndWait(GetURL("plugin_thread_async_call.html")); |
| 329 } | 330 } |
| 330 | 331 |
| 331 // Test checking the privacy mode is on. | 332 // Test checking the privacy mode is on. |
| 332 // If this flakes on Linux, use http://crbug.com/104380 | 333 // If this flakes on Linux, use http://crbug.com/104380 |
| 333 IN_PROC_BROWSER_TEST_F(PluginTest, PrivateEnabled) { | 334 IN_PROC_BROWSER_TEST_F(PluginTest, PrivateEnabled) { |
| 334 GURL url = GetURL("private.html"); | 335 GURL url = GetURL("private.html"); |
| 335 url = GURL(url.spec() + "?private"); | 336 url = GURL(url.spec() + "?private"); |
| 336 LoadAndWait(url); | 337 LoadAndWaitInWindow(CreateOffTheRecordBrowser(), url); |
| 337 } | 338 } |
| 338 | 339 |
| 339 #if defined(OS_WIN) || defined(OS_MACOSX) | 340 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 340 // Test a browser hang due to special case of multiple | 341 // Test a browser hang due to special case of multiple |
| 341 // plugin instances indulged in sync calls across renderer. | 342 // plugin instances indulged in sync calls across renderer. |
| 342 IN_PROC_BROWSER_TEST_F(PluginTest, MultipleInstancesSyncCalls) { | 343 IN_PROC_BROWSER_TEST_F(PluginTest, MultipleInstancesSyncCalls) { |
| 343 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); | 344 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); |
| 344 } | 345 } |
| 345 #endif | 346 #endif |
| 346 | 347 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { | 448 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { |
| 448 TestPlugin("Java.html"); | 449 TestPlugin("Java.html"); |
| 449 } | 450 } |
| 450 | 451 |
| 451 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { | 452 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { |
| 452 TestPlugin("silverlight.html"); | 453 TestPlugin("silverlight.html"); |
| 453 } | 454 } |
| 454 #endif // defined(OS_WIN) | 455 #endif // defined(OS_WIN) |
| 455 | 456 |
| 456 } // namespace content | 457 } // namespace content |
| OLD | NEW |