| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/test/layout_browsertest.h" | 5 #include "content/test/layout_browsertest.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/layout_test_http_server.h" | 18 #include "chrome/test/base/layout_test_http_server.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
| 21 #include "content/public/common/content_paths.h" | 21 #include "content/public/common/content_paths.h" |
| 22 #include "content/public/test/browser_test_utils.h" |
| 22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 | 24 |
| 24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 25 static const char kPlatformName[] = "chromium-win"; | 26 static const char kPlatformName[] = "chromium-win"; |
| 26 #elif defined(OS_MACOSX) | 27 #elif defined(OS_MACOSX) |
| 27 static const char kPlatformName[] = "chromium-mac"; | 28 static const char kPlatformName[] = "chromium-mac"; |
| 28 #elif defined(OS_LINUX) | 29 #elif defined(OS_LINUX) |
| 29 static const char kPlatformName[] = "chromium-linux"; | 30 static const char kPlatformName[] = "chromium-linux"; |
| 30 #elif defined(OS_OPENBSD) | 31 #elif defined(OS_OPENBSD) |
| 31 static const char kPlatformName[] = "chromium-openbsd"; | 32 static const char kPlatformName[] = "chromium-openbsd"; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 GURL url(StringPrintf( | 179 GURL url(StringPrintf( |
| 179 "http://127.0.0.1:%d/%s/%s", port_, test_case_dir_.MaybeAsASCII().c_str(), | 180 "http://127.0.0.1:%d/%s/%s", port_, test_case_dir_.MaybeAsASCII().c_str(), |
| 180 test_case_file_name.c_str())); | 181 test_case_file_name.c_str())); |
| 181 RunLayoutTestInternal(test_case_file_name, url); | 182 RunLayoutTestInternal(test_case_file_name, url); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void InProcessBrowserLayoutTest::RunLayoutTestInternal( | 185 void InProcessBrowserLayoutTest::RunLayoutTestInternal( |
| 185 const std::string& test_case_file_name, const GURL& url) { | 186 const std::string& test_case_file_name, const GURL& url) { |
| 186 LOG(INFO) << "Navigating to URL " << url << " and blocking."; | 187 LOG(INFO) << "Navigating to URL " << url << " and blocking."; |
| 187 const string16 expected_title = ASCIIToUTF16("done"); | 188 const string16 expected_title = ASCIIToUTF16("done"); |
| 188 ui_test_utils::TitleWatcher title_watcher( | 189 content::TitleWatcher title_watcher( |
| 189 chrome::GetActiveWebContents(browser()), expected_title); | 190 chrome::GetActiveWebContents(browser()), expected_title); |
| 190 ui_test_utils::NavigateToURL(browser(), url); | 191 ui_test_utils::NavigateToURL(browser(), url); |
| 191 LOG(INFO) << "Navigation completed, now waiting for title."; | 192 LOG(INFO) << "Navigation completed, now waiting for title."; |
| 192 string16 final_title = title_watcher.WaitAndGetTitle(); | 193 string16 final_title = title_watcher.WaitAndGetTitle(); |
| 193 EXPECT_EQ(expected_title, final_title); | 194 EXPECT_EQ(expected_title, final_title); |
| 194 | 195 |
| 195 std::string actual_text; | 196 std::string actual_text; |
| 196 ScrapeResultFromBrowser(browser(), &actual_text); | 197 ScrapeResultFromBrowser(browser(), &actual_text); |
| 197 ReplaceSubstringsAfterOffset(&actual_text, 0, "\r", ""); | 198 ReplaceSubstringsAfterOffset(&actual_text, 0, "\r", ""); |
| 198 TrimString(actual_text, "\n", &actual_text); | 199 TrimString(actual_text, "\n", &actual_text); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html)); | 253 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html)); |
| 253 | 254 |
| 254 size_t insertion_position = FindInsertPosition(test_html); | 255 size_t insertion_position = FindInsertPosition(test_html); |
| 255 test_html.insert(insertion_position, preamble); | 256 test_html.insert(insertion_position, preamble); |
| 256 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_); | 257 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_); |
| 257 *test_path = test_path->AppendASCII(test_case_file_name); | 258 *test_path = test_path->AppendASCII(test_case_file_name); |
| 258 ASSERT_TRUE(file_util::WriteFile(*test_path, | 259 ASSERT_TRUE(file_util::WriteFile(*test_path, |
| 259 &test_html.at(0), | 260 &test_html.at(0), |
| 260 static_cast<int>(test_html.size()))); | 261 static_cast<int>(test_html.size()))); |
| 261 } | 262 } |
| OLD | NEW |