diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 20:07:11 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 20:07:11 +0000 |
commit | 95409e1020037b0bbfbce17f861d3de090d10186 (patch) | |
tree | 90a893af1247b1d4a3767c5ab14aae797f467946 /chrome/browser/history | |
parent | 701e869b30deffda579c5c413cf1d73defee34fa (diff) | |
download | chromium_src-95409e1020037b0bbfbce17f861d3de090d10186.zip chromium_src-95409e1020037b0bbfbce17f861d3de090d10186.tar.gz chromium_src-95409e1020037b0bbfbce17f861d3de090d10186.tar.bz2 |
Test server cleanup patch of death:
- reduce the number of different classes
- clean up the internal code
- modify the interface to expose less internal details
(this will allow more flexibility with port numbers)
TEST=many
BUG=49680
Review URL: http://codereview.chromium.org/3080029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/multipart_uitest.cc | 9 | ||||
-rw-r--r-- | chrome/browser/history/redirect_uitest.cc | 73 |
2 files changed, 36 insertions, 46 deletions
diff --git a/chrome/browser/history/multipart_uitest.cc b/chrome/browser/history/multipart_uitest.cc index aabf593..42339bf 100644 --- a/chrome/browser/history/multipart_uitest.cc +++ b/chrome/browser/history/multipart_uitest.cc @@ -30,16 +30,15 @@ class MultipartResponseUITest : public UITest { TEST_F(MultipartResponseUITest, MAYBE_SingleVisit) { // Make sure that visiting a multipart/x-mixed-replace site only // creates one entry in the visits table. - const wchar_t kDocRoot[] = L"chrome/test/data"; - scoped_refptr<net::HTTPTestServer> server = - net::HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + net::TestServer test_server(net::TestServer::TYPE_HTTP, + FilePath(FILE_PATH_LITERAL("chrome/test/data"))); + ASSERT_TRUE(test_server.Start()); scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); ASSERT_TRUE(tab_proxy.get()); - NavigateToURL(server->TestServerPage("multipart")); + NavigateToURL(test_server.GetURL("multipart")); std::wstring title; EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); EXPECT_EQ(L"page 9", title); diff --git a/chrome/browser/history/redirect_uitest.cc b/chrome/browser/history/redirect_uitest.cc index 6ea84ae..7e3ac11 100644 --- a/chrome/browser/history/redirect_uitest.cc +++ b/chrome/browser/history/redirect_uitest.cc @@ -20,18 +20,23 @@ namespace { -const wchar_t kDocRoot[] = L"chrome/test/data"; +class RedirectTest : public UITest { + public: + RedirectTest() + : test_server_(net::TestServer::TYPE_HTTP, + FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { + } -typedef UITest RedirectTest; + protected: + net::TestServer test_server_; +}; // Tests a single server redirect TEST_F(RedirectTest, Server) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); - GURL final_url = server->TestServerPage(std::string()); - GURL first_url = server->TestServerPage( + GURL final_url = test_server_.GetURL(std::string()); + GURL first_url = test_server_.GetURL( "server-redirect?" + final_url.spec()); NavigateToURL(first_url); @@ -48,12 +53,10 @@ TEST_F(RedirectTest, Server) { // Tests a single client redirect. TEST_F(RedirectTest, Client) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); - GURL final_url = server->TestServerPage(std::string()); - GURL first_url = server->TestServerPage( + GURL final_url = test_server_.GetURL(std::string()); + GURL first_url = test_server_.GetURL( "client-redirect?" + final_url.spec()); // The client redirect appears as two page visits in the browser. @@ -82,11 +85,9 @@ TEST_F(RedirectTest, Client) { } TEST_F(RedirectTest, ClientEmptyReferer) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); - GURL final_url = server->TestServerPage(std::string()); + GURL final_url = test_server_.GetURL(std::string()); FilePath test_file(test_data_directory_); test_file = test_file.AppendASCII("file_client_redirect.html"); GURL first_url = net::FilePathToFileURL(test_file); @@ -142,16 +143,14 @@ TEST_F(RedirectTest, ClientCancelled) { // Tests a client->server->server redirect TEST_F(RedirectTest, ClientServerServer) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); - GURL final_url = server->TestServerPage(std::string()); - GURL next_to_last = server->TestServerPage( + GURL final_url = test_server_.GetURL(std::string()); + GURL next_to_last = test_server_.GetURL( "server-redirect?" + final_url.spec()); - GURL second_url = server->TestServerPage( + GURL second_url = test_server_.GetURL( "server-redirect?" + next_to_last.spec()); - GURL first_url = server->TestServerPage( + GURL first_url = test_server_.GetURL( "client-redirect?" + second_url.spec()); std::vector<GURL> redirects; @@ -176,14 +175,12 @@ TEST_F(RedirectTest, ClientServerServer) { // Tests that the "#reference" gets preserved across server redirects. TEST_F(RedirectTest, ServerReference) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); const std::string ref("reference"); - GURL final_url = server->TestServerPage(std::string()); - GURL initial_url = server->TestServerPage( + GURL final_url = test_server_.GetURL(std::string()); + GURL initial_url = test_server_.GetURL( "server-redirect?" + final_url.spec() + "#" + ref); NavigateToURL(initial_url); @@ -196,14 +193,12 @@ TEST_F(RedirectTest, ServerReference) { // A) does not crash the browser or confuse the redirect chain, see bug 1080873 // B) does not take place. TEST_F(RedirectTest, NoHttpToFile) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); FilePath test_file(test_data_directory_); test_file = test_file.AppendASCII("http_to_file.html"); GURL file_url = net::FilePathToFileURL(test_file); - GURL initial_url = server->TestServerPage( + GURL initial_url = test_server_.GetURL( "client-redirect?" + file_url.spec()); NavigateToURL(initial_url); @@ -219,9 +214,7 @@ TEST_F(RedirectTest, NoHttpToFile) { // Ensures that non-user initiated location changes (within page) are // flagged as client redirects. See bug 1139823. TEST_F(RedirectTest, ClientFragments) { - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); FilePath test_file(test_data_directory_); test_file = test_file.AppendASCII("ref_redirect.html"); @@ -253,13 +246,11 @@ TEST_F(RedirectTest, // which causes it to start a provisional load, and while it is waiting // for the response (which means it hasn't committed the load for the client // redirect destination page yet), we issue a new navigation request. - scoped_refptr<net::HTTPTestServer> server( - net::HTTPTestServer::CreateServer(kDocRoot)); - ASSERT_TRUE(NULL != server.get()); + ASSERT_TRUE(test_server_.Start()); - GURL final_url = server->TestServerPage("files/title2.html"); - GURL slow = server->TestServerPage("slow?60"); - GURL first_url = server->TestServerPage( + GURL final_url = test_server_.GetURL("files/title2.html"); + GURL slow = test_server_.GetURL("slow?60"); + GURL first_url = test_server_.GetURL( "client-redirect?" + slow.spec()); std::vector<GURL> redirects; |