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

Side by Side Diff: content/renderer/accessibility/renderer_accessibility_browsertest.cc

Issue 25943003: Support accessible inline text boxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 7 years, 1 month 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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/common/accessibility_node_data.h" 6 #include "content/common/accessibility_node_data.h"
7 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
8 #include "content/public/test/render_view_test.h" 8 #include "content/public/test/render_view_test.h"
9 #include "content/renderer/accessibility/renderer_accessibility_complete.h" 9 #include "content/renderer/accessibility/renderer_accessibility_complete.h"
10 #include "content/renderer/render_view_impl.h" 10 #include "content/renderer/render_view_impl.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 "<body>" 325 "<body>"
326 " <p>Hello, world.</p>" 326 " <p>Hello, world.</p>"
327 "</body>"; 327 "</body>";
328 LoadHTML(html.c_str()); 328 LoadHTML(html.c_str());
329 329
330 // Creating a RendererAccessibilityComplete should send the tree 330 // Creating a RendererAccessibilityComplete should send the tree
331 // to the browser. 331 // to the browser.
332 scoped_ptr<TestRendererAccessibilityComplete> accessibility( 332 scoped_ptr<TestRendererAccessibilityComplete> accessibility(
333 new TestRendererAccessibilityComplete(view())); 333 new TestRendererAccessibilityComplete(view()));
334 accessibility->SendPendingAccessibilityEvents(); 334 accessibility->SendPendingAccessibilityEvents();
335 EXPECT_EQ(3, accessibility->browser_tree_node_count()); 335 EXPECT_EQ(5, accessibility->browser_tree_node_count());
336 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); 336 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser());
337 337
338 // Post a "value changed" event, but then swap out 338 // Post a "value changed" event, but then swap out
339 // before sending it. It shouldn't send the event while 339 // before sending it. It shouldn't send the event while
340 // swapped out. 340 // swapped out.
341 sink_->ClearMessages(); 341 sink_->ClearMessages();
342 WebDocument document = view()->GetWebView()->mainFrame()->document(); 342 WebDocument document = view()->GetWebView()->mainFrame()->document();
343 WebAXObject root_obj = document.accessibilityObject(); 343 WebAXObject root_obj = document.accessibilityObject();
344 accessibility->HandleWebAccessibilityEvent( 344 accessibility->HandleWebAccessibilityEvent(
345 root_obj, 345 root_obj,
346 WebKit::WebAXEventValueChanged); 346 WebKit::WebAXEventValueChanged);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // a layout occurs and an anonymous render block is no longer needed. 472 // a layout occurs and an anonymous render block is no longer needed.
473 std::string html = 473 std::string html =
474 "<body aria-label='Body'>" 474 "<body aria-label='Body'>"
475 "<span>1</span><span style='display:block'>2</span>" 475 "<span>1</span><span style='display:block'>2</span>"
476 "</body>"; 476 "</body>";
477 LoadHTML(html.c_str()); 477 LoadHTML(html.c_str());
478 478
479 scoped_ptr<TestRendererAccessibilityComplete> accessibility( 479 scoped_ptr<TestRendererAccessibilityComplete> accessibility(
480 new TestRendererAccessibilityComplete(view())); 480 new TestRendererAccessibilityComplete(view()));
481 accessibility->SendPendingAccessibilityEvents(); 481 accessibility->SendPendingAccessibilityEvents();
482 EXPECT_EQ(5, accessibility->browser_tree_node_count()); 482 EXPECT_EQ(7, accessibility->browser_tree_node_count());
483 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); 483 EXPECT_EQ(7, CountAccessibilityNodesSentToBrowser());
484 484
485 // Initially, the accessibility tree looks like this: 485 // Initially, the accessibility tree looks like this:
486 // 486 //
487 // Document 487 // Document
488 // +--Body 488 // +--Body
489 // +--Anonymous Block 489 // +--Anonymous Block
490 // +--Static Text "1" 490 // +--Static Text "1"
491 // +--Inline Text Box "1"
491 // +--Static Text "2" 492 // +--Static Text "2"
493 // +--Inline Text Box "2"
492 WebDocument document = view()->GetWebView()->mainFrame()->document(); 494 WebDocument document = view()->GetWebView()->mainFrame()->document();
493 WebAXObject root_obj = document.accessibilityObject(); 495 WebAXObject root_obj = document.accessibilityObject();
494 WebAXObject body = root_obj.childAt(0); 496 WebAXObject body = root_obj.childAt(0);
495 WebAXObject anonymous_block = body.childAt(0); 497 WebAXObject anonymous_block = body.childAt(0);
496 WebAXObject text_1 = anonymous_block.childAt(0); 498 WebAXObject text_1 = anonymous_block.childAt(0);
497 WebAXObject text_2 = body.childAt(1); 499 WebAXObject text_2 = body.childAt(1);
498 500
499 // Change the display of the second 'span' back to inline, which causes the 501 // Change the display of the second 'span' back to inline, which causes the
500 // anonymous block to be destroyed. 502 // anonymous block to be destroyed.
501 ExecuteJavaScript( 503 ExecuteJavaScript(
502 "document.querySelectorAll('span')[1].style.display = 'inline';"); 504 "document.querySelectorAll('span')[1].style.display = 'inline';");
503 // Force layout now. 505 // Force layout now.
504 ExecuteJavaScript("document.body.offsetLeft;"); 506 ExecuteJavaScript("document.body.offsetLeft;");
505 507
506 // Send a childrenChanged on the body. 508 // Send a childrenChanged on the body.
507 sink_->ClearMessages(); 509 sink_->ClearMessages();
508 accessibility->HandleWebAccessibilityEvent( 510 accessibility->HandleWebAccessibilityEvent(
509 body, 511 body,
510 WebKit::WebAXEventChildrenChanged); 512 WebKit::WebAXEventChildrenChanged);
511 513
512 accessibility->SendPendingAccessibilityEvents(); 514 accessibility->SendPendingAccessibilityEvents();
513 515
514 // Afterwards, the accessibility tree looks like this: 516 // Afterwards, the accessibility tree looks like this:
515 // 517 //
516 // Document 518 // Document
517 // +--Body 519 // +--Body
518 // +--Static Text "1" 520 // +--Static Text "1"
521 // +--Inline Text Box "1"
519 // +--Static Text "2" 522 // +--Static Text "2"
523 // +--Inline Text Box "2"
520 // 524 //
521 // We just assert that there are now four nodes in the 525 // We just assert that there are now four nodes in the
522 // accessibility tree and that only three nodes needed 526 // accessibility tree and that only three nodes needed
523 // to be updated (the body, the static text 1, and 527 // to be updated (the body, the static text 1, and
524 // the static text 2). 528 // the static text 2).
525 EXPECT_EQ(4, accessibility->browser_tree_node_count()); 529 EXPECT_EQ(6, accessibility->browser_tree_node_count());
526 530
527 AccessibilityHostMsg_EventParams event; 531 AccessibilityHostMsg_EventParams event;
528 GetLastAccEvent(&event); 532 GetLastAccEvent(&event);
529 ASSERT_EQ(3U, event.nodes.size()); 533 ASSERT_EQ(5U, event.nodes.size());
530 534
531 EXPECT_EQ(body.axID(), event.nodes[0].id); 535 EXPECT_EQ(body.axID(), event.nodes[0].id);
532 EXPECT_EQ(text_1.axID(), event.nodes[1].id); 536 EXPECT_EQ(text_1.axID(), event.nodes[1].id);
533 // The third event is to update text_2, but its id changes 537 // The third event is to update text_2, but its id changes
534 // so we don't have a test expectation for it. 538 // so we don't have a test expectation for it.
535 } 539 }
536 540
537 } // namespace content 541 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698