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

Side by Side Diff: content/test/layout_browsertest.cc

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/test/browser_test_utils.cc ('k') | 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) 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"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); 53 expected_result_path = expected_result_path.AppendASCII(test_case_file_name);
54 expected_result_path = expected_result_path.InsertBeforeExtension( 54 expected_result_path = expected_result_path.InsertBeforeExtension(
55 FILE_PATH_LITERAL("-expected")); 55 FILE_PATH_LITERAL("-expected"));
56 expected_result_path = 56 expected_result_path =
57 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); 57 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt"));
58 return file_util::ReadFileToString( 58 return file_util::ReadFileToString(
59 expected_result_path, expected_result_value); 59 expected_result_path, expected_result_value);
60 } 60 }
61 61
62 void ScrapeResultFromBrowser(Browser* browser, std::string* actual_text) { 62 void ScrapeResultFromBrowser(Browser* browser, std::string* actual_text) {
63 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 63 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
64 chrome::GetActiveWebContents(browser)->GetRenderViewHost(), 64 chrome::GetActiveWebContents(browser)->GetRenderViewHost(),
65 L"", 65 L"",
66 L"window.domAutomationController.send(document.body.innerText);", 66 L"window.domAutomationController.send(document.body.innerText);",
67 actual_text)); 67 actual_text));
68 } 68 }
69 69
70 static const std::string preamble = 70 static const std::string preamble =
71 "\n<script>\n" 71 "\n<script>\n"
72 "function LayoutTestController() {\n" 72 "function LayoutTestController() {\n"
73 " this.wait_until_done_ = false;\n" 73 " this.wait_until_done_ = false;\n"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html)); 253 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html));
254 254
255 size_t insertion_position = FindInsertPosition(test_html); 255 size_t insertion_position = FindInsertPosition(test_html);
256 test_html.insert(insertion_position, preamble); 256 test_html.insert(insertion_position, preamble);
257 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_); 257 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_);
258 *test_path = test_path->AppendASCII(test_case_file_name); 258 *test_path = test_path->AppendASCII(test_case_file_name);
259 ASSERT_TRUE(file_util::WriteFile(*test_path, 259 ASSERT_TRUE(file_util::WriteFile(*test_path,
260 &test_html.at(0), 260 &test_html.at(0),
261 static_cast<int>(test_html.size()))); 261 static_cast<int>(test_html.size())));
262 } 262 }
OLDNEW
« no previous file with comments | « content/test/browser_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698