| 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/view_messages.h" | 6 #include "content/common/view_messages.h" |
| 7 #include "content/public/test/render_view_test.h" | 7 #include "content/public/test/render_view_test.h" |
| 8 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 8 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
| 9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 RenderViewImpl* view() { | 61 RenderViewImpl* view() { |
| 62 return static_cast<RenderViewImpl*>(view_); | 62 return static_cast<RenderViewImpl*>(view_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void SetUp() { | 65 virtual void SetUp() { |
| 66 RenderViewTest::SetUp(); | 66 RenderViewTest::SetUp(); |
| 67 sink_ = &render_thread_->sink(); | 67 sink_ = &render_thread_->sink(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void SetMode(AccessibilityMode mode) { | 70 void SetMode(unsigned int mode) { |
| 71 view()->OnSetAccessibilityMode(mode); | 71 view()->OnSetAccessibilityMode(mode); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void GetLastAccEvent( | 74 void GetLastAccEvent( |
| 75 AccessibilityHostMsg_EventParams* params) { | 75 AccessibilityHostMsg_EventParams* params) { |
| 76 const IPC::Message* message = | 76 const IPC::Message* message = |
| 77 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); | 77 sink_->GetUniqueMessageMatching(AccessibilityHostMsg_Events::ID); |
| 78 ASSERT_TRUE(message); | 78 ASSERT_TRUE(message); |
| 79 Tuple1<std::vector<AccessibilityHostMsg_EventParams> > param; | 79 Tuple1<std::vector<AccessibilityHostMsg_EventParams> > param; |
| 80 AccessibilityHostMsg_Events::Read(message, ¶m); | 80 AccessibilityHostMsg_Events::Read(message, ¶m); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 IPC::TestSink* sink_; | 92 IPC::TestSink* sink_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityTest); | 94 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityTest); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) { | 97 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) { |
| 98 // This is not a test of true web accessibility, it's a test of | 98 // This is not a test of true web accessibility, it's a test of |
| 99 // a mode used on Windows 8 in Metro mode where an extremely simplified | 99 // a mode used on Windows 8 in Metro mode where an extremely simplified |
| 100 // accessibility tree containing only the current focused node is | 100 // accessibility tree containing only the current focused node is |
| 101 // generated. | 101 // generated. |
| 102 SetMode(AccessibilityModeEditableTextOnly); | 102 SetMode(AccessibilityModeFlagRenderer & |
| 103 AccessibilityModeFlagEditableTextOnly); |
| 103 | 104 |
| 104 // Set a minimum size and give focus so simulated events work. | 105 // Set a minimum size and give focus so simulated events work. |
| 105 view()->webwidget()->resize(blink::WebSize(500, 500)); | 106 view()->webwidget()->resize(blink::WebSize(500, 500)); |
| 106 view()->webwidget()->setFocus(true); | 107 view()->webwidget()->setFocus(true); |
| 107 | 108 |
| 108 std::string html = | 109 std::string html = |
| 109 "<body>" | 110 "<body>" |
| 110 " <input>" | 111 " <input>" |
| 111 " <textarea></textarea>" | 112 " <textarea></textarea>" |
| 112 " <p contentEditable>Editable</p>" | 113 " <p contentEditable>Editable</p>" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 GetLastAccEvent(&event); | 533 GetLastAccEvent(&event); |
| 533 ASSERT_EQ(5U, event.nodes.size()); | 534 ASSERT_EQ(5U, event.nodes.size()); |
| 534 | 535 |
| 535 EXPECT_EQ(body.axID(), event.nodes[0].id); | 536 EXPECT_EQ(body.axID(), event.nodes[0].id); |
| 536 EXPECT_EQ(text_1.axID(), event.nodes[1].id); | 537 EXPECT_EQ(text_1.axID(), event.nodes[1].id); |
| 537 // The third event is to update text_2, but its id changes | 538 // The third event is to update text_2, but its id changes |
| 538 // so we don't have a test expectation for it. | 539 // so we don't have a test expectation for it. |
| 539 } | 540 } |
| 540 | 541 |
| 541 } // namespace content | 542 } // namespace content |
| OLD | NEW |