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

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

Issue 175006: Wait correctly for all navigations that will happen in ErrorPageTest. (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/url_request/url_request_unittest.h"
(...skipping 28 matching lines...) Expand all
39 39
40 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 40 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
41 } 41 }
42 42
43 TEST_F(ErrorPageTest, DNSError_GoBack1) { 43 TEST_F(ErrorPageTest, DNSError_GoBack1) {
44 // Test that a DNS error occuring in the main frame does not result in an 44 // Test that a DNS error occuring in the main frame does not result in an
45 // additional session history entry. 45 // additional session history entry.
46 GURL test_url(URLRequestFailedDnsJob::kTestUrl); 46 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
47 47
48 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 48 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
49 NavigateToURL(test_url); 49 // The first navigation should fail, and the second one should be the error
50 // page.
51 NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
50 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 52 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
51 53
52 GetActiveTab()->GoBack(); 54 GetActiveTab()->GoBack();
53 55
54 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); 56 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
55 } 57 }
56 58
57 TEST_F(ErrorPageTest, DNSError_GoBack2) { 59 TEST_F(ErrorPageTest, DNSError_GoBack2) {
58 // Test that a DNS error occuring in the main frame does not result in an 60 // Test that a DNS error occuring in the main frame does not result in an
59 // additional session history entry. 61 // additional session history entry.
60 GURL test_url(URLRequestFailedDnsJob::kTestUrl); 62 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
61 63
62 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 64 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
63 NavigateToURL(test_url); 65 // The first navigation should fail, and the second one should be the error
66 // page.
67 NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
64 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 68 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
65 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); 69 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
66 70
67 // The first navigation should fail, and the second one should be the error 71 // The first navigation should fail, and the second one should be the error
68 // page. 72 // page.
69 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); 73 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2);
70 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 74 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
71 GetActiveTab()->GoBack(); 75 GetActiveTab()->GoBack();
72 76
73 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); 77 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
74 } 78 }
75 79
76 TEST_F(ErrorPageTest, DNSError_GoBack2AndForward) { 80 TEST_F(ErrorPageTest, DNSError_GoBack2AndForward) {
77 // Test that a DNS error occuring in the main frame does not result in an 81 // Test that a DNS error occuring in the main frame does not result in an
78 // additional session history entry. 82 // additional session history entry.
79 83
80 GURL test_url(URLRequestFailedDnsJob::kTestUrl); 84 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
81 85
82 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 86 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
83 NavigateToURL(test_url); 87 // The first navigation should fail, and the second one should be the error
88 // page.
89 NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
84 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 90 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
85 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); 91 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
86 92
87 // The first navigation should fail, and the second one should be the error 93 // The first navigation should fail, and the second one should be the error
88 // page. 94 // page.
89 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); 95 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2);
90 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 96 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
91 GetActiveTab()->GoBack(); 97 GetActiveTab()->GoBack();
92 // The first navigation should fail, and the second one should be the error 98 // The first navigation should fail, and the second one should be the error
93 // page. 99 // page.
94 GetActiveTab()->GoForwardBlockUntilNavigationsComplete(2); 100 GetActiveTab()->GoForwardBlockUntilNavigationsComplete(2);
95 101
96 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 102 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
97 } 103 }
98 104
99 TEST_F(ErrorPageTest, DNSError_GoBack2Forward2) { 105 TEST_F(ErrorPageTest, DNSError_GoBack2Forward2) {
100 // Test that a DNS error occuring in the main frame does not result in an 106 // Test that a DNS error occuring in the main frame does not result in an
101 // additional session history entry. 107 // additional session history entry.
102 108
103 GURL test_url(URLRequestFailedDnsJob::kTestUrl); 109 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
104 110
105 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); 111 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
106 NavigateToURL(test_url); 112 // The first navigation should fail, and the second one should be the error
113 // page.
114 NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
107 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 115 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
108 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 116 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
109 117
110 // The first navigation should fail, and the second one should be the error 118 // The first navigation should fail, and the second one should be the error
111 // page. 119 // page.
112 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); 120 GetActiveTab()->GoBackBlockUntilNavigationsComplete(2);
113 EXPECT_TRUE(WaitForTitleContaining(test_url.host())); 121 EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
114 GetActiveTab()->GoBack(); 122 GetActiveTab()->GoBack();
115 // The first navigation should fail, and the second one should be the error 123 // The first navigation should fail, and the second one should be the error
116 // page. 124 // page.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // error page loads instead), then the title will remain as "FAIL". 166 // error page loads instead), then the title will remain as "FAIL".
159 scoped_refptr<HTTPTestServer> server = 167 scoped_refptr<HTTPTestServer> server =
160 HTTPTestServer::CreateServer(L"chrome/test/data", NULL); 168 HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
161 ASSERT_TRUE(NULL != server.get()); 169 ASSERT_TRUE(NULL != server.get());
162 GURL test_url = server->TestServerPage("files/iframe404.html"); 170 GURL test_url = server->TestServerPage("files/iframe404.html");
163 NavigateToURL(test_url); 171 NavigateToURL(test_url);
164 172
165 EXPECT_TRUE(WaitForTitleMatching(L"SUCCESS")); 173 EXPECT_TRUE(WaitForTitleMatching(L"SUCCESS"));
166 } 174 }
167 175
168 #if defined(OS_LINUX)
169 // TODO(phajdan.jr): This test is flaky on Linux, http://crbug.com/19361
170 #define Page404 DISABLED_Page404
171 #define Page404_GoBack DISABLED_Page404_GoBack
172 #endif
173
174 TEST_F(ErrorPageTest, Page404) { 176 TEST_F(ErrorPageTest, Page404) {
175 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 177 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
176 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html")); 178 // The first navigation should fail, and the second one should be the error
179 // page.
180 NavigateToURLBlockUntilNavigationsComplete(
181 URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2);
177 182
178 EXPECT_TRUE(WaitForTitleContaining("page404.html")); 183 EXPECT_TRUE(WaitForTitleContaining("page404.html"));
179 } 184 }
180 185
181 TEST_F(ErrorPageTest, Page404_GoBack) { 186 TEST_F(ErrorPageTest, Page404_GoBack) {
182 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); 187 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
183 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html")); 188 // The first navigation should fail, and the second one should be the error
189 // page.
190 NavigateToURLBlockUntilNavigationsComplete(
191 URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2);
184 EXPECT_TRUE(WaitForTitleContaining("page404.html")); 192 EXPECT_TRUE(WaitForTitleContaining("page404.html"));
185 193
186 GetActiveTab()->GoBack(); 194 GetActiveTab()->GoBack();
187 195
188 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); 196 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
189 } 197 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698