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

Side by Side Diff: content/browser/accessibility/dump_accessibility_tree_helper_win.cc

Issue 10837065: Revert 149510 - Allow filters in accessibility tests to specify which attributes to check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 #include <oleacc.h> 7 #include <oleacc.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "content/browser/accessibility/browser_accessibility_win.h" 14 #include "content/browser/accessibility/browser_accessibility_win.h"
15 #include "content/common/accessibility_node_data.h"
16 #include "content/public/test/accessibility_test_utils_win.h" 15 #include "content/public/test/accessibility_test_utils_win.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/iaccessible2/ia2_api_all.h" 17 #include "third_party/iaccessible2/ia2_api_all.h"
19 #include "ui/base/win/atl_module.h"
20 18
21 19
22 void DumpAccessibilityTreeHelper::Initialize() {
23 ui::win::CreateATLModuleIfNeeded();
24 }
25
26 string16 DumpAccessibilityTreeHelper::ToString( 20 string16 DumpAccessibilityTreeHelper::ToString(
27 BrowserAccessibility* node, char* prefix) { 21 BrowserAccessibility* node, char* prefix) {
28 BrowserAccessibilityWin* acc_obj = node->ToBrowserAccessibilityWin(); 22 BrowserAccessibilityWin* acc_obj = node->ToBrowserAccessibilityWin();
29 23
30 // Get the computed name. 24 // Get state string.
31 VARIANT variant_self; 25 VARIANT variant_self;
32 variant_self.vt = VT_I4; 26 variant_self.vt = VT_I4;
33 variant_self.lVal = CHILDID_SELF; 27 variant_self.lVal = CHILDID_SELF;
34 CComBSTR msaa_name_variant; 28 VARIANT msaa_state_variant;
35 HRESULT hresult = acc_obj->get_accName(variant_self, &msaa_name_variant); 29 HRESULT hresult = acc_obj->get_accState(variant_self, &msaa_state_variant);
36 string16 name; 30 EXPECT_EQ(S_OK, hresult);
37 if (S_OK == hresult) 31 EXPECT_EQ(VT_I4, msaa_state_variant.vt);
38 name = msaa_name_variant.m_str; 32 string16 state_str = IAccessibleStateToString(msaa_state_variant.lVal);
33 string16 state2_str = IAccessible2StateToString(acc_obj->ia2_state());
34 if (!state2_str.empty()) {
35 if (!state_str.empty())
36 state_str += L",";
37 state_str += state2_str;
38 }
39 39
40 // Get state strings. 40 // Get role string.
41 std::vector<string16> state_strings; 41 string16 role_str = IAccessible2RoleToString(acc_obj->ia2_role());
42 IAccessibleStateToStringVector(acc_obj->ia_state(), &state_strings);
43 IAccessible2StateToStringVector(acc_obj->ia2_state(), &state_strings);
44 42
45 // Get the description and attributes. 43 return UTF8ToUTF16(prefix) +
46 string16 description; 44 role_str +
47 acc_obj->GetStringAttribute(content::AccessibilityNodeData::ATTR_DESCRIPTION, 45 L" name='" + acc_obj->name() +
48 &description); 46 L"' state=" + state_str + L"\n";
49 const std::vector<string16>& ia2_attributes = acc_obj->ia2_attributes();
50
51 // Build the line.
52 StartLine();
53 Add(true, IAccessible2RoleToString(acc_obj->ia2_role()));
54 Add(true, L"name='" + name + L"'");
55 for (std::vector<string16>::const_iterator it = state_strings.begin();
56 it != state_strings.end();
57 ++it) {
58 Add(false, *it);
59 }
60 for (std::vector<string16>::const_iterator it = ia2_attributes.begin();
61 it != ia2_attributes.end();
62 ++it) {
63 Add(false, *it);
64 }
65 Add(false, L"role_name='" + acc_obj->role_name() + L"'");
66 Add(false, L"value='" + acc_obj->value() + L"'");
67 Add(false, L"description='" + description + L"'");
68 return UTF8ToUTF16(prefix) + FinishLine() + ASCIIToUTF16("\n");
69 } 47 }
70 48
71 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix() 49 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix()
72 const { 50 const {
73 return FILE_PATH_LITERAL("-actual-win.txt"); 51 return FILE_PATH_LITERAL("-actual-win.txt");
74 } 52 }
75 53
76 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix() 54 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix()
77 const { 55 const {
78 return FILE_PATH_LITERAL("-expected-win.txt"); 56 return FILE_PATH_LITERAL("-expected-win.txt");
79 } 57 }
80
81
82 const std::string DumpAccessibilityTreeHelper::GetAllowString() const {
83 return "@WIN-ALLOW:";
84 }
85
86 const std::string DumpAccessibilityTreeHelper::GetDenyString() const {
87 return "@WIN-DENY:";
88 }
OLDNEW
« no previous file with comments | « content/browser/accessibility/dump_accessibility_tree_helper_mac.mm ('k') | content/common/accessibility_node_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698