OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/accessibility/dump_accessibility_browsertest_base.h" | 5 #include "content/browser/accessibility/dump_accessibility_browsertest_base.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 std::vector<std::string> actual_lines = Dump(); | 195 std::vector<std::string> actual_lines = Dump(); |
196 | 196 |
197 // Perform a diff (or write the initial baseline). | 197 // Perform a diff (or write the initial baseline). |
198 std::vector<std::string> expected_lines = base::SplitString( | 198 std::vector<std::string> expected_lines = base::SplitString( |
199 expected_contents, "\n", base::KEEP_WHITESPACE, | 199 expected_contents, "\n", base::KEEP_WHITESPACE, |
200 base::SPLIT_WANT_NONEMPTY); | 200 base::SPLIT_WANT_NONEMPTY); |
201 // Marking the end of the file with a line of text ensures that | 201 // Marking the end of the file with a line of text ensures that |
202 // file length differences are found. | 202 // file length differences are found. |
203 expected_lines.push_back(kMarkEndOfFile); | 203 expected_lines.push_back(kMarkEndOfFile); |
204 actual_lines.push_back(kMarkEndOfFile); | 204 actual_lines.push_back(kMarkEndOfFile); |
205 std::string actual_contents = JoinString(actual_lines, "\n"); | 205 std::string actual_contents = base::JoinString(actual_lines, "\n"); |
206 | 206 |
207 std::vector<int> diff_lines = DiffLines(expected_lines, actual_lines); | 207 std::vector<int> diff_lines = DiffLines(expected_lines, actual_lines); |
208 bool is_different = diff_lines.size() > 0; | 208 bool is_different = diff_lines.size() > 0; |
209 EXPECT_FALSE(is_different); | 209 EXPECT_FALSE(is_different); |
210 if (is_different) { | 210 if (is_different) { |
211 OnDiffFailed(); | 211 OnDiffFailed(); |
212 | 212 |
213 // Mark the expected lines which did not match actual output with a *. | 213 // Mark the expected lines which did not match actual output with a *. |
214 printf("* Line Expected\n"); | 214 printf("* Line Expected\n"); |
215 printf("- ---- --------\n"); | 215 printf("- ---- --------\n"); |
(...skipping 22 matching lines...) Expand all Loading... |
238 EXPECT_TRUE(base::WriteFile( | 238 EXPECT_TRUE(base::WriteFile( |
239 actual_file, actual_contents.c_str(), actual_contents.size())); | 239 actual_file, actual_contents.c_str(), actual_contents.size())); |
240 | 240 |
241 ADD_FAILURE() << "No expectation found. Create it by doing:\n" | 241 ADD_FAILURE() << "No expectation found. Create it by doing:\n" |
242 << "mv " << actual_file.LossyDisplayName() << " " | 242 << "mv " << actual_file.LossyDisplayName() << " " |
243 << expected_file.LossyDisplayName(); | 243 << expected_file.LossyDisplayName(); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 } // namespace content | 247 } // namespace content |
OLD | NEW |