diff options
Diffstat (limited to 'webkit/glue/resource_fetcher_unittest.cc')
-rw-r--r-- | webkit/glue/resource_fetcher_unittest.cc | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/webkit/glue/resource_fetcher_unittest.cc b/webkit/glue/resource_fetcher_unittest.cc index 98cef0a..70c316b 100644 --- a/webkit/glue/resource_fetcher_unittest.cc +++ b/webkit/glue/resource_fetcher_unittest.cc @@ -5,6 +5,7 @@ #include "webkit/glue/resource_fetcher.h" #include "base/callback.h" +#include "base/message_loop.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" @@ -24,13 +25,8 @@ using webkit_glue::ResourceFetcherWithTimeout; namespace { class ResourceFetcherTests : public TestShellTest { - public: - void SetUp() { - TestShellTest::SetUp(); - } - void TearDown() { - TestShellTest::TearDown(); - } + protected: + UnittestTestServer test_server_; }; static const int kMaxWaitTimeMs = 5000; @@ -154,13 +150,11 @@ FetcherDelegate* FetcherDelegate::instance_ = NULL; // Test a fetch from the test server. TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { - scoped_refptr<UnittestTestServer> server = - UnittestTestServer::CreateServer(); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); WebFrame* frame = test_shell_->webView()->mainFrame(); - GURL url = server->TestServerPage("files/test_shell/index.html"); + GURL url(test_server_.GetURL("files/test_shell/index.html")); scoped_ptr<FetcherDelegate> delegate(new FetcherDelegate); scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcher( url, frame, delegate->NewCallback())); @@ -173,7 +167,7 @@ TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { EXPECT_TRUE(text.find("What is this page?") != std::string::npos); // Test 404 response. - url = server->TestServerPage("files/thisfiledoesntexist.html"); + url = test_server_.GetURL("files/thisfiledoesntexist.html"); delegate.reset(new FetcherDelegate); fetcher.reset(new ResourceFetcher(url, frame, delegate->NewCallback())); @@ -185,9 +179,7 @@ TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { } TEST_F(ResourceFetcherTests, ResourceFetcherDidFail) { - scoped_refptr<UnittestTestServer> server = - UnittestTestServer::CreateServer(); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); WebFrame* frame = test_shell_->webView()->mainFrame(); @@ -208,15 +200,13 @@ TEST_F(ResourceFetcherTests, ResourceFetcherDidFail) { } TEST_F(ResourceFetcherTests, ResourceFetcherTimeout) { - scoped_refptr<UnittestTestServer> server = - UnittestTestServer::CreateServer(); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); WebFrame* frame = test_shell_->webView()->mainFrame(); // Grab a page that takes at least 1 sec to respond, but set the fetcher to // timeout in 0 sec. - GURL url = server->TestServerPage("slow?1"); + GURL url(test_server_.GetURL("slow?1")); scoped_ptr<FetcherDelegate> delegate(new FetcherDelegate); scoped_ptr<ResourceFetcher> fetcher(new ResourceFetcherWithTimeout( url, frame, 0, delegate->NewCallback())); |