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

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: Remove calls to ExecuteJavaScript 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());
esprehn 2017/04/21 03:14:46 Could you assert about some properties of the AOM
dmazzoni 2017/04/21 04:53:14 Sure. I'll follow up with a lot more tests too.
37 }
38
39 TEST_F(AccessibilityObjectModelTest, SetAccessibleNodeRole) {
40 SimRequest main_resource("https://example.com/", "text/html");
41 LoadURL("https://example.com/");
42 main_resource.Complete("<button id=button>Click me</button>");
43
44 auto* cache = AXObjectCache();
45 ASSERT_NE(nullptr, cache);
46
47 auto* button = GetDocument().getElementById("button");
48 ASSERT_NE(nullptr, button);
49
50 auto* axButton = cache->GetOrCreate(button);
51 EXPECT_EQ(kButtonRole, axButton->RoleValue());
52
53 button->accessibleNode()->setRole("slider");
54
55 EXPECT_EQ(kSliderRole, axButton->RoleValue());
56 }
57
58 } // namespace
59
60 } // 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