Index: content/browser/accessibility/dump_accessibility_tree_browsertest.cc |
diff --git a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc |
index b9156694efd52d2210160942623d3f3d8f34e715..df8c3c79bc97831b8a9f215700179af411bf0648 100644 |
--- a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc |
+++ b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include <string> |
+#include <vector> |
#include "base/logging.h" |
#include "base/path_service.h" |
@@ -32,7 +33,7 @@ using content::Referrer; |
namespace { |
// Required to enter html content into a url. |
static const std::string kUrlPreamble = "data:text/html,\n<!doctype html>"; |
-} // namespace |
+ static const char kCommentToken = '#'; |
// This test takes a snapshot of the platform BrowserAccessibility tree and |
// tests it against an expected baseline. |
@@ -46,6 +47,29 @@ namespace { |
// exactly match. |
class DumpAccessibilityTreeTest : public InProcessBrowserTest { |
public: |
+ // Utility helper that does a comment aware equality check. |
+ void ExpectEqualsWithComments(std::string& expected, std::string& actual) { |
+ std::vector<std::string> actual_lines, expected_lines; |
+ std::string line_ending = UTF16ToUTF8(helper_.GetLineEnding()); |
+ int actual_line_length = Tokenize(actual, line_ending, &actual_lines); |
dmazzoni
2012/03/09 19:55:37
How about line_count instead of line_length? line_
David Tseng
2012/03/12 18:51:58
substituted with *lines_count.
On 2012/03/09 19:
|
+ int expected_line_length = Tokenize(expected, line_ending, &expected_lines); |
+ int i = actual_line_length - 1, j = expected_line_length - 1; |
+ while (i >= 0 && j >= 0) { |
+ if (expected_lines[j].size() > 0 && |
+ expected_lines[j][0] == kCommentToken) { |
+ --j; |
+ continue; |
+ } |
+ |
+ EXPECT_EQ(actual_lines[i], expected_lines[j]); |
dmazzoni
2012/03/09 19:55:37
This could spew a whole bunch of errors if there's
David Tseng
2012/03/12 18:51:58
Returns result of comparison now.
On 2012/03/09 19
|
+ --i; |
+ --j; |
+ } |
+ |
+ // Actual file has been fully checked. |
+ EXPECT_LT(i, 0); |
+ } |
+ |
DumpAccessibilityTreeHelper helper_; |
}; |
@@ -107,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, |
host_view->GetBrowserAccessibilityManager()->GetRoot(), |
&actual_contents); |
std::string actual_contents8 = UTF16ToUTF8(actual_contents); |
- EXPECT_EQ(expected_contents, actual_contents8); |
+ ExpectEqualsWithComments(expected_contents, actual_contents8); |
if (!file_util::PathExists(expected_file)) { |
FilePath actual_file = |
@@ -123,3 +147,5 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, |
} |
} while (!(html_file = file_enumerator.Next()).empty()); |
} |
+ |
+} // namespace |
dmazzoni
2012/03/09 19:55:37
I think tests aren't supposed to be in an anonymou
David Tseng
2012/03/12 18:51:58
gtest_filter works fine for me with the tests wrap
|