| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/automation/tab_proxy.h" | 10 #include "chrome/test/automation/tab_proxy.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Reads the layout test controller simulation script. | 137 // Reads the layout test controller simulation script. |
| 138 FilePath path; | 138 FilePath path; |
| 139 PathService::Get(chrome::DIR_TEST_DATA, &path); | 139 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 140 path = path.AppendASCII("layout_tests"); | 140 path = path.AppendASCII("layout_tests"); |
| 141 path = path.AppendASCII("layout_test_controller.html"); | 141 path = path.AppendASCII("layout_test_controller.html"); |
| 142 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); | 142 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir, |
| 146 const FilePath& resource_dir) { |
| 147 FilePath root_dir; |
| 148 PathService::Get(base::DIR_SOURCE_ROOT, &root_dir); |
| 149 |
| 150 FilePath src_dir = root_dir.AppendASCII("chrome"); |
| 151 src_dir = src_dir.AppendASCII("test"); |
| 152 src_dir = src_dir.AppendASCII("data"); |
| 153 src_dir = src_dir.AppendASCII("layout_tests"); |
| 154 src_dir = src_dir.Append(parent_dir); |
| 155 src_dir = src_dir.Append(resource_dir); |
| 156 ASSERT_TRUE(file_util::DirectoryExists(src_dir)); |
| 157 |
| 158 FilePath dest_parent_dir = temp_test_dir_.Append(parent_dir); |
| 159 ASSERT_TRUE(file_util::CreateDirectory(dest_parent_dir)); |
| 160 FilePath dest_dir = dest_parent_dir.Append(resource_dir); |
| 161 ASSERT_TRUE(file_util::CopyDirectory(src_dir, dest_dir, true)); |
| 162 } |
| 163 |
| 145 void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name, | 164 void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name, |
| 146 bool is_http_test) { | 165 bool is_http_test) { |
| 147 SCOPED_TRACE(test_case_file_name.c_str()); | 166 SCOPED_TRACE(test_case_file_name.c_str()); |
| 148 | 167 |
| 149 ASSERT_TRUE(!layout_test_controller_.empty()); | 168 ASSERT_TRUE(!layout_test_controller_.empty()); |
| 150 | 169 |
| 151 // Creates a new cookie name. We will have to use a new cookie because | 170 // Creates a new cookie name. We will have to use a new cookie because |
| 152 // this function could be called multiple times. | 171 // this function could be called multiple times. |
| 153 std::string status_cookie(kTestCompleteCookie); | 172 std::string status_cookie(kTestCompleteCookie); |
| 154 status_cookie += IntToString(test_count_); | 173 status_cookie += IntToString(test_count_); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 std::string* expected_result_value) { | 244 std::string* expected_result_value) { |
| 226 FilePath expected_result_path(result_dir_path); | 245 FilePath expected_result_path(result_dir_path); |
| 227 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); | 246 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); |
| 228 expected_result_path = expected_result_path.InsertBeforeExtension( | 247 expected_result_path = expected_result_path.InsertBeforeExtension( |
| 229 FILE_PATH_LITERAL("-expected")); | 248 FILE_PATH_LITERAL("-expected")); |
| 230 expected_result_path = | 249 expected_result_path = |
| 231 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); | 250 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); |
| 232 return file_util::ReadFileToString(expected_result_path, | 251 return file_util::ReadFileToString(expected_result_path, |
| 233 expected_result_value); | 252 expected_result_value); |
| 234 } | 253 } |
| OLD | NEW |