| OLD | NEW |
| 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 "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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
| 13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "content/public/common/content_paths.h" |
| 16 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 | 19 |
| 20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 static const char kPlatformName[] = "chromium-win"; | 21 static const char kPlatformName[] = "chromium-win"; |
| 22 #elif defined(OS_MACOSX) | 22 #elif defined(OS_MACOSX) |
| 23 static const char kPlatformName[] = "chromium-mac"; | 23 static const char kPlatformName[] = "chromium-mac"; |
| 24 #elif defined(OS_LINUX) | 24 #elif defined(OS_LINUX) |
| 25 static const char kPlatformName[] = "chromium-linux"; | 25 static const char kPlatformName[] = "chromium-linux"; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 // To work around this problem, we try to repeat the deletion several | 43 // To work around this problem, we try to repeat the deletion several |
| 44 // times. | 44 // times. |
| 45 EXPECT_TRUE(file_util::DieFileDie(temp_test_dir_, true)); | 45 EXPECT_TRUE(file_util::DieFileDie(temp_test_dir_, true)); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir, | 49 void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir, |
| 50 const FilePath& test_case_dir, | 50 const FilePath& test_case_dir, |
| 51 int port) { | 51 int port) { |
| 52 FilePath src_dir; | 52 FilePath src_dir; |
| 53 ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &src_dir)); | 53 ASSERT_TRUE(PathService::Get(content::DIR_LAYOUT_TESTS, &src_dir)); |
| 54 layout_test_dir_ = src_dir.Append(test_parent_dir); | 54 layout_test_dir_ = src_dir.Append(test_parent_dir); |
| 55 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); | 55 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); |
| 56 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_)); | 56 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_)) |
| 57 << " " << layout_test_dir_.value(); |
| 57 | 58 |
| 58 // Gets the file path to rebased expected result directory for the current | 59 // Gets the file path to rebased expected result directory for the current |
| 59 // platform. | 60 // platform. |
| 60 // $LayoutTestRoot/platform/chromium_***/... | 61 // $LayoutTestRoot/platform/chromium_***/... |
| 61 rebase_result_dir_ = src_dir.AppendASCII("platform"); | 62 rebase_result_dir_ = src_dir.AppendASCII("platform"); |
| 62 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName); | 63 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName); |
| 63 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir); | 64 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir); |
| 64 rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir); | 65 rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir); |
| 65 | 66 |
| 66 // Generic chromium expected results. Not OS-specific. For example, | 67 // Generic chromium expected results. Not OS-specific. For example, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 parent_resource_path = parent_resource_path.AppendASCII("resources"); | 117 parent_resource_path = parent_resource_path.AppendASCII("resources"); |
| 117 FilePath new_parent_resource_path(new_layout_test_dir_.DirName()); | 118 FilePath new_parent_resource_path(new_layout_test_dir_.DirName()); |
| 118 new_parent_resource_path = | 119 new_parent_resource_path = |
| 119 new_parent_resource_path.AppendASCII("resources"); | 120 new_parent_resource_path.AppendASCII("resources"); |
| 120 ASSERT_TRUE(file_util::CopyDirectory( | 121 ASSERT_TRUE(file_util::CopyDirectory( |
| 121 parent_resource_path, new_parent_resource_path, true)); | 122 parent_resource_path, new_parent_resource_path, true)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 // Reads the layout test controller simulation script. | 125 // Reads the layout test controller simulation script. |
| 125 FilePath path; | 126 FilePath path; |
| 126 PathService::Get(chrome::DIR_TEST_DATA, &path); | 127 PathService::Get(content::DIR_TEST_DATA, &path); |
| 127 path = path.AppendASCII("layout_tests"); | 128 path = path.AppendASCII("layout_tests"); |
| 128 path = path.AppendASCII("layout_test_controller.html"); | 129 path = path.AppendASCII("layout_test_controller.html"); |
| 129 layout_test_controller_.clear(); | 130 layout_test_controller_.clear(); |
| 130 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); | 131 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir, | 134 void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir, |
| 134 const FilePath& resource_name) { | 135 const FilePath& resource_name) { |
| 135 FilePath source; | 136 FilePath source; |
| 136 ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &source)); | 137 ASSERT_TRUE(PathService::Get(content::DIR_LAYOUT_TESTS, &source)); |
| 137 source = source.Append(parent_dir); | 138 source = source.Append(parent_dir); |
| 138 source = source.Append(resource_name); | 139 source = source.Append(resource_name); |
| 139 | 140 |
| 140 ASSERT_TRUE(file_util::PathExists(source)); | 141 ASSERT_TRUE(file_util::PathExists(source)) << " " << source.value(); |
| 141 | 142 |
| 142 FilePath dest_parent_dir = temp_test_dir_. | 143 FilePath dest_parent_dir = temp_test_dir_. |
| 143 AppendASCII("LayoutTests").Append(parent_dir); | 144 AppendASCII("LayoutTests").Append(parent_dir); |
| 144 ASSERT_TRUE(file_util::CreateDirectory(dest_parent_dir)); | 145 ASSERT_TRUE(file_util::CreateDirectory(dest_parent_dir)); |
| 145 FilePath dest = dest_parent_dir.Append(resource_name); | 146 FilePath dest = dest_parent_dir.Append(resource_name); |
| 146 | 147 |
| 147 if (file_util::DirectoryExists(source)) { | 148 if (file_util::DirectoryExists(source)) { |
| 148 ASSERT_TRUE(file_util::CopyDirectory(source, dest, true)); | 149 ASSERT_TRUE(file_util::CopyDirectory(source, dest, true)); |
| 149 } else { | 150 } else { |
| 150 ASSERT_TRUE(file_util::CopyFile(source, dest)); | 151 ASSERT_TRUE(file_util::CopyFile(source, dest)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 std::string* expected_result_value) { | 255 std::string* expected_result_value) { |
| 255 FilePath expected_result_path(result_dir_path); | 256 FilePath expected_result_path(result_dir_path); |
| 256 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); | 257 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); |
| 257 expected_result_path = expected_result_path.InsertBeforeExtension( | 258 expected_result_path = expected_result_path.InsertBeforeExtension( |
| 258 FILE_PATH_LITERAL("-expected")); | 259 FILE_PATH_LITERAL("-expected")); |
| 259 expected_result_path = | 260 expected_result_path = |
| 260 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); | 261 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); |
| 261 return file_util::ReadFileToString(expected_result_path, | 262 return file_util::ReadFileToString(expected_result_path, |
| 262 expected_result_value); | 263 expected_result_value); |
| 263 } | 264 } |
| OLD | NEW |