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

Side by Side Diff: Source/modules/accessibility/AXObjectTest.cpp

Issue 885163002: [Contextual Search] Check for ARIA widget roles. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleaup usage of Web wrappers. Created 5 years, 10 months 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
OLDNEW
(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 <gtest/gtest.h>
12
13 namespace blink {
14
15 class AXObjectTest : public testing::Test {
16 protected:
17 Document& document() { return m_pageHolder->document(); }
18
19 private:
20 virtual void SetUp() override;
21
22 OwnPtr<DummyPageHolder> m_pageHolder;
23 };
24
25 void AXObjectTest::SetUp()
26 {
27 m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
28 }
29
30 TEST_F(AXObjectTest, IsARIAWidget)
31 {
32 String testContent = "<body>"
33 "<span id=\"plain\">plain</span><br>"
34 "<span id=\"button\" role=\"button\">button</span><br>"
35 "<span id=\"button-parent\" role=\"button\"><span>button-parent</span></ span><br>"
36 "<span id=\"button-caps\" role=\"BUTTON\">button-caps</span><br>"
37 "<span id=\"button-second\" role=\"another-role button\">button-second</ span><br>"
38 "<span id=\"aria-bogus\" aria-bogus=\"bogus\">aria-bogus</span><br>"
39 "<span id=\"aria-selected\" aria-selected>aria-selected</span><br>"
40 "<span id=\"haspopup-true\" aria-haspopup=\"true\">aria-haspopup-true</s pan><br>"
41 "<span id=\"haspopup-false\" aria-haspopup=\"false\">aria-haspopup-false </span><br>"
42 "<div id=\"focusable\" tabindex=\"1\">focusable</div><br>"
43 "<div id=\"focusable-parent\" tabindex=\"2\"><div>focusable-parent</div> </div><br>"
dmazzoni 2015/02/10 07:40:54 I don't see a test for this line. You should proba
Donn Denman 2015/02/24 23:37:52 Nice catch! Done.
44 "</body>";
45
46 document().documentElement()->setInnerHTML(testContent, ASSERT_NO_EXCEPTION) ;
47 document().updateLayout();
48 Element* root(document().documentElement());
49 EXPECT_FALSE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElemen tById("plain")));
50 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("button")));
51 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("button-parent")));
52 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("button-caps")));
53 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("button-second")));
54 EXPECT_FALSE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElemen tById("aria-bogus")));
55 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("aria-selected")));
56 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("haspopup-true")));
57 EXPECT_FALSE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElemen tById("haspopup-false")));
58 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("focusable")));
59 EXPECT_TRUE(AXObject::isInsideFocusableElementOrARIAWidget(*root->getElement ById("focusable")));
60 }
61
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698