OLD | NEW |
---|---|
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" |
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 < 100; ++i) { | 15 for (int i = 0; i < 100; ++i) { |
16 if (GetActiveTabTitle() == title) | 16 if (GetActiveTabTitle() == title) |
17 return true; | 17 return true; |
18 PlatformThread::Sleep(sleep_timeout_ms() / 10); | 18 PlatformThread::Sleep(sleep_timeout_ms() / 10); |
19 } | 19 } |
20 | |
21 // Print more info when things go wrong. | |
22 EXPECT_EQ(title, GetActiveTabTitle()); | |
M-A Ruel
2009/09/10 17:48:42
I'd remove 3 lines out of 4. I'll let you guess wh
| |
23 | |
20 return false; | 24 return false; |
21 } | 25 } |
22 bool WaitForTitleContaining(const std::string& title_substring) { | 26 bool WaitForTitleContaining(const std::string& title_substring) { |
23 for (int i = 0; i < 100; ++i) { | 27 for (int i = 0; i < 100; ++i) { |
24 std::wstring title = GetActiveTabTitle(); | 28 std::wstring title = GetActiveTabTitle(); |
25 if (title.find(UTF8ToWide(title_substring)) != std::wstring::npos) | 29 if (title.find(UTF8ToWide(title_substring)) != std::wstring::npos) |
26 return true; | 30 return true; |
27 PlatformThread::Sleep(sleep_timeout_ms() / 10); | 31 PlatformThread::Sleep(sleep_timeout_ms() / 10); |
28 } | 32 } |
33 | |
34 // Print more info when things go wrong. | |
35 LOG(ERROR) << "Could not find " << title_substring << " in " | |
M-A Ruel
2009/09/10 17:48:42
Here too.
| |
36 << GetActiveTabTitle(); | |
37 | |
29 return false; | 38 return false; |
30 } | 39 } |
31 }; | 40 }; |
32 | 41 |
33 TEST_F(ErrorPageTest, DNSError_Basic) { | 42 TEST_F(ErrorPageTest, DNSError_Basic) { |
34 GURL test_url(URLRequestFailedDnsJob::kTestUrl); | 43 GURL test_url(URLRequestFailedDnsJob::kTestUrl); |
35 | 44 |
36 // The first navigation should fail, and the second one should be the error | 45 // The first navigation should fail, and the second one should be the error |
37 // page. | 46 // page. |
38 NavigateToURLBlockUntilNavigationsComplete(test_url, 2); | 47 NavigateToURLBlockUntilNavigationsComplete(test_url, 2); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // The first navigation should fail, and the second one should be the error | 197 // The first navigation should fail, and the second one should be the error |
189 // page. | 198 // page. |
190 NavigateToURLBlockUntilNavigationsComplete( | 199 NavigateToURLBlockUntilNavigationsComplete( |
191 URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2); | 200 URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2); |
192 EXPECT_TRUE(WaitForTitleContaining("page404.html")); | 201 EXPECT_TRUE(WaitForTitleContaining("page404.html")); |
193 | 202 |
194 GetActiveTab()->GoBack(); | 203 GetActiveTab()->GoBack(); |
195 | 204 |
196 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); | 205 EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); |
197 } | 206 } |
OLD | NEW |