summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 00:51:38 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 00:51:38 +0000
commit10dd7531c0eace81434783ddb9b7c224dbe0e9f9 (patch)
tree2eee185378800586e8f2e71275ea4c3708ca2e5c /chrome/test
parent0407b5c4a9af9baf7f82caaf86b04299c2d5a9fe (diff)
downloadchromium_src-10dd7531c0eace81434783ddb9b7c224dbe0e9f9.zip
chromium_src-10dd7531c0eace81434783ddb9b7c224dbe0e9f9.tar.gz
chromium_src-10dd7531c0eace81434783ddb9b7c224dbe0e9f9.tar.bz2
Run appcache layout tests in chrome using the ui test harness.
BUG=39365 TEST=yes Review URL: http://codereview.chromium.org/2822007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/ui/ui_layout_test.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc
index 73556a9..6c5415f 100644
--- a/chrome/test/ui/ui_layout_test.cc
+++ b/chrome/test/ui/ui_layout_test.cc
@@ -156,6 +156,16 @@ void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir,
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 @@ void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name,
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_);