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

Side by Side Diff: chrome/browser/errorpage_uitest.cc

Issue 3034038: GTTF: Move more test server code from net/url_request/url_request_unittest.h (Closed)
Patch Set: hopefully final Created 10 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/string_util.h" 5 #include "base/string_util.h"
6 #include "chrome/test/automation/tab_proxy.h" 6 #include "chrome/test/automation/tab_proxy.h"
7 #include "chrome/test/ui/ui_test.h" 7 #include "chrome/test/ui/ui_test.h"
8 #include "chrome/browser/net/url_request_failed_dns_job.h" 8 #include "chrome/browser/net/url_request_failed_dns_job.h"
9 #include "chrome/browser/net/url_request_mock_http_job.h" 9 #include "chrome/browser/net/url_request_mock_http_job.h"
10 #include "net/url_request/url_request_unittest.h" 10 #include "net/test/test_server.h"
11 11
12 class ErrorPageTest : public UITest { 12 class ErrorPageTest : public UITest {
13 protected: 13 protected:
14 bool WaitForTitleMatching(const std::wstring& title) { 14 bool WaitForTitleMatching(const std::wstring& title) {
15 for (int i = 0; i < 10; ++i) { 15 for (int i = 0; i < 10; ++i) {
16 if (GetActiveTabTitle() == title) 16 if (GetActiveTabTitle() == title)
17 return true; 17 return true;
18 PlatformThread::Sleep(sleep_timeout_ms()); 18 PlatformThread::Sleep(sleep_timeout_ms());
19 } 19 }
20 EXPECT_EQ(title, GetActiveTabTitle()); 20 EXPECT_EQ(title, GetActiveTabTitle());
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EXPECT_TRUE(GetActiveTab()->GoForward()); 161 EXPECT_TRUE(GetActiveTab()->GoForward());
162 162
163 EXPECT_TRUE(WaitForTitleMatching(L"Blah")); 163 EXPECT_TRUE(WaitForTitleMatching(L"Blah"));
164 } 164 }
165 165
166 TEST_F(ErrorPageTest, IFrame404) { 166 TEST_F(ErrorPageTest, IFrame404) {
167 // iframes that have 404 pages should not trigger an alternate error page. 167 // iframes that have 404 pages should not trigger an alternate error page.
168 // In this test, the iframe sets the title of the parent page to "SUCCESS" 168 // In this test, the iframe sets the title of the parent page to "SUCCESS"
169 // when the iframe loads. If the iframe fails to load (because an alternate 169 // when the iframe loads. If the iframe fails to load (because an alternate
170 // error page loads instead), then the title will remain as "FAIL". 170 // error page loads instead), then the title will remain as "FAIL".
171 scoped_refptr<HTTPTestServer> server = 171 scoped_refptr<net::HTTPTestServer> server =
172 HTTPTestServer::CreateServer(L"chrome/test/data"); 172 net::HTTPTestServer::CreateServer(L"chrome/test/data");
173 ASSERT_TRUE(NULL != server.get()); 173 ASSERT_TRUE(NULL != server.get());
174 GURL test_url = server->TestServerPage("files/iframe404.html"); 174 GURL test_url = server->TestServerPage("files/iframe404.html");
175 NavigateToURL(test_url); 175 NavigateToURL(test_url);
176 176
177 EXPECT_TRUE(WaitForTitleMatching(L"SUCCESS")); 177 EXPECT_TRUE(WaitForTitleMatching(L"SUCCESS"));
178 } 178 }
179 179
180 TEST_F(ErrorPageTest, Page404) { 180 TEST_F(ErrorPageTest, Page404) {
181 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( 181 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(
182 FilePath(FILE_PATH_LITERAL("title2.html")))); 182 FilePath(FILE_PATH_LITERAL("title2.html"))));
(...skipping 13 matching lines...) Expand all
196 // page. 196 // page.
197 NavigateToURLBlockUntilNavigationsComplete( 197 NavigateToURLBlockUntilNavigationsComplete(
198 URLRequestMockHTTPJob::GetMockUrl( 198 URLRequestMockHTTPJob::GetMockUrl(
199 FilePath(FILE_PATH_LITERAL("page404.html"))), 2); 199 FilePath(FILE_PATH_LITERAL("page404.html"))), 2);
200 EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); 200 EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
201 201
202 EXPECT_TRUE(GetActiveTab()->GoBack()); 202 EXPECT_TRUE(GetActiveTab()->GoBack());
203 203
204 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); 204 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
205 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | chrome/browser/extensions/extension_apitest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698