OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "modules/accessibility/AXObject.h" | |
7 | |
8 #include "core/dom/Document.h" | |
9 #include "core/dom/Element.h" | |
10 #include "core/testing/DummyPageHolder.h" | |
11 // #include "public/web/WebNode.h" | |
12 #include <gtest/gtest.h> | |
13 | |
14 namespace blink { | |
15 | |
16 class AXObjectTest : public testing::Test { | |
17 protected: | |
18 Document& document() { return m_pageHolder->document(); } | |
19 | |
20 private: | |
21 virtual void SetUp() override; | |
22 | |
23 OwnPtr<DummyPageHolder> m_pageHolder; | |
24 }; | |
25 | |
26 void AXObjectTest::SetUp() | |
27 { | |
28 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); | |
29 } | |
30 | |
31 TEST_F(AXObjectTest, IsARIAWidget) | |
32 { | |
33 String testContent = "<body>" | |
34 "<span id=\"plain\">plain</span><br>" | |
35 "<span id=\"button\" role=\"button\">button</span><br>" | |
36 "<span id=\"button-parent\" role=\"button\"><span>button-parent</span></ span><br>" | |
37 "<span id=\"button-caps\" role=\"BUTTON\">button-caps</span><br>" | |
38 "<span id=\"button-second\" role=\"another-role button\">button-second</ span><br>" | |
39 "<span id=\"aria-bogus\" aria-bogus=\"bogus\">aria-bogus</span><br>" | |
40 "<span id=\"aria-selected\" aria-selected>aria-selected</span><br>" | |
41 "<span id=\"haspopup-true\" aria-haspopup=\"true\">aria-haspopup-true</s pan><br>" | |
42 "<span id=\"haspopup-false\" aria-haspopup=\"false\">aria-haspopup-false </span><br>" | |
43 "<div id=\"focusable\" tabindex=\"1\">focusable</div><br>" | |
44 "<div id=\"focusable-parent\" tabindex=\"2\"><div>focusable-parent</div> </div><br>" | |
45 "</body>"; | |
46 | |
47 document().documentElement()->setInnerHTML(testContent, ASSERT_NO_EXCEPTION) ; | |
48 document().updateLayout(); | |
49 Element* root(document().documentElement()); | |
50 EXPECT_FALSE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementByI d("plain")))); | |
dmazzoni
2015/02/05 00:40:23
No need to cast to WebNode, just pass the Node
Donn Denman
2015/02/06 22:53:36
Done -- looks like I don't even need the cast, jus
| |
51 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("button")))); | |
52 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("button-parent")))); | |
53 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("button-caps")))); | |
54 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("button-second")))); | |
55 EXPECT_FALSE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementByI d("aria-bogus")))); | |
56 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("aria-selected")))); | |
57 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("haspopup-true")))); | |
58 EXPECT_FALSE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementByI d("haspopup-false")))); | |
59 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("focusable")))); | |
60 EXPECT_TRUE(AXObject::isARIAWidget(static_cast<WebNode>(root->getElementById ("focusable-parent")))); | |
61 } | |
62 | |
63 } | |
OLD | NEW |