diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 14:26:42 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 14:26:42 +0000 |
commit | 5d474ff6e09b20d734a6074cbca3477bebcf76a9 (patch) | |
tree | 7a934f99247a5dd6276084370996dba2ee402446 /chrome/browser/plugin_test.cc | |
parent | e4eec96d49686a9b90fc9c0dafc510af3a712726 (diff) | |
download | chromium_src-5d474ff6e09b20d734a6074cbca3477bebcf76a9.zip chromium_src-5d474ff6e09b20d734a6074cbca3477bebcf76a9.tar.gz chromium_src-5d474ff6e09b20d734a6074cbca3477bebcf76a9.tar.bz2 |
Revert 117210 - Show error message when downloading a plug-in installer fails.
Also, don't try to directly download Flash Player from http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player.exe anymore.
TBR=arv@chromium.org
BUG=62079
TEST=Go to http://www/~bauerb/no_crawl/test/install_plugin.html, turn off your network and click on "Get Plug-in". You should see an error.
Review URL: http://codereview.chromium.org/9149004
TBR=bauerb@chromium.org
Review URL: http://codereview.chromium.org/9190005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_test.cc')
-rw-r--r-- | chrome/browser/plugin_test.cc | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/chrome/browser/plugin_test.cc b/chrome/browser/plugin_test.cc index d4639e1..711ef0d 100644 --- a/chrome/browser/plugin_test.cc +++ b/chrome/browser/plugin_test.cc @@ -27,7 +27,9 @@ #include <string> +#include "base/file_path.h" #include "base/file_util.h" +#include "base/message_loop.h" #include "base/path_service.h" #include "base/test/test_timeouts.h" #include "chrome/browser/plugin_download_helper.h" @@ -38,7 +40,10 @@ #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/ui/ui_test.h" #include "content/browser/net/url_request_mock_http_job.h" +#include "content/test/test_browser_thread.h" #include "net/base/net_util.h" +#include "net/url_request/url_request_context_getter.h" +#include "net/url_request/url_request_test_util.h" #include "third_party/npapi/bindings/npapi.h" #include "webkit/plugins/npapi/plugin_constants_win.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -246,3 +251,98 @@ TEST_F(PluginTest, Silverlight) { TestTimeouts::action_max_timeout_ms(), false); } #endif // defined(OS_WIN) + +#if !defined(OS_CHROMEOS) +namespace { + +class TestURLRequestContextGetter : public net::URLRequestContextGetter { + public: + explicit TestURLRequestContextGetter() { + io_message_loop_proxy_ = base::MessageLoopProxy::current(); + } + virtual net::URLRequestContext* GetURLRequestContext() { + if (!context_) + context_ = new TestURLRequestContext(); + return context_; + } + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { + return io_message_loop_proxy_; + } + + protected: + scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + + private: + virtual ~TestURLRequestContextGetter() {} + + scoped_refptr<net::URLRequestContext> context_; +}; + +} // namespace + +// This class provides functionality to test the plugin installer download +// file functionality. +class PluginInstallerDownloadTest : public testing::Test { + public: + PluginInstallerDownloadTest() + : message_loop_(MessageLoop::TYPE_IO), + file_thread_(content::BrowserThread::FILE, &message_loop_), + download_helper_(NULL), + success_(false) {} + ~PluginInstallerDownloadTest() {} + + void Start() { + initial_download_path_ = PluginTest::GetTestUrl("flash.html", "", false); + download_helper_ = new PluginDownloadUrlHelper(); + TestURLRequestContextGetter* context_getter = + new TestURLRequestContextGetter; + download_helper_->InitiateDownload( + initial_download_path_, + context_getter, + base::Bind(&PluginInstallerDownloadTest::OnDownloadCompleted, + base::Unretained(this))); + + message_loop_.PostDelayedTask( + FROM_HERE, MessageLoop::QuitClosure(), + TestTimeouts::action_max_timeout_ms()); + } + + void OnDownloadCompleted(const FilePath& download_path) { + success_ = true; + final_download_path_ = download_path; + message_loop_.Quit(); + download_helper_ = NULL; + } + + FilePath final_download_path() const { + return final_download_path_; + } + + FilePath initial_download_path() const { + return final_download_path_; + } + + bool success() const { + return success_; + } + + private: + MessageLoop message_loop_; + content::TestBrowserThread file_thread_; + FilePath final_download_path_; + PluginDownloadUrlHelper* download_helper_; + bool success_; + GURL initial_download_path_; +}; + +// This test validates that the plugin downloader downloads the specified file +// to a temporary path with the same file name. +TEST_F(PluginInstallerDownloadTest, PluginInstallerDownloadPathTest) { + Start(); + MessageLoop::current()->Run(); + + EXPECT_TRUE(success()); + EXPECT_TRUE(initial_download_path().BaseName().value() == + final_download_path().BaseName().value()); +} +#endif // !defined(OS_CHROMEOS) |