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

Side by Side Diff: content/browser/accessibility/dump_accessibility_tree_helper_mac.mm

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: Fix repetitive code, re-enable webkit strings. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/browser/accessibility/dump_accessibility_tree_helper.h" 5 #include "content/browser/accessibility/dump_accessibility_tree_helper.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/browser/accessibility/browser_accessibility_cocoa.h" 11 #include "content/browser/accessibility/browser_accessibility_cocoa.h"
12 #include "content/browser/accessibility/browser_accessibility_mac.h" 12 #include "content/browser/accessibility/browser_accessibility_mac.h"
13 13
14 namespace {
15 string16 Format(BrowserAccessibility* node,
16 const char *prefix,
17 SEL selector,
18 const char *suffix) {
19 BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa();
20 NSString* format_str =
21 [NSString stringWithFormat:@"%s%%@%s", prefix, suffix];
22 NSString* tmp = [NSString stringWithFormat:format_str,
23 [cocoa_node performSelector:selector]];
24 return UTF8ToUTF16([tmp cStringUsingEncoding:NSUTF8StringEncoding]);
25 }
26 }
27
14 void DumpAccessibilityTreeHelper::Initialize() {} 28 void DumpAccessibilityTreeHelper::Initialize() {}
15 29
16 string16 DumpAccessibilityTreeHelper::ToString(BrowserAccessibility* node, 30 string16 DumpAccessibilityTreeHelper::ToString(BrowserAccessibility* node,
17 char* prefix) { 31 char* prefix) {
18 BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa(); 32 StartLine();
19 NSString* dump = 33 Add(true, Format(node, "", @selector(role), ""));
20 [NSString stringWithFormat:@"%s%@ " 34 Add(true, Format(node, "subrole=", @selector(subrole), ""));
21 "subrole=%@ " 35 Add(false, Format(node, "roleDescription='",
22 "roleDescription='%@' " 36 @selector(roleDescription),
23 "title='%@' " 37 "'"));
24 "value='%@'\n", 38 Add(true, Format(node, "title='", @selector(title), "'"));
25 prefix, 39 Add(true, Format(node, "value='", @selector(value), "'"));
26 [cocoa_node role], 40 Add(false, Format(node, "description='", @selector(description), "'"));
27 [cocoa_node subrole], 41 Add(false, Format(node, "help='", @selector(help), "'"));
28 [cocoa_node roleDescription], 42 return ASCIIToUTF16(prefix) + FinishLine() + ASCIIToUTF16("\n");
29 [cocoa_node title],
30 [cocoa_node value]];
31 std::string tempVal = [dump cStringUsingEncoding:NSUTF8StringEncoding];
32
33 return UTF8ToUTF16(tempVal);
34 } 43 }
35 44
36 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix() 45 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix()
37 const { 46 const {
38 return FILE_PATH_LITERAL("-actual-mac.txt"); 47 return FILE_PATH_LITERAL("-actual-mac.txt");
39 } 48 }
40 49
41 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix() 50 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix()
42 const { 51 const {
43 return FILE_PATH_LITERAL("-expected-mac.txt"); 52 return FILE_PATH_LITERAL("-expected-mac.txt");
44 } 53 }
54
55 const std::string DumpAccessibilityTreeHelper::GetAllowString() const {
56 return "@MAC-ALLOW:";
57 }
58
59 const std::string DumpAccessibilityTreeHelper::GetDenyString() const {
60 return "@MAC-DENY:";
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698