OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/ui/ui_layout_test.h" | 5 #include "chrome/test/ui/ui_layout_test.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/test/test_file_util.h" | 10 #include "base/test/test_file_util.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // Copies the parent resource subdirectory. This is needed in order to run | 119 // Copies the parent resource subdirectory. This is needed in order to run |
120 // http layout tests. | 120 // http layout tests. |
121 if (port == kHttpPort) { | 121 if (port == kHttpPort) { |
122 FilePath parent_resource_path(layout_test_dir_.DirName()); | 122 FilePath parent_resource_path(layout_test_dir_.DirName()); |
123 parent_resource_path = parent_resource_path.AppendASCII("resources"); | 123 parent_resource_path = parent_resource_path.AppendASCII("resources"); |
124 FilePath new_parent_resource_path(new_layout_test_dir_.DirName()); | 124 FilePath new_parent_resource_path(new_layout_test_dir_.DirName()); |
125 new_parent_resource_path = | 125 new_parent_resource_path = |
126 new_parent_resource_path.AppendASCII("resources"); | 126 new_parent_resource_path.AppendASCII("resources"); |
127 ASSERT_TRUE(file_util::CopyDirectory( | 127 ASSERT_TRUE(file_util::CopyDirectory( |
128 parent_resource_path, new_parent_resource_path, true)); | 128 parent_resource_path, new_parent_resource_path, true)); |
129 | |
130 // Copy the js test files to the same location they're copied to | |
131 // when running under DRT. | |
132 FilePath js_resources_dir = src_dir.AppendASCII("fast") | |
133 .AppendASCII("js") | |
134 .AppendASCII("resources"); | |
135 FilePath new_js_resources_dir = | |
136 new_layout_test_dir_.AppendASCII("js-test-resources"); | |
michaeln
2011/03/22 21:32:50
Geez... so the fast/js/resources are also used for
adamk
2011/03/22 21:41:00
<script src="/js-test-resources/js-test-pre.js">.
| |
137 ASSERT_TRUE(file_util::CopyDirectory(js_resources_dir, | |
138 new_js_resources_dir, | |
139 true)); | |
129 } | 140 } |
130 | 141 |
131 // Reads the layout test controller simulation script. | 142 // Reads the layout test controller simulation script. |
132 FilePath path; | 143 FilePath path; |
133 PathService::Get(chrome::DIR_TEST_DATA, &path); | 144 PathService::Get(chrome::DIR_TEST_DATA, &path); |
134 path = path.AppendASCII("layout_tests"); | 145 path = path.AppendASCII("layout_tests"); |
135 path = path.AppendASCII("layout_test_controller.html"); | 146 path = path.AppendASCII("layout_test_controller.html"); |
136 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); | 147 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); |
137 } | 148 } |
138 | 149 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 &test_html.at(0), | 216 &test_html.at(0), |
206 static_cast<int>(test_html.size()))); | 217 static_cast<int>(test_html.size()))); |
207 // We expect the test case dir to be ASCII. It might be empty, so we | 218 // We expect the test case dir to be ASCII. It might be empty, so we |
208 // can't test whether MaybeAsASCII succeeded, but the tests will fail | 219 // can't test whether MaybeAsASCII succeeded, but the tests will fail |
209 // loudly in that case anyway. | 220 // loudly in that case anyway. |
210 std::string url_path = test_case_dir_.MaybeAsASCII(); | 221 std::string url_path = test_case_dir_.MaybeAsASCII(); |
211 | 222 |
212 scoped_ptr<GURL> new_test_url; | 223 scoped_ptr<GURL> new_test_url; |
213 if (port != kNoHttpPort) | 224 if (port != kNoHttpPort) |
214 new_test_url.reset(new GURL( | 225 new_test_url.reset(new GURL( |
215 StringPrintf("http://localhost:%d/", port) + | 226 StringPrintf("http://127.0.0.1:%d/", port) + |
michaeln
2011/03/22 21:32:50
+1 on this change
adamk
2011/03/22 21:41:00
Yeah, this is something that brings us in line wit
| |
216 url_path + "/" + test_case_file_name)); | 227 url_path + "/" + test_case_file_name)); |
217 else | 228 else |
218 new_test_url.reset(new GURL(net::FilePathToFileURL(new_test_file_path))); | 229 new_test_url.reset(new GURL(net::FilePathToFileURL(new_test_file_path))); |
219 | 230 |
220 // Runs the new layout test. | 231 // Runs the new layout test. |
221 scoped_refptr<TabProxy> tab(GetActiveTab()); | 232 scoped_refptr<TabProxy> tab(GetActiveTab()); |
222 ASSERT_TRUE(tab.get()); | 233 ASSERT_TRUE(tab.get()); |
223 ASSERT_TRUE(tab->NavigateToURL(*new_test_url.get())); | 234 ASSERT_TRUE(tab->NavigateToURL(*new_test_url.get())); |
224 std::string escaped_value = | 235 std::string escaped_value = |
225 WaitUntilCookieNonEmpty(tab.get(), *new_test_url.get(), | 236 WaitUntilCookieNonEmpty(tab.get(), *new_test_url.get(), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 std::string* expected_result_value) { | 277 std::string* expected_result_value) { |
267 FilePath expected_result_path(result_dir_path); | 278 FilePath expected_result_path(result_dir_path); |
268 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); | 279 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); |
269 expected_result_path = expected_result_path.InsertBeforeExtension( | 280 expected_result_path = expected_result_path.InsertBeforeExtension( |
270 FILE_PATH_LITERAL("-expected")); | 281 FILE_PATH_LITERAL("-expected")); |
271 expected_result_path = | 282 expected_result_path = |
272 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); | 283 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); |
273 return file_util::ReadFileToString(expected_result_path, | 284 return file_util::ReadFileToString(expected_result_path, |
274 expected_result_value); | 285 expected_result_value); |
275 } | 286 } |
OLD | NEW |