Chromium Code Reviews

Side by Side Diff: chrome_frame/test/chrome_frame_ui_test_utils.cc

Issue 5507001: base: Remove stub scoped_variant_win.h file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/chrome_frame_ui_test_utils.h ('k') | chrome_frame/test/ie_event_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome_frame/test/chrome_frame_ui_test_utils.h" 5 #include "chrome_frame/test/chrome_frame_ui_test_utils.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 #include <stack> 10 #include <stack>
(...skipping 42 matching lines...)
53 IID_IAccessible, reinterpret_cast<void**>(accessible.Receive())); 53 IID_IAccessible, reinterpret_cast<void**>(accessible.Receive()));
54 if (accessible) 54 if (accessible)
55 return new AccObject(accessible); 55 return new AccObject(accessible);
56 return NULL; 56 return NULL;
57 } 57 }
58 58
59 // static 59 // static
60 AccObject* AccObject::CreateFromEvent(HWND hwnd, LONG object_id, 60 AccObject* AccObject::CreateFromEvent(HWND hwnd, LONG object_id,
61 LONG child_id) { 61 LONG child_id) {
62 ScopedComPtr<IAccessible> accessible; 62 ScopedComPtr<IAccessible> accessible;
63 ScopedVariant acc_child_id; 63 base::win::ScopedVariant acc_child_id;
64 ::AccessibleObjectFromEvent(hwnd, object_id, child_id, accessible.Receive(), 64 ::AccessibleObjectFromEvent(hwnd, object_id, child_id, accessible.Receive(),
65 acc_child_id.Receive()); 65 acc_child_id.Receive());
66 if (accessible && acc_child_id.type() == VT_I4) 66 if (accessible && acc_child_id.type() == VT_I4)
67 return new AccObject(accessible, V_I4(&acc_child_id)); 67 return new AccObject(accessible, V_I4(&acc_child_id));
68 return NULL; 68 return NULL;
69 } 69 }
70 70
71 // static 71 // static
72 AccObject* AccObject::CreateFromDispatch(IDispatch* dispatch) { 72 AccObject* AccObject::CreateFromDispatch(IDispatch* dispatch) {
73 if (dispatch) { 73 if (dispatch) {
74 ScopedComPtr<IAccessible> accessible; 74 ScopedComPtr<IAccessible> accessible;
75 accessible.QueryFrom(dispatch); 75 accessible.QueryFrom(dispatch);
76 if (accessible) 76 if (accessible)
77 return new AccObject(accessible); 77 return new AccObject(accessible);
78 } 78 }
79 return NULL; 79 return NULL;
80 } 80 }
81 81
82 // static 82 // static
83 AccObject* AccObject::CreateFromPoint(int x, int y) { 83 AccObject* AccObject::CreateFromPoint(int x, int y) {
84 ScopedComPtr<IAccessible> accessible; 84 ScopedComPtr<IAccessible> accessible;
85 ScopedVariant child_id; 85 base::win::ScopedVariant child_id;
86 POINT point = {x, y}; 86 POINT point = {x, y};
87 ::AccessibleObjectFromPoint(point, accessible.Receive(), child_id.Receive()); 87 ::AccessibleObjectFromPoint(point, accessible.Receive(), child_id.Receive());
88 if (accessible && child_id.type() == VT_I4) 88 if (accessible && child_id.type() == VT_I4)
89 return new AccObject(accessible, V_I4(&child_id)); 89 return new AccObject(accessible, V_I4(&child_id));
90 return NULL; 90 return NULL;
91 } 91 }
92 92
93 bool AccObject::DoDefaultAction() { 93 bool AccObject::DoDefaultAction() {
94 // Prevent clients from using this method to try to select menu items, which 94 // Prevent clients from using this method to try to select menu items, which
95 // does not work with a locked desktop. 95 // does not work with a locked desktop.
(...skipping 16 matching lines...)
112 return PostMouseButtonMessages(WM_RBUTTONDOWN, WM_RBUTTONUP); 112 return PostMouseButtonMessages(WM_RBUTTONDOWN, WM_RBUTTONUP);
113 } 113 }
114 114
115 bool AccObject::Focus() { 115 bool AccObject::Focus() {
116 EXPECT_HRESULT_SUCCEEDED( 116 EXPECT_HRESULT_SUCCEEDED(
117 accessible_->accSelect(SELFLAG_TAKEFOCUS, child_id_)); 117 accessible_->accSelect(SELFLAG_TAKEFOCUS, child_id_));
118 118
119 // Double check that the object actually received focus. In some cases 119 // Double check that the object actually received focus. In some cases
120 // the parent object must have the focus first. 120 // the parent object must have the focus first.
121 bool did_focus = false; 121 bool did_focus = false;
122 ScopedVariant focused; 122 base::win::ScopedVariant focused;
123 if (SUCCEEDED(accessible_->get_accFocus(focused.Receive()))) { 123 if (SUCCEEDED(accessible_->get_accFocus(focused.Receive()))) {
124 if (focused.type() != VT_EMPTY) 124 if (focused.type() != VT_EMPTY)
125 did_focus = true; 125 did_focus = true;
126 } 126 }
127 EXPECT_TRUE(did_focus) << "Could not focus AccObject: " << GetDescription(); 127 EXPECT_TRUE(did_focus) << "Could not focus AccObject: " << GetDescription();
128 return did_focus; 128 return did_focus;
129 } 129 }
130 130
131 bool AccObject::Select() { 131 bool AccObject::Select() {
132 // SELFLAG_TAKESELECTION needs to be combined with the focus in order to 132 // SELFLAG_TAKESELECTION needs to be combined with the focus in order to
133 // take effect. 133 // take effect.
134 int selection_flag = SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION; 134 int selection_flag = SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION;
135 EXPECT_HRESULT_SUCCEEDED(accessible_->accSelect(selection_flag, child_id_)); 135 EXPECT_HRESULT_SUCCEEDED(accessible_->accSelect(selection_flag, child_id_));
136 136
137 // Double check that the object actually received selection. 137 // Double check that the object actually received selection.
138 bool did_select = false; 138 bool did_select = false;
139 ScopedVariant selected; 139 base::win::ScopedVariant selected;
140 if (SUCCEEDED(accessible_->get_accSelection(selected.Receive()))) { 140 if (SUCCEEDED(accessible_->get_accSelection(selected.Receive()))) {
141 if (selected.type() != VT_EMPTY) 141 if (selected.type() != VT_EMPTY)
142 did_select = true; 142 did_select = true;
143 } 143 }
144 EXPECT_TRUE(did_select) << "Could not select AccObject: " << GetDescription(); 144 EXPECT_TRUE(did_select) << "Could not select AccObject: " << GetDescription();
145 return did_select; 145 return did_select;
146 } 146 }
147 147
148 bool AccObject::SetValue(const std::wstring& value) { 148 bool AccObject::SetValue(const std::wstring& value) {
149 base::win::ScopedBstr value_bstr(value.c_str()); 149 base::win::ScopedBstr value_bstr(value.c_str());
(...skipping 15 matching lines...)
165 DCHECK(name); 165 DCHECK(name);
166 base::win::ScopedBstr name_bstr; 166 base::win::ScopedBstr name_bstr;
167 HRESULT result = accessible_->get_accName(child_id_, name_bstr.Receive()); 167 HRESULT result = accessible_->get_accName(child_id_, name_bstr.Receive());
168 if (SUCCEEDED(result)) 168 if (SUCCEEDED(result))
169 name->assign(name_bstr, name_bstr.Length()); 169 name->assign(name_bstr, name_bstr.Length());
170 return SUCCEEDED(result); 170 return SUCCEEDED(result);
171 } 171 }
172 172
173 bool AccObject::GetRoleText(std::wstring* role_text) { 173 bool AccObject::GetRoleText(std::wstring* role_text) {
174 DCHECK(role_text); 174 DCHECK(role_text);
175 ScopedVariant role_variant; 175 base::win::ScopedVariant role_variant;
176 if (SUCCEEDED(accessible_->get_accRole(child_id_, role_variant.Receive()))) { 176 if (SUCCEEDED(accessible_->get_accRole(child_id_, role_variant.Receive()))) {
177 if (role_variant.type() == VT_I4) { 177 if (role_variant.type() == VT_I4) {
178 wchar_t role_text_array[50]; 178 wchar_t role_text_array[50];
179 UINT characters = ::GetRoleText(V_I4(&role_variant), role_text_array, 179 UINT characters = ::GetRoleText(V_I4(&role_variant), role_text_array,
180 arraysize(role_text_array)); 180 arraysize(role_text_array));
181 if (characters) { 181 if (characters) {
182 *role_text = role_text_array; 182 *role_text = role_text_array;
183 return true; 183 return true;
184 } else { 184 } else {
185 DLOG(ERROR) << "GetRoleText failed for role: " 185 DLOG(ERROR) << "GetRoleText failed for role: "
(...skipping 14 matching lines...)
200 DCHECK(value); 200 DCHECK(value);
201 base::win::ScopedBstr value_bstr; 201 base::win::ScopedBstr value_bstr;
202 HRESULT result = accessible_->get_accValue(child_id_, value_bstr.Receive()); 202 HRESULT result = accessible_->get_accValue(child_id_, value_bstr.Receive());
203 if (SUCCEEDED(result)) 203 if (SUCCEEDED(result))
204 value->assign(value_bstr, value_bstr.Length()); 204 value->assign(value_bstr, value_bstr.Length());
205 return SUCCEEDED(result); 205 return SUCCEEDED(result);
206 } 206 }
207 207
208 bool AccObject::GetState(int* state) { 208 bool AccObject::GetState(int* state) {
209 DCHECK(state); 209 DCHECK(state);
210 ScopedVariant state_variant; 210 base::win::ScopedVariant state_variant;
211 if (SUCCEEDED(accessible_->get_accState(child_id_, 211 if (SUCCEEDED(accessible_->get_accState(child_id_,
212 state_variant.Receive()))) { 212 state_variant.Receive()))) {
213 if (state_variant.type() == VT_I4) { 213 if (state_variant.type() == VT_I4) {
214 *state = V_I4(&state_variant); 214 *state = V_I4(&state_variant);
215 return true; 215 return true;
216 } 216 }
217 } 217 }
218 return false; 218 return false;
219 } 219 }
220 220
(...skipping 106 matching lines...)
327 } 327 }
328 return true; 328 return true;
329 } 329 }
330 330
331 bool AccObject::GetFromNavigation(long navigation_type, 331 bool AccObject::GetFromNavigation(long navigation_type,
332 scoped_refptr<AccObject>* object) { 332 scoped_refptr<AccObject>* object) {
333 DCHECK(object); 333 DCHECK(object);
334 bool is_child_navigation = navigation_type == NAVDIR_FIRSTCHILD || 334 bool is_child_navigation = navigation_type == NAVDIR_FIRSTCHILD ||
335 navigation_type == NAVDIR_LASTCHILD; 335 navigation_type == NAVDIR_LASTCHILD;
336 DCHECK(!is_child_navigation || !IsSimpleElement()); 336 DCHECK(!is_child_navigation || !IsSimpleElement());
337 ScopedVariant object_variant; 337 base::win::ScopedVariant object_variant;
338 HRESULT result = accessible_->accNavigate(navigation_type, 338 HRESULT result = accessible_->accNavigate(navigation_type,
339 child_id_, 339 child_id_,
340 object_variant.Receive()); 340 object_variant.Receive());
341 if (FAILED(result)) { 341 if (FAILED(result)) {
342 LOG(WARNING) << "Navigation from accessibility object failed"; 342 LOG(WARNING) << "Navigation from accessibility object failed";
343 return false; 343 return false;
344 } 344 }
345 if (result == S_FALSE || object_variant.type() == VT_EMPTY) { 345 if (result == S_FALSE || object_variant.type() == VT_EMPTY) {
346 // This indicates that there was no accessibility object found by the 346 // This indicates that there was no accessibility object found by the
347 // navigation. 347 // navigation.
(...skipping 316 matching lines...)
664 } 664 }
665 665
666 bool IsDesktopUnlocked() { 666 bool IsDesktopUnlocked() {
667 HDESK desk = ::OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); 667 HDESK desk = ::OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
668 if (desk) 668 if (desk)
669 ::CloseDesktop(desk); 669 ::CloseDesktop(desk);
670 return desk; 670 return desk;
671 } 671 }
672 672
673 } // namespace chrome_frame_test 673 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_ui_test_utils.h ('k') | chrome_frame/test/ie_event_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine