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

Side by Side Diff: chrome/test/ui/ui_layout_test.cc

Issue 8641002: Add chrome::DIR_LAYOUT_TESTS to PathService::Get (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Define chrome::DIR_LAYOUT_TESTS Created 9 years, 1 month 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 | « chrome/common/chrome_paths.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) 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/string_util.h" 10 #include "base/string_util.h"
(...skipping 27 matching lines...) Expand all
38 UILayoutTest::~UILayoutTest() { 38 UILayoutTest::~UILayoutTest() {
39 if (!temp_test_dir_.empty()) { 39 if (!temp_test_dir_.empty()) {
40 // The deletion might fail because HTTP server process might not been 40 // The deletion might fail because HTTP server process might not been
41 // completely shut down yet and is still holding certain handle to it. 41 // completely shut down yet and is still holding certain handle to it.
42 // To work around this problem, we try to repeat the deletion several 42 // To work around this problem, we try to repeat the deletion several
43 // times. 43 // times.
44 EXPECT_TRUE(file_util::DieFileDie(temp_test_dir_, true)); 44 EXPECT_TRUE(file_util::DieFileDie(temp_test_dir_, true));
45 } 45 }
46 } 46 }
47 47
48 // Gets layout tests root. For the current git workflow, this is
49 // third_party/WebKit/LayoutTests
50 // On svn workflow (including build machines) and older git workflow, this is
51 // chrome/test/data/layout_tests/LayoutTests
52 // This function probes for the first and then fallbacks to the second.
53 static FilePath GetLayoutTestRoot() {
54 FilePath src_root;
55 PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
56
57 FilePath webkit_layout_tests = src_root;
58 webkit_layout_tests = webkit_layout_tests.AppendASCII("third_party");
59 webkit_layout_tests = webkit_layout_tests.AppendASCII("WebKit");
60 webkit_layout_tests = webkit_layout_tests.AppendASCII("LayoutTests");
61 if (file_util::DirectoryExists(webkit_layout_tests))
62 return webkit_layout_tests;
63
64 FilePath chrome_layout_tests = src_root;
65 chrome_layout_tests = chrome_layout_tests.AppendASCII("chrome");
66 chrome_layout_tests = chrome_layout_tests.AppendASCII("test");
67 chrome_layout_tests = chrome_layout_tests.AppendASCII("data");
68 chrome_layout_tests = chrome_layout_tests.AppendASCII("layout_tests");
69 chrome_layout_tests = chrome_layout_tests.AppendASCII("LayoutTests");
70 return chrome_layout_tests;
71 }
72
73 void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir, 48 void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
74 const FilePath& test_case_dir, 49 const FilePath& test_case_dir,
75 int port) { 50 int port) {
76 FilePath src_dir = GetLayoutTestRoot(); 51 FilePath src_dir;
52 ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &src_dir));
77 layout_test_dir_ = src_dir.Append(test_parent_dir); 53 layout_test_dir_ = src_dir.Append(test_parent_dir);
78 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); 54 layout_test_dir_ = layout_test_dir_.Append(test_case_dir);
79 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_)); 55 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_));
80 56
81 // Gets the file path to rebased expected result directory for the current 57 // Gets the file path to rebased expected result directory for the current
82 // platform. 58 // platform.
83 // $LayoutTestRoot/platform/chromium_***/... 59 // $LayoutTestRoot/platform/chromium_***/...
84 rebase_result_dir_ = src_dir.AppendASCII("platform"); 60 rebase_result_dir_ = src_dir.AppendASCII("platform");
85 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName); 61 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName);
86 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir); 62 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 FilePath path; 124 FilePath path;
149 PathService::Get(chrome::DIR_TEST_DATA, &path); 125 PathService::Get(chrome::DIR_TEST_DATA, &path);
150 path = path.AppendASCII("layout_tests"); 126 path = path.AppendASCII("layout_tests");
151 path = path.AppendASCII("layout_test_controller.html"); 127 path = path.AppendASCII("layout_test_controller.html");
152 layout_test_controller_.clear(); 128 layout_test_controller_.clear();
153 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_)); 129 ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_));
154 } 130 }
155 131
156 void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir, 132 void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir,
157 const FilePath& resource_name) { 133 const FilePath& resource_name) {
158 FilePath source = GetLayoutTestRoot(); 134 FilePath source;
135 ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &source));
159 source = source.Append(parent_dir); 136 source = source.Append(parent_dir);
160 source = source.Append(resource_name); 137 source = source.Append(resource_name);
161 138
162 ASSERT_TRUE(file_util::PathExists(source)); 139 ASSERT_TRUE(file_util::PathExists(source));
163 140
164 FilePath dest_parent_dir = temp_test_dir_. 141 FilePath dest_parent_dir = temp_test_dir_.
165 AppendASCII("LayoutTests").Append(parent_dir); 142 AppendASCII("LayoutTests").Append(parent_dir);
166 ASSERT_TRUE(file_util::CreateDirectory(dest_parent_dir)); 143 ASSERT_TRUE(file_util::CreateDirectory(dest_parent_dir));
167 FilePath dest = dest_parent_dir.Append(resource_name); 144 FilePath dest = dest_parent_dir.Append(resource_name);
168 145
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 std::string* expected_result_value) { 253 std::string* expected_result_value) {
277 FilePath expected_result_path(result_dir_path); 254 FilePath expected_result_path(result_dir_path);
278 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); 255 expected_result_path = expected_result_path.AppendASCII(test_case_file_name);
279 expected_result_path = expected_result_path.InsertBeforeExtension( 256 expected_result_path = expected_result_path.InsertBeforeExtension(
280 FILE_PATH_LITERAL("-expected")); 257 FILE_PATH_LITERAL("-expected"));
281 expected_result_path = 258 expected_result_path =
282 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); 259 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt"));
283 return file_util::ReadFileToString(expected_result_path, 260 return file_util::ReadFileToString(expected_result_path,
284 expected_result_value); 261 expected_result_value);
285 } 262 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698