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 #ifndef CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ |
7 | 7 |
8 #include <set> | |
9 | |
10 #include "base/file_path.h" | 8 #include "base/file_path.h" |
11 #include "base/string16.h" | 9 #include "base/string16.h" |
12 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
13 #include "content/browser/accessibility/browser_accessibility.h" | 11 #include "content/browser/accessibility/browser_accessibility.h" |
14 | 12 |
15 // A utility class for retrieving platform specific accessibility information. | 13 // A utility class for retrieving platform specific accessibility information. |
16 // This is extended by a subclass for each platform where accessibility is | 14 // This is extended by a subclass for each platform where accessibility is |
17 // implemented. | 15 // implemented. |
18 class DumpAccessibilityTreeHelper { | 16 class DumpAccessibilityTreeHelper { |
19 public: | 17 public: |
20 DumpAccessibilityTreeHelper(); | |
21 virtual ~DumpAccessibilityTreeHelper(); | |
22 | |
23 // Dumps a BrowserAccessibility tree into a string. | 18 // Dumps a BrowserAccessibility tree into a string. |
24 void DumpAccessibilityTree(BrowserAccessibility* node, | 19 void DumpAccessibilityTree(BrowserAccessibility* node, |
25 string16* contents); | 20 string16* contents); |
26 | 21 |
27 // Set regular expression filters that apply to each component of every | |
28 // line before it's output. | |
29 void SetFilters(const std::set<string16>& allow_filters, | |
30 const std::set<string16>& deny_filters); | |
31 | |
32 // Suffix of the expectation file corresponding to html file. | 22 // Suffix of the expectation file corresponding to html file. |
33 // Example: | 23 // Example: |
34 // HTML test: test-file.html | 24 // HTML test: test-file.html |
35 // Expected: test-file-expected-mac.txt. | 25 // Expected: test-file-expected-mac.txt. |
36 // Auto-generated: test-file-actual-mac.txt | 26 // Auto-generated: test-file-actual-mac.txt |
37 const FilePath::StringType GetActualFileSuffix() const; | 27 const FilePath::StringType GetActualFileSuffix() const; |
38 const FilePath::StringType GetExpectedFileSuffix() const; | 28 const FilePath::StringType GetExpectedFileSuffix() const; |
39 | 29 |
40 // A platform-specific string that indicates a given line in a file | |
41 // is an allow or deny filter. Example: | |
42 // Mac values: | |
43 // GetAllowString() -> "@MAC-ALLOW:" | |
44 // GetDenyString() -> "@MAC-DENY:" | |
45 // Example html: | |
46 // <!-- | |
47 // @MAC-ALLOW:roleDescription* | |
48 // @MAC-DENY:subrole* | |
49 // --> | |
50 // <p>Text</p> | |
51 const std::string GetAllowString() const; | |
52 const std::string GetDenyString() const; | |
53 | |
54 protected: | 30 protected: |
55 void RecursiveDumpAccessibilityTree(BrowserAccessibility* node, | 31 void RecursiveDumpAccessibilityTree(BrowserAccessibility* node, |
56 string16* contents, | 32 string16* contents, |
57 int indent); | 33 int indent); |
58 | 34 |
59 // Returns a platform specific representation of a BrowserAccessibility. | 35 // Returns a platform specific representation of a BrowserAccessibility. |
60 // Should be zero or more complete lines, each with |prefix| prepended | 36 // Should be zero or more complete lines, each with |prefix| prepended |
61 // (to indent each line). | 37 // (to indent each line). |
62 string16 ToString(BrowserAccessibility* node, char* prefix); | 38 string16 ToString(BrowserAccessibility* node, char* prefix); |
63 | 39 |
64 void Initialize(); | 40 void Initialize(); |
65 | |
66 bool MatchesFilters(const string16& text, bool default_result); | |
67 void StartLine(); | |
68 void Add(bool include_by_default, const string16& attr); | |
69 string16 FinishLine(); | |
70 | |
71 std::set<string16> allow_filters_; | |
72 std::set<string16> deny_filters_; | |
73 string16 line_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(DumpAccessibilityTreeHelper); | |
76 }; | 41 }; |
77 | 42 |
78 #endif // CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ | 43 #endif // CONTENT_BROWSER_ACCESSIBILITY_DUMP_ACCESSIBILITY_TREE_HELPER_H_ |
OLD | NEW |