| 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/files/file_util.h" | 6 #include "base/files/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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 net::URLRequestMockHTTPJob::AddUrlHandler( | 42 net::URLRequestMockHTTPJob::AddUrlHandler( |
| 43 path, content::BrowserThread::GetBlockingPool()); | 43 path, content::BrowserThread::GetBlockingPool()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } | 46 } |
| 47 | 47 |
| 48 class PluginTest : public ContentBrowserTest { | 48 class PluginTest : public ContentBrowserTest { |
| 49 protected: | 49 protected: |
| 50 PluginTest() {} | 50 PluginTest() {} |
| 51 | 51 |
| 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 52 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 53 // Some NPAPI tests schedule garbage collection to force object tear-down. | 53 // Some NPAPI tests schedule garbage collection to force object tear-down. |
| 54 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); | 54 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); |
| 55 | 55 |
| 56 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
| 57 const testing::TestInfo* const test_info = | 57 const testing::TestInfo* const test_info = |
| 58 testing::UnitTest::GetInstance()->current_test_info(); | 58 testing::UnitTest::GetInstance()->current_test_info(); |
| 59 if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { | 59 if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { |
| 60 // The installer adds our process names to the registry key below. Since | 60 // The installer adds our process names to the registry key below. Since |
| 61 // the installer might not have run on this machine, add it manually. | 61 // the installer might not have run on this machine, add it manually. |
| 62 base::win::RegKey regkey; | 62 base::win::RegKey regkey; |
| 63 if (regkey.Open(HKEY_LOCAL_MACHINE, | 63 if (regkey.Open(HKEY_LOCAL_MACHINE, |
| 64 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", | 64 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", |
| 65 KEY_WRITE) == ERROR_SUCCESS) { | 65 KEY_WRITE) == ERROR_SUCCESS) { |
| 66 regkey.CreateKey(L"BROWSER_TESTS.EXE", KEY_READ); | 66 regkey.CreateKey(L"BROWSER_TESTS.EXE", KEY_READ); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 #elif defined(OS_MACOSX) | 69 #elif defined(OS_MACOSX) |
| 70 base::FilePath plugin_dir; | 70 base::FilePath plugin_dir; |
| 71 PathService::Get(base::DIR_MODULE, &plugin_dir); | 71 PathService::Get(base::DIR_MODULE, &plugin_dir); |
| 72 plugin_dir = plugin_dir.AppendASCII("plugins"); | 72 plugin_dir = plugin_dir.AppendASCII("plugins"); |
| 73 // The plugins directory isn't read by default on the Mac, so it needs to be | 73 // The plugins directory isn't read by default on the Mac, so it needs to be |
| 74 // explicitly registered. | 74 // explicitly registered. |
| 75 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); | 75 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); |
| 76 #endif | 76 #endif |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void SetUpOnMainThread() OVERRIDE { | 79 virtual void SetUpOnMainThread() override { |
| 80 base::FilePath path = GetTestFilePath("", ""); | 80 base::FilePath path = GetTestFilePath("", ""); |
| 81 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
| 82 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); | 82 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { | 85 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { |
| 86 base::string16 expected_title(ASCIIToUTF16("OK")); | 86 base::string16 expected_title(ASCIIToUTF16("OK")); |
| 87 TitleWatcher title_watcher(window->web_contents(), expected_title); | 87 TitleWatcher title_watcher(window->web_contents(), expected_title); |
| 88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
| 89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); | 89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 runner_ = new MessageLoopRunner; | 505 runner_ = new MessageLoopRunner; |
| 506 runner_->Run(); | 506 runner_->Run(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 private: | 509 private: |
| 510 // ResourceDispatcherHostDelegate implementation: | 510 // ResourceDispatcherHostDelegate implementation: |
| 511 virtual void OnResponseStarted( | 511 virtual void OnResponseStarted( |
| 512 net::URLRequest* request, | 512 net::URLRequest* request, |
| 513 ResourceContext* resource_context, | 513 ResourceContext* resource_context, |
| 514 ResourceResponse* response, | 514 ResourceResponse* response, |
| 515 IPC::Sender* sender) OVERRIDE { | 515 IPC::Sender* sender) override { |
| 516 // The URL below comes from plugin_geturl_test.cc. | 516 // The URL below comes from plugin_geturl_test.cc. |
| 517 if (!EndsWith(request->url().spec(), | 517 if (!EndsWith(request->url().spec(), |
| 518 "npapi/plugin_ref_target_page.html", | 518 "npapi/plugin_ref_target_page.html", |
| 519 true)) { | 519 true)) { |
| 520 return; | 520 return; |
| 521 } | 521 } |
| 522 net::HttpRequestHeaders headers; | 522 net::HttpRequestHeaders headers; |
| 523 bool found_cookie = false; | 523 bool found_cookie = false; |
| 524 if (request->GetFullRequestHeaders(&headers) && | 524 if (request->GetFullRequestHeaders(&headers) && |
| 525 headers.ToString().find("Cookie: blah") != std::string::npos) { | 525 headers.ToString().find("Cookie: blah") != std::string::npos) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 ResourceDispatcherHostDelegate* old_delegate = | 558 ResourceDispatcherHostDelegate* old_delegate = |
| 559 ResourceDispatcherHostImpl::Get()->delegate(); | 559 ResourceDispatcherHostImpl::Get()->delegate(); |
| 560 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); | 560 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); |
| 561 LoadAndWait(url); | 561 LoadAndWait(url); |
| 562 test_delegate.WaitForPluginRequest(); | 562 test_delegate.WaitForPluginRequest(); |
| 563 ASSERT_TRUE(test_delegate.found_cookie()); | 563 ASSERT_TRUE(test_delegate.found_cookie()); |
| 564 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); | 564 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace content | 567 } // namespace content |
| OLD | NEW |