OLD | NEW |
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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/win/scoped_bstr.h" | 7 #include "base/win/scoped_bstr.h" |
8 #include "base/win/scoped_comptr.h" | 8 #include "base/win/scoped_comptr.h" |
9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 events.push_back(param); | 313 events.push_back(param); |
314 manager->OnAccessibilityEvents(events); | 314 manager->OnAccessibilityEvents(events); |
315 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); | 315 ASSERT_EQ(1, CountedBrowserAccessibility::num_instances()); |
316 | 316 |
317 // Delete the manager and test that all BrowserAccessibility instances are | 317 // Delete the manager and test that all BrowserAccessibility instances are |
318 // deleted. | 318 // deleted. |
319 manager.reset(); | 319 manager.reset(); |
320 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 320 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
321 } | 321 } |
322 | 322 |
323 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { | 323 TEST_F(BrowserAccessibilityTest, DISABLED_TestTextBoundaries) { |
324 std::string text1_value = "One two three.\nFour five six."; | 324 std::string text1_value = "One two three.\nFour five six."; |
325 | 325 |
326 ui::AXNodeData text1; | 326 ui::AXNodeData text1; |
327 text1.id = 11; | 327 text1.id = 11; |
328 text1.role = ui::AX_ROLE_TEXT_FIELD; | 328 text1.role = ui::AX_ROLE_TEXT_FIELD; |
329 text1.state = 0; | 329 text1.state = 0; |
330 text1.AddStringAttribute(ui::AX_ATTR_VALUE, text1_value); | 330 text1.AddStringAttribute(ui::AX_ATTR_VALUE, text1_value); |
331 std::vector<int32> line_breaks; | 331 std::vector<int32> line_breaks; |
332 line_breaks.push_back(15); | 332 line_breaks.push_back(15); |
333 text1.AddIntListAttribute( | 333 text1.AddIntListAttribute( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 long end; | 367 long end; |
368 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 368 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
369 1, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive())); | 369 1, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive())); |
370 ASSERT_EQ(1, start); | 370 ASSERT_EQ(1, start); |
371 ASSERT_EQ(2, end); | 371 ASSERT_EQ(2, end); |
372 ASSERT_STREQ(L"n", text); | 372 ASSERT_STREQ(L"n", text); |
373 text.Reset(); | 373 text.Reset(); |
374 | 374 |
375 ASSERT_EQ(S_FALSE, text1_obj->get_textAtOffset( | 375 ASSERT_EQ(S_FALSE, text1_obj->get_textAtOffset( |
376 text1_len, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive())); | 376 text1_len, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive())); |
377 ASSERT_EQ(text1_len, start); | 377 ASSERT_EQ(0, start); |
378 ASSERT_EQ(text1_len, end); | 378 ASSERT_EQ(0, end); |
379 text.Reset(); | 379 text.Reset(); |
380 | 380 |
381 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 381 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
382 1, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 382 1, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
383 ASSERT_EQ(0, start); | 383 ASSERT_EQ(0, start); |
384 ASSERT_EQ(3, end); | 384 ASSERT_EQ(4, end); |
385 ASSERT_STREQ(L"One", text); | 385 ASSERT_STREQ(L"One ", text); |
386 text.Reset(); | 386 text.Reset(); |
387 | 387 |
388 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 388 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
389 6, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 389 6, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
390 ASSERT_EQ(4, start); | 390 ASSERT_EQ(4, start); |
391 ASSERT_EQ(7, end); | 391 ASSERT_EQ(8, end); |
392 ASSERT_STREQ(L"two", text); | 392 ASSERT_STREQ(L"two\n", text); |
393 text.Reset(); | 393 text.Reset(); |
394 | 394 |
395 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 395 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
396 text1_len, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 396 text1_len, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
397 ASSERT_EQ(25, start); | 397 ASSERT_EQ(25, start); |
398 ASSERT_EQ(29, end); | 398 ASSERT_EQ(29, end); |
399 ASSERT_STREQ(L"six.", text); | 399 ASSERT_STREQ(L"six.", text); |
400 text.Reset(); | 400 text.Reset(); |
401 | 401 |
402 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 402 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
403 1, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); | 403 1, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); |
404 ASSERT_EQ(0, start); | 404 ASSERT_EQ(0, start); |
405 ASSERT_EQ(15, end); | 405 ASSERT_EQ(15, end); |
406 ASSERT_STREQ(L"One two three.\n", text); | 406 ASSERT_STREQ(L"One two three.\n", text); |
407 text.Reset(); | 407 text.Reset(); |
408 | 408 |
| 409 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 410 text1_len, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); |
| 411 ASSERT_EQ(15, start); |
| 412 ASSERT_EQ(text1_len, end); |
| 413 ASSERT_STREQ(L"Four five six.", text); |
| 414 text.Reset(); |
| 415 |
409 ASSERT_EQ(S_OK, | 416 ASSERT_EQ(S_OK, |
410 text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 417 text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
| 418 ASSERT_EQ(0, start); |
| 419 ASSERT_EQ(text1_len, end); |
411 ASSERT_STREQ(L"One two three.\nFour five six.", text); | 420 ASSERT_STREQ(L"One two three.\nFour five six.", text); |
412 | 421 |
413 // Delete the manager and test that all BrowserAccessibility instances are | 422 // Delete the manager and test that all BrowserAccessibility instances are |
414 // deleted. | 423 // deleted. |
415 manager.reset(); | 424 manager.reset(); |
416 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 425 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
417 } | 426 } |
418 | 427 |
419 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { | 428 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { |
420 const std::string text1_name = "One two three."; | 429 const std::string text1_name = "One two three."; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 EXPECT_EQ(S_OK, hr); | 749 EXPECT_EQ(S_OK, hr); |
741 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); | 750 EXPECT_NE(nullptr, static_cast<BSTR>(attributes)); |
742 std::wstring attributes_str(attributes, attributes.Length()); | 751 std::wstring attributes_str(attributes, attributes.Length()); |
743 EXPECT_EQ(L"checkable:true;", attributes_str); | 752 EXPECT_EQ(L"checkable:true;", attributes_str); |
744 | 753 |
745 manager.reset(); | 754 manager.reset(); |
746 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 755 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
747 } | 756 } |
748 | 757 |
749 } // namespace content | 758 } // namespace content |
OLD | NEW |