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

Unified Diff: chrome/browser/plugin_test.cc

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/plugin_observer.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/plugin_test.cc
diff --git a/chrome/browser/plugin_test.cc b/chrome/browser/plugin_test.cc
index 00c3fdda73e3549dbcd356002ba25dd44ae7c9c9..9ee7d6ed3969a96f1659d0d070e0ce30b4cb056c 100644
--- a/chrome/browser/plugin_test.cc
+++ b/chrome/browser/plugin_test.cc
@@ -32,12 +32,14 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/test/test_timeouts.h"
+#include "chrome/browser/plugin_download_helper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/ui/ui_test.h"
+#include "content/browser/browser_thread_impl.h"
#include "content/browser/net/url_request_mock_http_job.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request_context_getter.h"
@@ -49,7 +51,6 @@
#if defined(OS_WIN)
#include "base/win/registry.h"
-#include "chrome/browser/plugin_download_helper.h"
#endif
class PluginTest : public UITest {
@@ -251,7 +252,9 @@ TEST_F(PluginTest, Silverlight) {
TestPlugin("silverlight.html", "",
TestTimeouts::action_max_timeout_ms(), false);
}
+#endif // defined(OS_WIN)
+#if !defined(OS_CHROMEOS)
namespace {
class TestURLRequestContextGetter : public net::URLRequestContextGetter {
@@ -278,37 +281,38 @@ class TestURLRequestContextGetter : public net::URLRequestContextGetter {
};
} // namespace
+
// This class provides functionality to test the plugin installer download
// file functionality.
-class PluginInstallerDownloadTest
- : public PluginDownloadUrlHelper::DownloadDelegate,
- public testing::Test {
+class PluginInstallerDownloadTest : public testing::Test {
public:
PluginInstallerDownloadTest()
- : success_(false),
- download_helper_(NULL) {}
+ : 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(
- initial_download_path_.spec(), NULL,
- static_cast<PluginDownloadUrlHelper::DownloadDelegate*>(this));
+ download_helper_ = new PluginDownloadUrlHelper();
TestURLRequestContextGetter* context_getter =
new TestURLRequestContextGetter;
- download_helper_->InitiateDownload(context_getter,
- context_getter->GetIOMessageLoopProxy());
+ download_helper_->InitiateDownload(
+ initial_download_path_,
+ context_getter,
+ base::Bind(&PluginInstallerDownloadTest::OnDownloadCompleted,
+ base::Unretained(this)));
- MessageLoop::current()->PostDelayedTask(
+ message_loop_.PostDelayedTask(
FROM_HERE, new MessageLoop::QuitTask,
TestTimeouts::action_max_timeout_ms());
}
- virtual void OnDownloadCompleted(const FilePath& download_path,
- bool success) {
- success_ = success;
+ void OnDownloadCompleted(const FilePath& download_path) {
+ success_ = true;
final_download_path_ = download_path;
- MessageLoop::current()->Quit();
+ message_loop_.Quit();
download_helper_ = NULL;
}
@@ -325,6 +329,8 @@ class PluginInstallerDownloadTest
}
private:
+ MessageLoop message_loop_;
+ content::BrowserThreadImpl file_thread_;
FilePath final_download_path_;
PluginDownloadUrlHelper* download_helper_;
bool success_;
@@ -334,12 +340,11 @@ class PluginInstallerDownloadTest
// This test validates that the plugin downloader downloads the specified file
// to a temporary path with the same file name.
TEST_F(PluginInstallerDownloadTest, PluginInstallerDownloadPathTest) {
- MessageLoop loop(MessageLoop::TYPE_IO);
Start();
- loop.Run();
+ MessageLoop::current()->Run();
EXPECT_TRUE(success());
EXPECT_TRUE(initial_download_path().BaseName().value() ==
final_download_path().BaseName().value());
}
-#endif // defined(OS_WIN)
+#endif // !defined(OS_CHROMEOS)
« no previous file with comments | « chrome/browser/plugin_observer.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698