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

Side by Side Diff: third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp

Issue 2823163002: Port some AOM tests from LayoutTests to SimTests. (Closed)
Patch Set: Address last feedback Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 "core/dom/AccessibleNode.h"
6 #include "core/html/HTMLBodyElement.h"
7 #include "modules/accessibility/AXObjectCacheImpl.h"
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
9 #include "web/tests/sim/SimRequest.h"
10 #include "web/tests/sim/SimTest.h"
11
12 namespace blink {
13
14 namespace {
15
16 class AccessibilityObjectModelTest
17 : public SimTest,
18 public ScopedAccessibilityObjectModelForTest {
19 public:
20 AccessibilityObjectModelTest()
21 : ScopedAccessibilityObjectModelForTest(true) {}
22
23 protected:
24 AXObjectCacheImpl* AXObjectCache() {
25 GetDocument().GetSettings()->SetAccessibilityEnabled(true);
26 return static_cast<AXObjectCacheImpl*>(GetDocument().AxObjectCache());
27 }
28 };
29
30 TEST_F(AccessibilityObjectModelTest, DOMElementsHaveAnAccessibleNode) {
31 SimRequest main_resource("https://example.com/", "text/html");
32 LoadURL("https://example.com/");
33 main_resource.Complete("<button id=button>Click me</button>");
34
35 auto* button = GetDocument().getElementById("button");
36 EXPECT_NE(nullptr, button->accessibleNode());
37 EXPECT_TRUE(button->accessibleNode()->role().IsNull());
38 EXPECT_TRUE(button->accessibleNode()->label().IsNull());
39 }
40
41 TEST_F(AccessibilityObjectModelTest, SetAccessibleNodeRole) {
42 SimRequest main_resource("https://example.com/", "text/html");
43 LoadURL("https://example.com/");
44 main_resource.Complete("<button id=button>Click me</button>");
45
46 auto* cache = AXObjectCache();
47 ASSERT_NE(nullptr, cache);
48
49 auto* button = GetDocument().getElementById("button");
50 ASSERT_NE(nullptr, button);
51
52 auto* axButton = cache->GetOrCreate(button);
53 EXPECT_EQ(kButtonRole, axButton->RoleValue());
54
55 button->accessibleNode()->setRole("slider");
56 EXPECT_EQ("slider", button->accessibleNode()->role());
57
58 EXPECT_EQ(kSliderRole, axButton->RoleValue());
59 }
60
61 } // namespace
62
63 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698