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

Side by Side Diff: content/browser/accessibility/dump_accessibility_browsertest_base.h

Issue 787813006: Pull out a base class from DumpAccessibilityTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_legacy_outerwidth
Patch Set: Created 6 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6 #include <vector>
7
8 #include "base/strings/string16.h"
9 #include "content/browser/accessibility/accessibility_tree_formatter.h"
10 #include "content/public/test/content_browser_test.h"
11
12 namespace content {
13
14 // Base class for an accessibility browsertest that takes an HTML file as
15 // input, loads it into a tab, dumps some accessibility data in text format,
16 // then compares that text to an expectation file in the same directory.
17 //
18 // The system was inspired by WebKit/Blink LayoutTests, but customized for
19 // testing accessibility in Chromium.
20 class DumpAccessibilityTestBase : public ContentBrowserTest {
21 public:
22 // Given a path to an HTML file relative to the test directory,
23 // loads the HTML, loads the accessibility tree, calls Dump(), then
24 // compares the output to the expected result and has the test succeed
25 // or fail based on the diff.
26 void RunTest(const base::FilePath::CharType* file_path);
27
28 protected:
29 //
30 // For subclasses to override:
31 //
32
33 // This is called by RunTest after the document has finished loading,
34 // including the load complete accessibility event. The subclass should
David Tseng 2014/12/17 01:03:32 Now that we test events, would we ever want to sta
dmazzoni 2014/12/17 07:04:51 Sure - not a super high priority for me right now
35 // dump whatever that specific test wants to dump, returning the result
36 // as a sequence of strings.
37 virtual std::vector<std::string> Dump() = 0;
38
39 // Add the default filters that are applied to all tests. Each subclass
40 // should override this.
David Tseng 2014/12/17 01:03:32 Since this method is pure virtual, this comment is
dmazzoni 2014/12/17 07:04:50 Done.
41 virtual void AddDefaultFilters(
42 std::vector<AccessibilityTreeFormatter::Filter>* filters) = 0;
43
44 // This gets called if the diff didn't match; the test can print
45 // additional useful info.
46 virtual void AdditionalErrorLogging() {}
David Tseng 2014/12/17 01:03:32 Name of this method should reflect the comment mor
dmazzoni 2014/12/17 07:04:51 Done.
47
48 //
49 // Helpers
50 //
51
52 // Dump the whole accessibility tree, without applying any filters,
53 // and return it as a string.
54 base::string16 DumpUnfilteredAccessibilityTreeAsString();
55
56 // Utility helper that does a comment-aware equality check.
57 // Returns array of lines from expected file which are different.
58 std::vector<int> DiffLines(const std::vector<std::string>& expected_lines,
59 const std::vector<std::string>& actual_lines);
60
61 // Parse the test html file and parse special directives, usually
62 // beginning with an '@' and inside an HTML comment, that control how the
63 // test is run and how the results are interpreted.
64 //
65 // When the accessibility tree is dumped as text, each attribute is
66 // run through filters before being appended to the string. An "allow"
67 // filter specifies attribute strings that should be dumped, and a "deny"
68 // filter specifies strings that should be suppressed. As an example,
69 // @MAC-ALLOW:AXSubrole=* means that the AXSubrole attribute should be
70 // printed, while @MAC-ALLOW:AXSubrole=AXList* means that any subrole
71 // beginning with the text "AXList" should be printed.
72 //
73 // The @WAIT-FOR:text directive allows the test to specify that the document
74 // may dynamically change after initial load, and the test is to wait
75 // until the given string (e.g., "text") appears in the resulting dump.
76 // A test can make some changes to the document, then append a magic string
77 // indicating that the test is done, and this framework will wait for that
78 // string to appear before comparing the results.
79 void ParseHtmlForExtraDirectives(
80 const std::string& test_html,
81 std::vector<AccessibilityTreeFormatter::Filter>* filters,
82 std::string* wait_for);
83
84 // The default filters plus the filters loaded from the test file.
85 std::vector<AccessibilityTreeFormatter::Filter> filters_;
86 };
87
88 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698