Chromium Code Reviews| 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, DISABLED_TestTextBoundaries) { | 323 TEST_F(BrowserAccessibilityTest, 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(0, start); | 377 ASSERT_EQ(0, start); |
| 378 ASSERT_EQ(0, end); | 378 ASSERT_EQ(0, end); |
| 379 text.Reset(); | 379 text.Reset(); |
| 380 | 380 |
| 381 /* | |
|
dmazzoni
2015/04/29 21:49:50
Commented out on purpose? Do these assertions no l
| |
| 382 // TODO(nektar): Add word_start_offsets and inline text boxes in a11y tree. | |
| 381 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 383 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 382 1, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 384 1, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
| 383 ASSERT_EQ(0, start); | 385 ASSERT_EQ(0, start); |
| 384 ASSERT_EQ(4, end); | 386 ASSERT_EQ(4, end); |
| 385 ASSERT_STREQ(L"One ", text); | 387 ASSERT_STREQ(L"One ", text); |
| 386 text.Reset(); | 388 text.Reset(); |
| 387 | 389 |
| 388 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 390 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 389 6, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 391 6, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
| 390 ASSERT_EQ(4, start); | 392 ASSERT_EQ(4, start); |
| 391 ASSERT_EQ(8, end); | 393 ASSERT_EQ(8, end); |
| 392 ASSERT_STREQ(L"two\n", text); | 394 ASSERT_STREQ(L"two\n", text); |
| 393 text.Reset(); | 395 text.Reset(); |
| 394 | 396 |
| 395 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 397 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 396 text1_len, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); | 398 text1_len, IA2_TEXT_BOUNDARY_WORD, &start, &end, text.Receive())); |
| 397 ASSERT_EQ(25, start); | 399 ASSERT_EQ(25, start); |
| 398 ASSERT_EQ(29, end); | 400 ASSERT_EQ(29, end); |
| 399 ASSERT_STREQ(L"six.", text); | 401 ASSERT_STREQ(L"six.", text); |
| 400 text.Reset(); | 402 text.Reset(); |
| 403 */ | |
| 401 | 404 |
| 402 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 405 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 403 1, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); | 406 1, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); |
| 404 ASSERT_EQ(0, start); | 407 ASSERT_EQ(0, start); |
| 405 ASSERT_EQ(15, end); | 408 ASSERT_EQ(15, end); |
| 406 ASSERT_STREQ(L"One two three.\n", text); | 409 ASSERT_STREQ(L"One two three.\n", text); |
| 407 text.Reset(); | 410 text.Reset(); |
| 408 | 411 |
| 409 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( | 412 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( |
| 410 text1_len, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); | 413 text1_len, IA2_TEXT_BOUNDARY_LINE, &start, &end, text.Receive())); |
| 411 ASSERT_EQ(15, start); | 414 ASSERT_EQ(15, start); |
| 412 ASSERT_EQ(text1_len, end); | 415 ASSERT_EQ(text1_len, end); |
| 413 ASSERT_STREQ(L"Four five six.", text); | 416 ASSERT_STREQ(L"Four five six.", text); |
| 414 text.Reset(); | 417 text.Reset(); |
| 415 | 418 |
| 416 ASSERT_EQ(S_OK, | 419 ASSERT_EQ(S_OK, |
| 417 text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); | 420 text1_obj->get_text(0, IA2_TEXT_OFFSET_LENGTH, text.Receive())); |
| 418 ASSERT_EQ(0, start); | |
| 419 ASSERT_EQ(text1_len, end); | |
| 420 ASSERT_STREQ(L"One two three.\nFour five six.", text); | 421 ASSERT_STREQ(L"One two three.\nFour five six.", text); |
| 421 | 422 |
| 422 // Delete the manager and test that all BrowserAccessibility instances are | 423 // Delete the manager and test that all BrowserAccessibility instances are |
| 423 // deleted. | 424 // deleted. |
| 424 manager.reset(); | 425 manager.reset(); |
| 425 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 426 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 426 } | 427 } |
| 427 | 428 |
| 428 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { | 429 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { |
| 429 const std::string text1_name = "One two three."; | 430 const std::string text1_name = "One two three."; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 0L /* selection_index */, &selection_start, &selection_end);; | 856 0L /* selection_index */, &selection_start, &selection_end);; |
| 856 EXPECT_EQ(S_OK, hr); | 857 EXPECT_EQ(S_OK, hr); |
| 857 EXPECT_EQ(1L, selection_start); | 858 EXPECT_EQ(1L, selection_start); |
| 858 EXPECT_EQ(2L, selection_end); | 859 EXPECT_EQ(2L, selection_end); |
| 859 | 860 |
| 860 manager.reset(); | 861 manager.reset(); |
| 861 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); | 862 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); |
| 862 } | 863 } |
| 863 | 864 |
| 864 } // namespace content | 865 } // namespace content |
| OLD | NEW |