| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/common/frame_messages.h" | 6 #include "content/common/frame_messages.h" |
| 7 #include "content/common/view_message_enums.h" | 7 #include "content/common/view_message_enums.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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 AccessibilityMessagesQueueWhileSwappedOut | 297 AccessibilityMessagesQueueWhileSwappedOut |
| 298 #endif | 298 #endif |
| 299 | 299 |
| 300 TEST_F(RendererAccessibilityTest, | 300 TEST_F(RendererAccessibilityTest, |
| 301 MAYBE_AccessibilityMessagesQueueWhileSwappedOut) { | 301 MAYBE_AccessibilityMessagesQueueWhileSwappedOut) { |
| 302 std::string html = | 302 std::string html = |
| 303 "<body>" | 303 "<body>" |
| 304 " <p>Hello, world.</p>" | 304 " <p>Hello, world.</p>" |
| 305 "</body>"; | 305 "</body>"; |
| 306 LoadHTML(html.c_str()); | 306 LoadHTML(html.c_str()); |
| 307 static const int kProxyRoutingId = 13; |
| 307 | 308 |
| 308 // Creating a RendererAccessibilityComplete should send the tree | 309 // Creating a RendererAccessibilityComplete should send the tree |
| 309 // to the browser. | 310 // to the browser. |
| 310 scoped_ptr<TestRendererAccessibilityComplete> accessibility( | 311 scoped_ptr<TestRendererAccessibilityComplete> accessibility( |
| 311 new TestRendererAccessibilityComplete(view())); | 312 new TestRendererAccessibilityComplete(view())); |
| 312 accessibility->SendPendingAccessibilityEvents(); | 313 accessibility->SendPendingAccessibilityEvents(); |
| 313 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); | 314 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); |
| 314 | 315 |
| 315 // Post a "value changed" event, but then swap out | 316 // Post a "value changed" event, but then swap out |
| 316 // before sending it. It shouldn't send the event while | 317 // before sending it. It shouldn't send the event while |
| 317 // swapped out. | 318 // swapped out. |
| 318 sink_->ClearMessages(); | 319 sink_->ClearMessages(); |
| 319 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 320 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 320 WebAXObject root_obj = document.accessibilityObject(); | 321 WebAXObject root_obj = document.accessibilityObject(); |
| 321 accessibility->HandleAXEvent( | 322 accessibility->HandleAXEvent( |
| 322 root_obj, | 323 root_obj, |
| 323 ui::AX_EVENT_VALUE_CHANGED); | 324 ui::AX_EVENT_VALUE_CHANGED); |
| 324 view()->main_render_frame()->OnSwapOut(); | 325 view()->main_render_frame()->OnSwapOut(kProxyRoutingId); |
| 325 accessibility->SendPendingAccessibilityEvents(); | 326 accessibility->SendPendingAccessibilityEvents(); |
| 326 EXPECT_FALSE(sink_->GetUniqueMessageMatching( | 327 EXPECT_FALSE(sink_->GetUniqueMessageMatching( |
| 327 AccessibilityHostMsg_Events::ID)); | 328 AccessibilityHostMsg_Events::ID)); |
| 328 | 329 |
| 329 // Navigate, so we're not swapped out anymore. Now we should | 330 // Navigate, so we're not swapped out anymore. Now we should |
| 330 // send accessibility events again. Note that the | 331 // send accessibility events again. Note that the |
| 331 // message that was queued up before will be quickly discarded | 332 // message that was queued up before will be quickly discarded |
| 332 // because the element it was referring to no longer exists, | 333 // because the element it was referring to no longer exists, |
| 333 // so the event here is from loading this new page. | 334 // so the event here is from loading this new page. |
| 334 FrameMsg_Navigate_Params nav_params; | 335 FrameMsg_Navigate_Params nav_params; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 545 |
| 545 const IPC::Message* message = | 546 const IPC::Message* message = |
| 546 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); | 547 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); |
| 547 ASSERT_TRUE(message); | 548 ASSERT_TRUE(message); |
| 548 Tuple1<std::vector<AccessibilityHostMsg_EventParams> > param; | 549 Tuple1<std::vector<AccessibilityHostMsg_EventParams> > param; |
| 549 AccessibilityHostMsg_Events::Read(message, ¶m); | 550 AccessibilityHostMsg_Events::Read(message, ¶m); |
| 550 ASSERT_EQ(0U, param.a.size()); | 551 ASSERT_EQ(0U, param.a.size()); |
| 551 } | 552 } |
| 552 | 553 |
| 553 } // namespace content | 554 } // namespace content |
| OLD | NEW |