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/macros.h" | 5 #include "base/macros.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 AccessibilityHostMsg_EventParams event; | 396 AccessibilityHostMsg_EventParams event; |
397 GetLastAccEvent(&event); | 397 GetLastAccEvent(&event); |
398 ASSERT_EQ(5U, event.update.nodes.size()); | 398 ASSERT_EQ(5U, event.update.nodes.size()); |
399 | 399 |
400 EXPECT_EQ(body.axID(), event.update.nodes[0].id); | 400 EXPECT_EQ(body.axID(), event.update.nodes[0].id); |
401 EXPECT_EQ(text_1.axID(), event.update.nodes[1].id); | 401 EXPECT_EQ(text_1.axID(), event.update.nodes[1].id); |
402 // The third event is to update text_2, but its id changes | 402 // The third event is to update text_2, but its id changes |
403 // so we don't have a test expectation for it. | 403 // so we don't have a test expectation for it. |
404 } | 404 } |
405 | 405 |
406 TEST_F(RendererAccessibilityTest, EventOnObjectNotInTree) { | |
407 // Test RendererAccessibility and make sure it doesn't send anything | |
408 // if we get a notification from Blink for an object that isn't in the | |
409 // tree, like the scroll area that's the parent of the main document, | |
410 // which we don't expose. | |
411 std::string html = "<body><input></body>"; | |
412 LoadHTML(html.c_str()); | |
413 | |
414 scoped_ptr<TestRendererAccessibility> accessibility( | |
415 new TestRendererAccessibility(frame())); | |
416 accessibility->SendPendingAccessibilityEvents(); | |
417 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); | |
418 | |
419 WebDocument document = view()->GetWebView()->mainFrame()->document(); | |
420 WebAXObject root_obj = document.accessibilityObject(); | |
421 WebAXObject scroll_area = root_obj.parentObject(); | |
422 EXPECT_EQ(blink::WebAXRoleScrollArea, scroll_area.role()); | |
423 | |
424 // Try to fire a message on the scroll area, and assert that we just | |
425 // ignore it. | |
426 sink_->ClearMessages(); | |
427 accessibility->HandleAXEvent(scroll_area, | |
428 ui::AX_EVENT_VALUE_CHANGED); | |
429 | |
430 accessibility->SendPendingAccessibilityEvents(); | |
431 | |
432 const IPC::Message* message = | |
433 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); | |
434 ASSERT_TRUE(message); | |
435 base::Tuple<std::vector<AccessibilityHostMsg_EventParams>, int> param; | |
436 AccessibilityHostMsg_Events::Read(message, ¶m); | |
437 ASSERT_EQ(0U, base::get<0>(param).size()); | |
438 } | |
439 | |
440 } // namespace content | 406 } // namespace content |
OLD | NEW |