| 323 | } |
| 324 | |
| 325 | IAccessible* Alert::GetChildWithRole(IAccessible* parent, long expected_role, int index) { |
| 326 | LOG(TRACE) << "Entering Alert::GetChildWithRole"; |
| 327 | IAccessible* child = NULL; |
| 328 | long child_count; |
| 329 | HRESULT hr = parent->get_accChildCount(&child_count); |
| 330 | if (FAILED(hr)) { |
| 331 | LOGHR(WARN, hr) << "Failed to get accChildCount property from Active Accessibility object"; |
| 332 | return child; |
| 333 | } |
| 334 | |
| 335 | long returned_children = 0; |
| 336 | std::vector<CComVariant> child_array(child_count); |
| 337 | hr = ::AccessibleChildren(parent, 0, child_count, &child_array[0], &returned_children); |
| 338 | |
| 339 | int found_index = 0; |
| 340 | for (long i = 0; i < child_count; ++i) { |
| 341 | if (child_array[i].vt == VT_DISPATCH) { |
| 342 | CComPtr<IAccessible> child_object; |
| 343 | hr = child_array[i].pdispVal->QueryInterface<IAccessible>(&child_object); |
| 344 | if (FAILED(hr)) { |
| 345 | LOGHR(WARN, hr) << "QueryInterface for IAccessible failed for child object with index " << i; |
| 346 | } |
| 347 | |
| 348 | CComVariant child_id; |
| 349 | child_id.vt = VT_I4; |
| 350 | child_id.lVal = CHILDID_SELF; |
| 351 | |
| 352 | CComVariant actual_role; |
| 353 | hr = child_object->get_accRole(child_id, &actual_role); |
| 354 | if (FAILED(hr)) { |
| 355 | LOGHR(WARN, hr) << "Failed to get accRole property from Active Accessibility object"; |
| 356 | } |
| 357 | |
| 358 | if (expected_role == actual_role.lVal) { |
| 359 | if (found_index == index) { |
| 360 | child = child_object.Detach(); |
| 361 | } else { |
| 362 | ++found_index; |
| 363 | } |
| 364 | } |
| 365 | LOG(DEBUG) << "accRole for child with index " << i << ": " << actual_role.lVal; |
| 366 | } |
| 367 | } |
| 368 | return child; |
| 369 | } |
| 370 | |
| 371 | HWND Alert::GetDirectUIChild() { |
| 372 | LOG(TRACE) << "Entering Alert::GetDirectUIChild"; |
no test coverage detected