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

Unified Diff: chrome/test/ui/ui_layout_test.cc

Issue 2879003: Run appcache layout tests in chrome using the ui test harness. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/layout_tests/layout_test_controller.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui/ui_layout_test.cc
===================================================================
--- chrome/test/ui/ui_layout_test.cc (revision 50901)
+++ chrome/test/ui/ui_layout_test.cc (working copy)
@@ -156,6 +156,16 @@
ASSERT_TRUE(file_util::CopyDirectory(src_dir, dest_dir, true));
}
+static size_t FindInsertPosition(const std::string& html) {
+ size_t tag_start = html.find("<html");
+ if (tag_start == std::string::npos)
+ return 0;
+ size_t tag_end = html.find(">", tag_start);
+ if (tag_end == std::string::npos)
+ return 0;
+ return tag_end + 1;
+}
+
void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name,
int port) {
SCOPED_TRACE(test_case_file_name.c_str());
@@ -175,9 +185,10 @@
ASSERT_TRUE(file_util::ReadFileToString(test_file_path, &test_html));
// Injects the layout test controller into the test HTML.
- test_html.insert(0, layout_test_controller_);
- ReplaceSubstringsAfterOffset(
- &test_html, 0, "%COOKIE%", status_cookie.c_str());
+ size_t insertion_position = FindInsertPosition(test_html);
+ test_html.insert(insertion_position, layout_test_controller_);
+ ReplaceFirstSubstringAfterOffset(
+ &test_html, insertion_position, "%COOKIE%", status_cookie.c_str());
// Creates the new layout test HTML file.
FilePath new_test_file_path(new_layout_test_dir_);
« no previous file with comments | « chrome/test/data/layout_tests/layout_test_controller.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698