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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/aria_util_test.js

Issue 292313004: Port aria_util_test.js to run as a WebUI test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify WebUIBrowserTest change Created 6 years, 7 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 | Annotate | Revision Log
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 test fixture.
6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']);
7
8 /**
9 * Test fixture for aria_util.js.
10 * @constructor
11 * @extends {ChromeVoxUnitTestBase}
12 */
13 function CvoxAriaUtilUnitTest() {}
14
15 CvoxAriaUtilUnitTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype,
17
18 /** @override */
19 extraLibraries: [
20 'aria_util.js',
21 'dom_util.js',
22 'node_state.js',
23 'chromevox.js',
24 '../host/interface/abstract_earcons.js']
25 };
26
27 TEST_F('CvoxAriaUtilUnitTest', 'GetStateGridWithActiveCell', function() {
28 this.loadDoc(function() {/*!
29 <div id="grid" role="grid" aria-activedescendant="cell">
30 <div role="row">
31 <div id="cell" role="gridcell">
32 </div>
33 </div>
34 */});
35 assertThat(
36 cvox.AriaUtil.getStateMsgs($('grid'), true),
37 eqJSON([['aria_role_gridcell_pos', 1, 1]]));
38 });
39
40 TEST_F('CvoxAriaUtilUnitTest', 'GetActiveDescendant', function() {
41 this.loadDoc(function() {/*!
42 <div id="top" aria-activedescendant="child">
43 <div id="child" />
44 </div>
45 <div id="top_2" aria-activedescendant="child_2">
46 <div id="child_2" aria-activedescendant="grandchild_2">
47 <div id="grandchild_2" />
48 </div>
49 </div>
50
51 <h1>The buggy cases.</h1>
52 <div id="loop" aria-activedescendant="loop" />
53 <div id="circleA" aria-activedescendant="circleB">
54 <div id="circleB" aria-activedescendant="circleA" />
55 </div>
56 */});
57
58 // The typical case.
59 var topElt = $('top');
60 var childElt = $('child');
61 assertEquals(childElt, cvox.AriaUtil.getActiveDescendant(topElt));
62
63 // childElt has not aria-activedescendant, so return null.
64 assertEquals(null, cvox.AriaUtil.getActiveDescendant(childElt));
65
66 // The chained case.
67 var top2Elt = $('top_2');
68 var grandchild2Elt = $('grandchild_2');
69 assertEquals(grandchild2Elt, cvox.AriaUtil.getActiveDescendant(top2Elt));
70
71 // The buggy cases. These are invalid, so return null as if the
72 // aria-activedescendant tags did not exist.
73 var loopElt = $('loop');
74 assertEquals(null, cvox.AriaUtil.getActiveDescendant(loopElt));
75
76 var circleAElt = $('circleA');
77 assertEquals(null, cvox.AriaUtil.getActiveDescendant(circleAElt));
78 });
79
80 TEST_F('CvoxAriaUtilUnitTest', 'ListIndexAndState', function() {
81 this.loadDoc(function() {/*!
82 <div id="l" role="listbox" tabindex="0" aria-activedescendant="l2">
83 <div id="l1" role="option">A</div>
84 <div id="l2" role="option">B</div>
85 <div id="l3" role="option">C</div>
86 </div>
87 <div id="a" role="listbox" tabindex="0" aria-activedescendant="a2">
88 <div id="a1" role="option" aria-setsize="10" aria-posinset="5">A</div>
89 <div id="a2" role="option" aria-setsize="20" aria-posinset="15">B</div>
90 <div id="a3" role="option" aria-setsize="30" aria-posinset="25">C</div>
91 </div>
92 <div id="b" role="listbox" tabindex="0" aria-activedescendant="b2">
93 <div id="b1" role="option" aria-posinset="3">A</div>
94 <div id="b2" role="option" aria-posinset="2">B</div>
95 <div id="b3" role="option" aria-posinset="1">C</div>
96 </div>
97 */});
98
99 var optionElt = $('l2');
100 assertThat(
101 cvox.AriaUtil.getStateMsgs(optionElt),
102 eqJSON([['list_position', 2, 3]]));
103
104 var ariaOptionElt = $('a2');
105 assertThat(
106 cvox.AriaUtil.getStateMsgs(ariaOptionElt),
107 eqJSON([['list_position', 15, 20]]));
108
109 ariaOptionElt = $('b3');
110 assertThat(
111 cvox.AriaUtil.getStateMsgs(ariaOptionElt),
112 eqJSON([['list_position', 1, 3]]));
113 });
114
115 TEST_F('CvoxAriaUtilUnitTest', 'GetLiveRegions', function() {
116 this.loadDoc(function() {/*!
117 <div id="outer">
118 <div id="progress" role="progressbar" aria-live="polite" aria-valuenow="1">
119 <div id="ptext">
120 1% complete.
121 </div>
122 </div>
123 <div id="progress2" role="progressbar" aria-live="polite" aria-valuenow="1">
124 <div id="ptext2">
125 1% complete.
126 </div>
127 </div>
128 </div>
129 */});
130
131 var progressLiveRegions = cvox.AriaUtil.getLiveRegions(progress);
132 assertEquals(1, progressLiveRegions.length);
133 assertNotEquals(-1, progressLiveRegions.indexOf(progress));
134
135 var outerLiveRegions = cvox.AriaUtil.getLiveRegions(outer);
136 assertEquals(2, outerLiveRegions.length);
137 assertNotEquals(-1, outerLiveRegions.indexOf(progress));
138 assertNotEquals(-1, outerLiveRegions.indexOf(progress2));
139
140 // getLiveRegions works walking up the tree as well.
141 var ptextLiveRegions = cvox.AriaUtil.getLiveRegions(ptext);
142 assertEquals(1, ptextLiveRegions.length);
143 assertNotEquals(-1, ptextLiveRegions.indexOf(progress));
144 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698