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

Unified Diff: content/browser/accessibility/dump_accessibility_tree_helper.cc

Issue 10662003: Allow filters in accessibility tests to specify which attributes to check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around missing webkit strings in content_browsertests for now Created 8 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/dump_accessibility_tree_helper.cc
diff --git a/content/browser/accessibility/dump_accessibility_tree_helper.cc b/content/browser/accessibility/dump_accessibility_tree_helper.cc
index 1d667c952676206fb0d73cbc0d62f8d131a3520a..cd540070c5eeaab20d71d511dfc047c6c23abd02 100644
--- a/content/browser/accessibility/dump_accessibility_tree_helper.cc
+++ b/content/browser/accessibility/dump_accessibility_tree_helper.cc
@@ -4,12 +4,21 @@
#include "content/browser/accessibility/dump_accessibility_tree_helper.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/string_util.h"
namespace {
const int kIndentSpaces = 4;
}
+DumpAccessibilityTreeHelper::DumpAccessibilityTreeHelper() {
+ Initialize();
+}
+
+DumpAccessibilityTreeHelper::~DumpAccessibilityTreeHelper() {
+}
+
void DumpAccessibilityTreeHelper::DumpAccessibilityTree(
BrowserAccessibility* node, string16* contents) {
RecursiveDumpAccessibilityTree(node, contents, 0);
@@ -28,3 +37,41 @@ void DumpAccessibilityTreeHelper::RecursiveDumpAccessibilityTree(
indent + kIndentSpaces);
}
}
+
+void DumpAccessibilityTreeHelper::SetFilters(
+ const std::set<string16>& allow_filters,
+ const std::set<string16>& deny_filters) {
+ allow_filters_ = allow_filters;
+ deny_filters_ = deny_filters;
+}
+
+bool DumpAccessibilityTreeHelper::MatchesFilters(
+ const string16& text, bool default_result) {
+ std::set<string16>::const_iterator iter = allow_filters_.begin();
+ for (iter = allow_filters_.begin(); iter != allow_filters_.end(); ++iter) {
+ if (MatchPattern(text, *iter))
+ return true;
+ }
+ for (iter = deny_filters_.begin(); iter != deny_filters_.end(); ++iter) {
+ if (MatchPattern(text, *iter))
+ return false;
+ }
+ return default_result;
+}
+
+void DumpAccessibilityTreeHelper::StartLine() {
+ line_.clear();
+}
+
+void DumpAccessibilityTreeHelper::Add(
+ bool include_by_default, const string16& attr) {
+ if (!MatchesFilters(attr, include_by_default))
+ return;
+ if (!line_.empty())
+ line_ += ASCIIToUTF16(" ");
+ line_ += attr;
+}
+
+string16 DumpAccessibilityTreeHelper::FinishLine() {
+ return line_;
+}

Powered by Google App Engine
This is Rietveld 408576698