diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-31 20:30:28 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-14 20:31:41 -0700 |
commit | 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801 (patch) | |
tree | 382278a54ce7a744d62fa510a9a80688cc12434b /chrome/browser/prerender/prerender_interceptor_unittest.cc | |
parent | c4becdd46e31d261b930e4b5a539cbc1d45c23a6 (diff) | |
download | external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.zip external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.gz external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.bz2 |
Merge Chromium.org at r11.0.672.0: Initial merge by git.
Change-Id: I8b4aaf611a2a405fe3fe10e8a94ea7658645c192
Diffstat (limited to 'chrome/browser/prerender/prerender_interceptor_unittest.cc')
-rw-r--r-- | chrome/browser/prerender/prerender_interceptor_unittest.cc | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/chrome/browser/prerender/prerender_interceptor_unittest.cc b/chrome/browser/prerender/prerender_interceptor_unittest.cc deleted file mode 100644 index 2fc236f..0000000 --- a/chrome/browser/prerender/prerender_interceptor_unittest.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/prerender/prerender_interceptor.h" - -#include <string> - -#include "base/callback.h" -#include "base/file_path.h" -#include "base/message_loop_proxy.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/browser_thread.h" -#include "googleurl/src/gurl.h" -#include "net/base/load_flags.h" -#include "net/test/test_server.h" -#include "net/url_request/url_request_unittest.h" - -class PrerenderInterceptorTest : public testing::Test { - protected: - PrerenderInterceptorTest(); - - void MakeTestUrl(const std::string& base); - virtual void SetUp(); - - net::TestServer test_server_; - GURL gurl_; - GURL last_intercepted_gurl_; - scoped_ptr<net::URLRequest> req_; - - private: - void SetLastInterceptedGurl(const GURL& url); - - PrerenderInterceptor prerender_interceptor_; - MessageLoopForIO io_loop_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; - BrowserThread ui_thread_; - TestDelegate delegate_for_req_; -}; - -PrerenderInterceptorTest::PrerenderInterceptorTest() - : test_server_(net::TestServer::TYPE_HTTP, - FilePath(FILE_PATH_LITERAL("chrome/test/data"))), - last_intercepted_gurl_("http://not.initialized/"), - ALLOW_THIS_IN_INITIALIZER_LIST( - prerender_interceptor_( - NewCallback(this, - &PrerenderInterceptorTest::SetLastInterceptedGurl))), - ui_thread_(BrowserThread::UI, &io_loop_) { -} - -void PrerenderInterceptorTest::SetUp() { - testing::Test::SetUp(); - last_intercepted_gurl_ = GURL("http://nothing.intercepted/"); - - io_message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); - ASSERT_TRUE(test_server_.Start()); -} - -void PrerenderInterceptorTest::MakeTestUrl(const std::string& base) { - gurl_ = test_server_.GetURL(base); - req_.reset(new TestURLRequest(gurl_, &delegate_for_req_)); -} - -void PrerenderInterceptorTest::SetLastInterceptedGurl(const GURL& url) { - last_intercepted_gurl_ = url; -} - -namespace { - -TEST_F(PrerenderInterceptorTest, Interception) { - MakeTestUrl("files/prerender/doc1.html"); - req_->set_load_flags(req_->load_flags() | net::LOAD_PREFETCH); - req_->Start(); - - MessageLoop::current()->Run(); - EXPECT_EQ(URLRequestStatus::SUCCESS, req_->status().status()); - EXPECT_EQ(gurl_, last_intercepted_gurl_); -} - -TEST_F(PrerenderInterceptorTest, NotAPrefetch) { - MakeTestUrl("files/prerender/doc2.html"); - req_->set_load_flags(req_->load_flags() & ~net::LOAD_PREFETCH); - req_->Start(); - - MessageLoop::current()->Run(); - EXPECT_EQ(URLRequestStatus::SUCCESS, req_->status().status()); - EXPECT_NE(gurl_, last_intercepted_gurl_); -} - -TEST_F(PrerenderInterceptorTest, WrongMimeType) { - MakeTestUrl("files/prerender/image.jpeg"); - req_->set_load_flags(req_->load_flags() | net::LOAD_PREFETCH); - req_->Start(); - - MessageLoop::current()->Run(); - EXPECT_EQ(URLRequestStatus::SUCCESS, req_->status().status()); - EXPECT_NE(gurl_, last_intercepted_gurl_); -} - -} // namespace |