Commit e94ff17a authored by Josiah K's avatar Josiah K Committed by Commit Bot

Change runWithLoadedTree default to yield root web area node

Should be pure refactor with no functional changes (except for some minor cleanup as noted, and using just root node where desktop wasn't needed).

(Previously, runWithLoadedTree default invoked callback with desktop node)

AX-Relnotes: n/a.
Change-Id: Ib738ae4c39bf1e115878430036267baa01408201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2460234
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Auto-Submit: Josiah Krutz <josiahk@google.com>
Cr-Commit-Position: refs/heads/master@{#816368}
parent bfb7ac21
...@@ -62,9 +62,8 @@ AutoclickE2ETest = class extends E2ETestBase { ...@@ -62,9 +62,8 @@ AutoclickE2ETest = class extends E2ETestBase {
TEST_F('AutoclickE2ETest', 'HighlightsRootWebAreaIfNotScrollable', function() { TEST_F('AutoclickE2ETest', 'HighlightsRootWebAreaIfNotScrollable', function() {
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,<p>Cats rock!</p>', 'data:text/html;charset=utf-8,<p>Cats rock!</p>', async function(root) {
async function(desktop) { const node = root.find(
const node = desktop.find(
{role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}}); {role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}});
await new Promise(resolve => { await new Promise(resolve => {
this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested( this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested(
...@@ -86,8 +85,8 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() { ...@@ -86,8 +85,8 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() {
'<div style="width:100px;height:100px;overflow:scroll">' + '<div style="width:100px;height:100px;overflow:scroll">' +
'<div style="margin:50px">cats rock! this text wraps and overflows!' + '<div style="margin:50px">cats rock! this text wraps and overflows!' +
'</div></div>', '</div></div>',
async function(desktop) { async function(root) {
const node = desktop.find({ const node = root.find({
role: RoleType.STATIC_TEXT, role: RoleType.STATIC_TEXT,
attributes: {name: 'cats rock! this text wraps and overflows!'} attributes: {name: 'cats rock! this text wraps and overflows!'}
}); });
...@@ -110,8 +109,7 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() { ...@@ -110,8 +109,7 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() {
TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() { TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() {
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,<p>Cats rock!</p>', 'data:text/html;charset=utf-8,<p>Cats rock!</p>', async function(root) {
async function(desktop) {
// Turn on screen magnifier so that when we turn off autoclick, the // Turn on screen magnifier so that when we turn off autoclick, the
// extension doesn't get unloaded and crash the test. // extension doesn't get unloaded and crash the test.
await new Promise(resolve => { await new Promise(resolve => {
...@@ -126,7 +124,7 @@ TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() { ...@@ -126,7 +124,7 @@ TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() {
await new Promise(resolve => { await new Promise(resolve => {
chrome.accessibilityFeatures.autoclick.set({value: true}, resolve); chrome.accessibilityFeatures.autoclick.set({value: true}, resolve);
}); });
const node = desktop.find( const node = root.find(
{role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}}); {role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}});
await new Promise(resolve => { await new Promise(resolve => {
this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested( this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested(
......
...@@ -89,10 +89,6 @@ ChromeVoxNextE2ETest = class extends ChromeVoxE2ETest { ...@@ -89,10 +89,6 @@ ChromeVoxNextE2ETest = class extends ChromeVoxE2ETest {
/** @override */ /** @override */
runWithLoadedTree(doc, callback, opt_params = {}) { runWithLoadedTree(doc, callback, opt_params = {}) {
if (opt_params.returnPage === undefined) {
opt_params.returnPage = true;
}
callback = this.newCallback(callback); callback = this.newCallback(callback);
const wrappedCallback = (node) => { const wrappedCallback = (node) => {
CommandHandler.onCommand('nextObject'); CommandHandler.onCommand('nextObject');
......
...@@ -14,7 +14,7 @@ RepeatedTreeChangeHandlerTest = class extends ChromeVoxNextE2ETest {}; ...@@ -14,7 +14,7 @@ RepeatedTreeChangeHandlerTest = class extends ChromeVoxNextE2ETest {};
TEST_F( TEST_F(
'RepeatedTreeChangeHandlerTest', 'RepeatedTreeChangeHandledOnce', 'RepeatedTreeChangeHandlerTest', 'RepeatedTreeChangeHandledOnce',
function() { function() {
this.runWithLoadedTree('', (root) => { this.runWithLoadedDesktop(() => {
this.handlerCallCount = 0; this.handlerCallCount = 0;
const handler = () => this.handlerCallCount++; const handler = () => this.handlerCallCount++;
...@@ -34,7 +34,7 @@ TEST_F( ...@@ -34,7 +34,7 @@ TEST_F(
}); });
TEST_F('RepeatedTreeChangeHandlerTest', 'Predicate', function() { TEST_F('RepeatedTreeChangeHandlerTest', 'Predicate', function() {
this.runWithLoadedTree('', (root) => { this.runWithLoadedDesktop(() => {
this.handlerCallCount = 0; this.handlerCallCount = 0;
const handler = () => this.handlerCallCount++; const handler = () => this.handlerCallCount++;
......
...@@ -83,22 +83,33 @@ E2ETestBase = class extends testing.Test { ...@@ -83,22 +83,33 @@ E2ETestBase = class extends testing.Test {
return this.callbackHelper_.wrap(opt_callback); return this.callbackHelper_.wrap(opt_callback);
} }
/**
* Gets the desktop from the automation API and runs |callback|.
* Arranges to call |testDone()| after |callback| returns.
* NOTE: Callbacks created inside |opt_callback| must be wrapped with
* |this.newCallback| if passed to asynchronous calls. Otherwise, the test
* will be finished prematurely.
* @param {function(chrome.automation.AutomationNode)} callback
* Called with the desktop node once it's retrieved.
*/
runWithLoadedDesktop(callback) {
chrome.automation.getDesktop(this.newCallback(callback));
}
/** /**
* Gets the desktop from the automation API and Launches a new tab with * Gets the desktop from the automation API and Launches a new tab with
* the given document, and runs |callback| when a load complete fires. * the given document, and runs |callback| when a load complete fires.
* Arranges to call |testDone()| after |callback| returns. * Arranges to call |testDone()| after |callback| returns.
* NOTE: Callbacks created inside |opt_callback| must be wrapped with * NOTE: Callbacks created inside |callback| must be wrapped with
* |this.newCallback| if passed to asynchronous calls. Otherwise, the test * |this.newCallback| if passed to asynchronous calls. Otherwise, the test
* will be finished prematurely. * will be finished prematurely.
* @param {string|function(): string} doc An HTML snippet, optionally wrapped * @param {string|function(): string} doc An HTML snippet, optionally wrapped
* inside of a function. * inside of a function.
* @param {function(chrome.automation.AutomationNode)} callback * @param {function(chrome.automation.AutomationNode)} callback
* Called once the document is ready. * Called with the root web area node once the document is ready.
* @param {{url: (string=), returnPage: (boolean=)}} * @param {{url: (string=), returnDesktop: (boolean=)}}
* opt_params * opt_params
* url Optional url to wait for. Defaults to undefined. * url Optional url to wait for. Defaults to undefined.
* returnPage True if the node for the root web area should be
* returned; otherwise the desktop will be returned.
*/ */
runWithLoadedTree(doc, callback, opt_params = {}) { runWithLoadedTree(doc, callback, opt_params = {}) {
callback = this.newCallback(callback); callback = this.newCallback(callback);
...@@ -111,9 +122,10 @@ E2ETestBase = class extends testing.Test { ...@@ -111,9 +122,10 @@ E2ETestBase = class extends testing.Test {
desktop.removeEventListener('focus', listener, true); desktop.removeEventListener('focus', listener, true);
desktop.removeEventListener('loadComplete', listener, true); desktop.removeEventListener('loadComplete', listener, true);
callback && callback(opt_params.returnPage ? event.target : desktop); callback && callback(event.target);
callback = null; callback = null;
}; };
this.desktop_ = desktop; this.desktop_ = desktop;
desktop.addEventListener('focus', listener, true); desktop.addEventListener('focus', listener, true);
desktop.addEventListener('loadComplete', listener, true); desktop.addEventListener('loadComplete', listener, true);
......
...@@ -47,11 +47,11 @@ SelectToSpeakKeystrokeSelectionTest = class extends SelectToSpeakE2ETest { ...@@ -47,11 +47,11 @@ SelectToSpeakKeystrokeSelectionTest = class extends SelectToSpeakE2ETest {
* extra whitespace, after this selection is triggered. * extra whitespace, after this selection is triggered.
*/ */
testSimpleTextAtKeystroke(text, anchorOffset, focusOffset, expected) { testSimpleTextAtKeystroke(text, anchorOffset, focusOffset, expected) {
this.testReadTextAtKeystroke('<p>' + text + '</p>', function(desktop) { this.testReadTextAtKeystroke('<p>' + text + '</p>', function(root) {
// Set the document selection. This will fire the changed event // Set the document selection. This will fire the changed event
// above, allowing us to do the keystroke and test that speech // above, allowing us to do the keystroke and test that speech
// occurred properly. // occurred properly.
const textNode = this.findTextNode(desktop, 'This is some text'); const textNode = this.findTextNode(root, 'This is some text');
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: textNode, anchorObject: textNode,
anchorOffset, anchorOffset,
...@@ -78,21 +78,20 @@ SelectToSpeakKeystrokeSelectionTest = class extends SelectToSpeakE2ETest { ...@@ -78,21 +78,20 @@ SelectToSpeakKeystrokeSelectionTest = class extends SelectToSpeakE2ETest {
*/ */
testReadTextAtKeystroke(contents, setFocusCallback, expected) { testReadTextAtKeystroke(contents, setFocusCallback, expected) {
setFocusCallback = this.newCallback(setFocusCallback); setFocusCallback = this.newCallback(setFocusCallback);
this.runWithLoadedTree( this.runWithLoadedTree(contents, function(root) {
contents, function(desktop) { // Add an event listener that will start the user interaction
// Add an event listener that will start the user interaction // of the test once the selection is completed.
// of the test once the selection is completed. root.addEventListener(
desktop.addEventListener( 'documentSelectionChanged', this.newCallback(function(event) {
'documentSelectionChanged', this.newCallback(function(event) { this.triggerReadSelectedText();
this.triggerReadSelectedText(); assertTrue(this.mockTts.currentlySpeaking());
assertTrue(this.mockTts.currentlySpeaking()); assertEquals(this.mockTts.pendingUtterances().length, 1);
assertEquals(this.mockTts.pendingUtterances().length, 1); this.assertEqualsCollapseWhitespace(
this.assertEqualsCollapseWhitespace( this.mockTts.pendingUtterances()[0], expected);
this.mockTts.pendingUtterances()[0], expected); }),
}), false);
false); setFocusCallback(root);
setFocusCallback(desktop); });
});
} }
generateHtmlWithSelection(selectionCode, bodyHtml) { generateHtmlWithSelection(selectionCode, bodyHtml) {
...@@ -138,9 +137,9 @@ TEST_F( ...@@ -138,9 +137,9 @@ TEST_F(
function() { function() {
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<p>This is some <b>bold</b> text</p><p>Second paragraph</p>', '<p>This is some <b>bold</b> text</p><p>Second paragraph</p>',
function(desktop) { function(root) {
const firstNode = this.findTextNode(desktop, 'This is some '); const firstNode = this.findTextNode(root, 'This is some ');
const lastNode = this.findTextNode(desktop, ' text'); const lastNode = this.findTextNode(root, ' text');
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: firstNode, anchorObject: firstNode,
anchorOffset: 0, anchorOffset: 0,
...@@ -156,10 +155,10 @@ TEST_F( ...@@ -156,10 +155,10 @@ TEST_F(
'SpeaksAcrossNodesSelectedBackwardsAtKeystroke', function() { 'SpeaksAcrossNodesSelectedBackwardsAtKeystroke', function() {
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<p>This is some <b>bold</b> text</p><p>Second paragraph</p>', '<p>This is some <b>bold</b> text</p><p>Second paragraph</p>',
function(desktop) { function(root) {
// Set the document selection backwards in page order. // Set the document selection backwards in page order.
const lastNode = this.findTextNode(desktop, 'This is some '); const lastNode = this.findTextNode(root, 'This is some ');
const firstNode = this.findTextNode(desktop, ' text'); const firstNode = this.findTextNode(root, ' text');
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: firstNode, anchorObject: firstNode,
anchorOffset: 5, anchorOffset: 5,
...@@ -176,9 +175,9 @@ TEST_F( ...@@ -176,9 +175,9 @@ TEST_F(
// If you load this html and double-click on "Selected text", this is the // If you load this html and double-click on "Selected text", this is the
// document selection that occurs -- into the second <br/> element. // document selection that occurs -- into the second <br/> element.
let setFocusCallback = function(desktop) { let setFocusCallback = function(root) {
const firstNode = this.findTextNode(desktop, 'Selected text'); const firstNode = this.findTextNode(root, 'Selected text');
const lastNode = desktop.findAll({role: 'lineBreak'})[1]; const lastNode = root.findAll({role: 'lineBreak'})[1];
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: firstNode, anchorObject: firstNode,
anchorOffset: 0, anchorOffset: 0,
...@@ -188,10 +187,10 @@ TEST_F( ...@@ -188,10 +187,10 @@ TEST_F(
}; };
setFocusCallback = this.newCallback(setFocusCallback); setFocusCallback = this.newCallback(setFocusCallback);
this.runWithLoadedTree( this.runWithLoadedTree(
'<br/><p>Selected text</p><br/>', function(desktop) { '<br/><p>Selected text</p><br/>', function(root) {
// Add an event listener that will start the user interaction // Add an event listener that will start the user interaction
// of the test once the selection is completed. // of the test once the selection is completed.
desktop.addEventListener( root.addEventListener(
'documentSelectionChanged', this.newCallback(function(event) { 'documentSelectionChanged', this.newCallback(function(event) {
this.triggerReadSelectedText(); this.triggerReadSelectedText();
assertTrue(this.mockTts.currentlySpeaking()); assertTrue(this.mockTts.currentlySpeaking());
...@@ -203,7 +202,7 @@ TEST_F( ...@@ -203,7 +202,7 @@ TEST_F(
} }
}), }),
false); false);
setFocusCallback(desktop); setFocusCallback(root);
}); });
}); });
...@@ -212,10 +211,10 @@ TEST_F( ...@@ -212,10 +211,10 @@ TEST_F(
function() { function() {
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<div id="empty"></div><div><p>This is some <b>bold</b> text</p></div>', '<div id="empty"></div><div><p>This is some <b>bold</b> text</p></div>',
function(desktop) { function(root) {
const firstNode = const firstNode =
this.findTextNode(desktop, 'This is some ').root.children[0]; this.findTextNode(root, 'This is some ').root.children[0];
const lastNode = this.findTextNode(desktop, ' text'); const lastNode = this.findTextNode(root, ' text');
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: firstNode, anchorObject: firstNode,
anchorOffset: 0, anchorOffset: 0,
...@@ -231,10 +230,10 @@ TEST_F( ...@@ -231,10 +230,10 @@ TEST_F(
function() { function() {
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<div><p>This is some <span style="user-select:none">unselectable</span> text</p></div>', '<div><p>This is some <span style="user-select:none">unselectable</span> text</p></div>',
function(desktop) { function(root) {
const firstNode = const firstNode =
this.findTextNode(desktop, 'This is some ').root.children[0]; this.findTextNode(root, 'This is some ').root.children[0];
const lastNode = this.findTextNode(desktop, ' text'); const lastNode = this.findTextNode(root, ' text');
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: firstNode, anchorObject: firstNode,
anchorOffset: 0, anchorOffset: 0,
...@@ -249,8 +248,8 @@ TEST_F( ...@@ -249,8 +248,8 @@ TEST_F(
'SelectToSpeakKeystrokeSelectionTest', 'SelectToSpeakKeystrokeSelectionTest',
'HandlesSingleImageCorrectlyWithAutomation', function() { 'HandlesSingleImageCorrectlyWithAutomation', function() {
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<img src="pipe.jpg" alt="one"/>', function(desktop) { '<img src="pipe.jpg" alt="one"/>', function(root) {
const container = desktop.findAll({role: 'genericContainer'})[0]; const container = root.findAll({role: 'genericContainer'})[0];
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: container, anchorObject: container,
anchorOffset: 0, anchorOffset: 0,
...@@ -266,8 +265,8 @@ TEST_F( ...@@ -266,8 +265,8 @@ TEST_F(
this.testReadTextAtKeystroke( this.testReadTextAtKeystroke(
'<img src="pipe.jpg" alt="one"/>' + '<img src="pipe.jpg" alt="one"/>' +
'<img src="pipe.jpg" alt="two"/><img src="pipe.jpg" alt="three"/>', '<img src="pipe.jpg" alt="two"/><img src="pipe.jpg" alt="three"/>',
function(desktop) { function(root) {
const container = desktop.findAll({role: 'genericContainer'})[0]; const container = root.findAll({role: 'genericContainer'})[0];
chrome.automation.setDocumentSelection({ chrome.automation.setDocumentSelection({
anchorObject: container, anchorObject: container,
anchorOffset: 1, anchorOffset: 1,
......
...@@ -48,7 +48,7 @@ TEST_F('SelectToSpeakMouseSelectionTest', 'SpeaksNodeWhenClicked', function() { ...@@ -48,7 +48,7 @@ TEST_F('SelectToSpeakMouseSelectionTest', 'SpeaksNodeWhenClicked', function() {
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p>This is some text</p>', '<p>This is some text</p>',
function(desktop) { function(root) {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 0); assertEquals(this.mockTts.pendingUtterances().length, 0);
this.mockTts.setOnSpeechCallbacks( this.mockTts.setOnSpeechCallbacks(
...@@ -59,7 +59,7 @@ TEST_F('SelectToSpeakMouseSelectionTest', 'SpeaksNodeWhenClicked', function() { ...@@ -59,7 +59,7 @@ TEST_F('SelectToSpeakMouseSelectionTest', 'SpeaksNodeWhenClicked', function() {
this.assertEqualsCollapseWhitespace( this.assertEqualsCollapseWhitespace(
this.mockTts.pendingUtterances()[0], 'This is some text'); this.mockTts.pendingUtterances()[0], 'This is some text');
})]); })]);
const textNode = this.findTextNode(desktop, 'This is some text'); const textNode = this.findTextNode(root, 'This is some text');
const event = { const event = {
screenX: textNode.location.left + 1, screenX: textNode.location.left + 1,
screenY: textNode.location.top + 1 screenY: textNode.location.top + 1
...@@ -74,7 +74,7 @@ TEST_F( ...@@ -74,7 +74,7 @@ TEST_F(
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p>This is some text</p><p>This is some more text</p>', '<p>This is some text</p><p>This is some more text</p>',
function(desktop) { function(root) {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 0); assertEquals(this.mockTts.pendingUtterances().length, 0);
this.mockTts.setOnSpeechCallbacks([ this.mockTts.setOnSpeechCallbacks([
...@@ -89,13 +89,12 @@ TEST_F( ...@@ -89,13 +89,12 @@ TEST_F(
utterance, 'This is some more text'); utterance, 'This is some more text');
}) })
]); ]);
const firstNode = this.findTextNode(desktop, 'This is some text'); const firstNode = this.findTextNode(root, 'This is some text');
const downEvent = { const downEvent = {
screenX: firstNode.location.left + 1, screenX: firstNode.location.left + 1,
screenY: firstNode.location.top + 1 screenY: firstNode.location.top + 1
}; };
const lastNode = const lastNode = this.findTextNode(root, 'This is some more text');
this.findTextNode(desktop, 'This is some more text');
const upEvent = { const upEvent = {
screenX: lastNode.location.left + lastNode.location.width, screenX: lastNode.location.left + lastNode.location.width,
screenY: lastNode.location.top + lastNode.location.height screenY: lastNode.location.top + lastNode.location.height
...@@ -111,7 +110,7 @@ TEST_F( ...@@ -111,7 +110,7 @@ TEST_F(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p style="width:200px">This is some text in a paragraph that wraps. ' + '<p style="width:200px">This is some text in a paragraph that wraps. ' +
'<i>Italic text</i></p>', '<i>Italic text</i></p>',
function(desktop) { function(root) {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 0); assertEquals(this.mockTts.pendingUtterances().length, 0);
this.mockTts.setOnSpeechCallbacks( this.mockTts.setOnSpeechCallbacks(
...@@ -124,12 +123,12 @@ TEST_F( ...@@ -124,12 +123,12 @@ TEST_F(
'Italic text'); 'Italic text');
})]); })]);
const firstNode = this.findTextNode( const firstNode = this.findTextNode(
desktop, 'This is some text in a paragraph that wraps. '); root, 'This is some text in a paragraph that wraps. ');
const downEvent = { const downEvent = {
screenX: firstNode.location.left + 1, screenX: firstNode.location.left + 1,
screenY: firstNode.location.top + 1 screenY: firstNode.location.top + 1
}; };
const lastNode = this.findTextNode(desktop, 'Italic text'); const lastNode = this.findTextNode(root, 'Italic text');
const upEvent = { const upEvent = {
screenX: lastNode.location.left + lastNode.location.width, screenX: lastNode.location.left + lastNode.location.width,
screenY: lastNode.location.top + lastNode.location.height screenY: lastNode.location.top + lastNode.location.height
...@@ -144,7 +143,7 @@ TEST_F( ...@@ -144,7 +143,7 @@ TEST_F(
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p>This is some text</p>', '<p>This is some text</p>',
function(desktop) { function(root) {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
this.mockTts.setOnSpeechCallbacks( this.mockTts.setOnSpeechCallbacks(
[this.newCallback(function(utterance) { [this.newCallback(function(utterance) {
...@@ -155,13 +154,14 @@ TEST_F( ...@@ -155,13 +154,14 @@ TEST_F(
this.mockTts.pendingUtterances()[0], 'This is some text'); this.mockTts.pendingUtterances()[0], 'This is some text');
})]); })]);
const textNode = this.findTextNode(desktop, 'This is some text'); const textNode = this.findTextNode(root, 'This is some text');
const event = { const event = {
screenX: textNode.location.left + 1, screenX: textNode.location.left + 1,
screenY: textNode.location.top + 1 screenY: textNode.location.top + 1
}; };
// A state change request should shift us into 'selecting' state // A state change request should shift us into 'selecting' state
// from 'inactive'. // from 'inactive'.
const desktop = root.parent.root;
this.tapTrayButton(desktop, () => { this.tapTrayButton(desktop, () => {
selectToSpeak.fireMockMouseDownEvent(event); selectToSpeak.fireMockMouseDownEvent(event);
selectToSpeak.fireMockMouseUpEvent(event); selectToSpeak.fireMockMouseUpEvent(event);
...@@ -175,14 +175,15 @@ TEST_F( ...@@ -175,14 +175,15 @@ TEST_F(
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p>This is some text</p>', '<p>This is some text</p>',
function(desktop) { function(root) {
const textNode = this.findTextNode(desktop, 'This is some text'); const textNode = this.findTextNode(root, 'This is some text');
const event = { const event = {
screenX: textNode.location.left + 1, screenX: textNode.location.left + 1,
screenY: textNode.location.top + 1 screenY: textNode.location.top + 1
}; };
// A state change request should shift us into 'selecting' state // A state change request should shift us into 'selecting' state
// from 'inactive'. // from 'inactive'.
const desktop = root.parent.root;
this.tapTrayButton(desktop, () => { this.tapTrayButton(desktop, () => {
selectToSpeak.fireMockMouseDownEvent(event); selectToSpeak.fireMockMouseDownEvent(event);
assertEquals(SelectToSpeakState.SELECTING, selectToSpeak.state_); assertEquals(SelectToSpeakState.SELECTING, selectToSpeak.state_);
...@@ -200,7 +201,7 @@ TEST_F( ...@@ -200,7 +201,7 @@ TEST_F(
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,' + 'data:text/html;charset=utf-8,' +
'<p>This is some text</p>', '<p>This is some text</p>',
function(desktop) { function(root) {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 0); assertEquals(this.mockTts.pendingUtterances().length, 0);
this.mockTts.setOnSpeechCallbacks( this.mockTts.setOnSpeechCallbacks(
...@@ -212,6 +213,7 @@ TEST_F( ...@@ -212,6 +213,7 @@ TEST_F(
this.mockTts.pendingUtterances()[0], 'This is some text'); this.mockTts.pendingUtterances()[0], 'This is some text');
// Cancel speech and make sure state resets to INACTIVE. // Cancel speech and make sure state resets to INACTIVE.
const desktop = root.parent.root;
this.tapTrayButton(desktop, () => { this.tapTrayButton(desktop, () => {
assertFalse(this.mockTts.currentlySpeaking()); assertFalse(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 0); assertEquals(this.mockTts.pendingUtterances().length, 0);
...@@ -219,7 +221,7 @@ TEST_F( ...@@ -219,7 +221,7 @@ TEST_F(
SelectToSpeakState.INACTIVE, selectToSpeak.state_); SelectToSpeakState.INACTIVE, selectToSpeak.state_);
}); });
})]); })]);
const textNode = this.findTextNode(desktop, 'This is some text'); const textNode = this.findTextNode(root, 'This is some text');
const event = { const event = {
screenX: textNode.location.left + 1, screenX: textNode.location.left + 1,
screenY: textNode.location.top + 1 screenY: textNode.location.top + 1
...@@ -237,7 +239,7 @@ TEST_F( ...@@ -237,7 +239,7 @@ TEST_F(
// stylus may act as a laser pointer unless it taps on the stylus options // stylus may act as a laser pointer unless it taps on the stylus options
// button, which always opens on a tap regardless of the stylus behavior // button, which always opens on a tap regardless of the stylus behavior
// selected. // selected.
chrome.automation.getDesktop(this.newCallback((desktop) => { this.runWithLoadedDesktop((desktop) => {
this.tapTrayButton(desktop, () => { this.tapTrayButton(desktop, () => {
assertEquals(selectToSpeak.state_, SelectToSpeakState.SELECTING); assertEquals(selectToSpeak.state_, SelectToSpeakState.SELECTING);
const button = desktop.find({ const button = desktop.find({
...@@ -266,5 +268,5 @@ TEST_F( ...@@ -266,5 +268,5 @@ TEST_F(
selectToSpeak.fireMockMouseDownEvent(event); selectToSpeak.fireMockMouseDownEvent(event);
selectToSpeak.fireMockMouseUpEvent(event); selectToSpeak.fireMockMouseUpEvent(event);
}); });
})); });
}); });
...@@ -47,7 +47,7 @@ SwitchAccessAutoScanManagerTest = class extends SwitchAccessE2ETest { ...@@ -47,7 +47,7 @@ SwitchAccessAutoScanManagerTest = class extends SwitchAccessE2ETest {
}; };
TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabled', function() { TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabled', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedTree('', () => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running prematurely'); 'Auto scan manager is running prematurely');
...@@ -76,7 +76,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabled', function() { ...@@ -76,7 +76,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabled', function() {
}); });
TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() { TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop(() => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running prematurely'); 'Auto scan manager is running prematurely');
...@@ -94,7 +94,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() { ...@@ -94,7 +94,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() {
}); });
TEST_F('SwitchAccessAutoScanManagerTest', 'EnableAndDisable', function() { TEST_F('SwitchAccessAutoScanManagerTest', 'EnableAndDisable', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop(() => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running prematurely'); 'Auto scan manager is running prematurely');
...@@ -116,7 +116,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'EnableAndDisable', function() { ...@@ -116,7 +116,7 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'EnableAndDisable', function() {
TEST_F( TEST_F(
'SwitchAccessAutoScanManagerTest', 'RestartIfRunningMultiple', function() { 'SwitchAccessAutoScanManagerTest', 'RestartIfRunningMultiple', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop(() => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running prematurely'); 'Auto scan manager is running prematurely');
...@@ -140,7 +140,7 @@ TEST_F( ...@@ -140,7 +140,7 @@ TEST_F(
TEST_F( TEST_F(
'SwitchAccessAutoScanManagerTest', 'RestartIfRunningWhenOff', function() { 'SwitchAccessAutoScanManagerTest', 'RestartIfRunningWhenOff', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop(() => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running at start.'); 'Auto scan manager is running at start.');
...@@ -152,7 +152,7 @@ TEST_F( ...@@ -152,7 +152,7 @@ TEST_F(
}); });
TEST_F('SwitchAccessAutoScanManagerTest', 'SetPrimaryScanTime', function() { TEST_F('SwitchAccessAutoScanManagerTest', 'SetPrimaryScanTime', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop(() => {
assertFalse( assertFalse(
AutoScanManager.instance.isRunning_(), AutoScanManager.instance.isRunning_(),
'Auto scan manager is running prematurely'); 'Auto scan manager is running prematurely');
......
...@@ -42,7 +42,8 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveTo', function() { ...@@ -42,7 +42,8 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveTo', function() {
</div> </div>
<button></button> <button></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
const desktop = root.parent.root;
const textFields = const textFields =
desktop.findAll({role: chrome.automation.RoleType.TEXT_FIELD}); desktop.findAll({role: chrome.automation.RoleType.TEXT_FIELD});
assertEquals(2, textFields.length, 'Should be exactly 2 text fields.'); assertEquals(2, textFields.length, 'Should be exactly 2 text fields.');
...@@ -105,7 +106,8 @@ TEST_F('SwitchAccessNavigationManagerTest', 'JumpTo', function() { ...@@ -105,7 +106,8 @@ TEST_F('SwitchAccessNavigationManagerTest', 'JumpTo', function() {
<button></button> <button></button>
<button></button> <button></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
const desktop = root.parent.root;
const textInput = const textInput =
desktop.findAll({role: chrome.automation.RoleType.TEXT_FIELD})[1]; desktop.findAll({role: chrome.automation.RoleType.TEXT_FIELD})[1];
assertNotNullNorUndefined(textInput, 'Text field is undefined'); assertNotNullNorUndefined(textInput, 'Text field is undefined');
...@@ -163,7 +165,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'SelectButton', function() { ...@@ -163,7 +165,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'SelectButton', function() {
})); }));
NavigationManager.instance.node_.performAction('select'); NavigationManager.instance.node_.performAction('select');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessNavigationManagerTest', 'EnterGroup', function() { TEST_F('SwitchAccessNavigationManagerTest', 'EnterGroup', function() {
...@@ -172,7 +174,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'EnterGroup', function() { ...@@ -172,7 +174,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'EnterGroup', function() {
<button></button> <button></button>
</div> </div>
<input type="range">`; <input type="range">`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
const targetGroup = this.findNodeById('group'); const targetGroup = this.findNodeById('group');
this.navigator.moveTo_(targetGroup); this.navigator.moveTo_(targetGroup);
...@@ -202,7 +204,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveForward', function() { ...@@ -202,7 +204,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveForward', function() {
<button id="button2"></button> <button id="button2"></button>
<button id="button3"></button> <button id="button3"></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
this.navigator.moveTo_(this.findNodeById('button1')); this.navigator.moveTo_(this.findNodeById('button1'));
const button1 = this.navigator.node_; const button1 = this.navigator.node_;
assertFalse( assertFalse(
...@@ -257,7 +259,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveBackward', function() { ...@@ -257,7 +259,7 @@ TEST_F('SwitchAccessNavigationManagerTest', 'MoveBackward', function() {
<button id="button2"></button> <button id="button2"></button>
<button id="button3"></button> <button id="button3"></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
this.navigator.moveTo_(this.findNodeById('button1')); this.navigator.moveTo_(this.findNodeById('button1'));
const button1 = this.navigator.node_; const button1 = this.navigator.node_;
assertFalse( assertFalse(
...@@ -310,7 +312,7 @@ TEST_F( ...@@ -310,7 +312,7 @@ TEST_F(
const website = `<div> const website = `<div>
<button id="button1"></button> <button id="button1"></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
this.navigator.moveTo_(this.findNodeById('button1')); this.navigator.moveTo_(this.findNodeById('button1'));
const button1 = this.navigator.node_; const button1 = this.navigator.node_;
assertFalse( assertFalse(
......
...@@ -15,8 +15,8 @@ TEST_F('SwitchAccessBasicNodeTest', 'AsRootNode', function() { ...@@ -15,8 +15,8 @@ TEST_F('SwitchAccessBasicNodeTest', 'AsRootNode', function() {
</div> </div>
<button></button> <button></button>
</div>`; </div>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
const slider = desktop.find({role: chrome.automation.RoleType.SLIDER}); const slider = root.find({role: chrome.automation.RoleType.SLIDER});
const inner = slider.parent; const inner = slider.parent;
assertNotEquals(undefined, inner, 'Could not find inner group'); assertNotEquals(undefined, inner, 'Could not find inner group');
const outer = inner.parent; const outer = inner.parent;
...@@ -42,7 +42,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'AsRootNode', function() { ...@@ -42,7 +42,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'AsRootNode', function() {
}); });
TEST_F('SwitchAccessBasicNodeTest', 'Equals', function() { TEST_F('SwitchAccessBasicNodeTest', 'Equals', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop((desktop) => {
const desktopNode = DesktopNode.build(desktop); const desktopNode = DesktopNode.build(desktop);
let childGroup = desktopNode.firstChild; let childGroup = desktopNode.firstChild;
...@@ -115,9 +115,9 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() { ...@@ -115,9 +115,9 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() {
const website = `<input type="text"> const website = `<input type="text">
<button></button> <button></button>
<input type="range" min=1 max=5 value=3>`; <input type="range" min=1 max=5 value=3>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (root) => {
const textField = BasicNode.create( const textField = BasicNode.create(
desktop.find({role: chrome.automation.RoleType.TEXT_FIELD}), root.find({role: chrome.automation.RoleType.TEXT_FIELD}),
new SARootNode()); new SARootNode());
assertEquals( assertEquals(
...@@ -134,8 +134,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() { ...@@ -134,8 +134,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() {
'Text field has action SELECT'); 'Text field has action SELECT');
const button = BasicNode.create( const button = BasicNode.create(
desktop.find({role: chrome.automation.RoleType.BUTTON}), root.find({role: chrome.automation.RoleType.BUTTON}), new SARootNode());
new SARootNode());
assertEquals( assertEquals(
chrome.automation.RoleType.BUTTON, button.role, chrome.automation.RoleType.BUTTON, button.role,
...@@ -151,8 +150,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() { ...@@ -151,8 +150,7 @@ TEST_F('SwitchAccessBasicNodeTest', 'Actions', function() {
'Button has action DICTATION'); 'Button has action DICTATION');
const slider = BasicNode.create( const slider = BasicNode.create(
desktop.find({role: chrome.automation.RoleType.SLIDER}), root.find({role: chrome.automation.RoleType.SLIDER}), new SARootNode());
new SARootNode());
assertEquals( assertEquals(
chrome.automation.RoleType.SLIDER, slider.role, chrome.automation.RoleType.SLIDER, slider.role,
......
...@@ -8,7 +8,7 @@ GEN_INCLUDE(['../switch_access_e2e_test_base.js']); ...@@ -8,7 +8,7 @@ GEN_INCLUDE(['../switch_access_e2e_test_base.js']);
SwitchAccessDesktopNodeTest = class extends SwitchAccessE2ETest {}; SwitchAccessDesktopNodeTest = class extends SwitchAccessE2ETest {};
TEST_F('SwitchAccessDesktopNodeTest', 'Build', function() { TEST_F('SwitchAccessDesktopNodeTest', 'Build', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop((desktop) => {
const desktopNode = DesktopNode.build(desktop); const desktopNode = DesktopNode.build(desktop);
const children = desktopNode.children; const children = desktopNode.children;
......
...@@ -9,11 +9,11 @@ SwitchAccessGroupNodeTest = class extends SwitchAccessE2ETest {}; ...@@ -9,11 +9,11 @@ SwitchAccessGroupNodeTest = class extends SwitchAccessE2ETest {};
TEST_F('SwitchAccessGroupNodeTest', 'NodesRemoved', function() { TEST_F('SwitchAccessGroupNodeTest', 'NodesRemoved', function() {
const website = `<button></button>`; const website = `<button></button>`;
this.runWithLoadedTree(website, (desktop) => { this.runWithLoadedTree(website, (rootNode) => {
const button = desktop.find({role: chrome.automation.RoleType.BUTTON}); const button = rootNode.find({role: chrome.automation.RoleType.BUTTON});
assertNotEquals(undefined, button); assertNotEquals(undefined, button);
const root = new BasicRootNode(desktop); const root = new BasicRootNode(rootNode);
assertEquals(0, root.children_.length); assertEquals(0, root.children_.length);
// Add a group child which has two buttons (same underlying automation // Add a group child which has two buttons (same underlying automation
......
...@@ -8,7 +8,7 @@ GEN_INCLUDE(['../switch_access_e2e_test_base.js']); ...@@ -8,7 +8,7 @@ GEN_INCLUDE(['../switch_access_e2e_test_base.js']);
SwitchAccessTabNodeTest = class extends SwitchAccessE2ETest {}; SwitchAccessTabNodeTest = class extends SwitchAccessE2ETest {};
TEST_F('SwitchAccessTabNodeTest', 'FindCloseButton', function() { TEST_F('SwitchAccessTabNodeTest', 'FindCloseButton', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop((desktop) => {
const tab = desktop.find({role: chrome.automation.RoleType.TAB}); const tab = desktop.find({role: chrome.automation.RoleType.TAB});
// To find the close button, Switch Access relies on it being the only // To find the close button, Switch Access relies on it being the only
...@@ -24,7 +24,7 @@ TEST_F('SwitchAccessTabNodeTest', 'FindCloseButton', function() { ...@@ -24,7 +24,7 @@ TEST_F('SwitchAccessTabNodeTest', 'FindCloseButton', function() {
}); });
TEST_F('SwitchAccessTabNodeTest', 'Construction', function() { TEST_F('SwitchAccessTabNodeTest', 'Construction', function() {
this.runWithLoadedTree('', (desktop) => { this.runWithLoadedDesktop((desktop) => {
NavigationManager.instance.moveTo_( NavigationManager.instance.moveTo_(
desktop.find({role: chrome.automation.RoleType.TAB})); desktop.find({role: chrome.automation.RoleType.TAB}));
......
...@@ -128,7 +128,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsInteresting', function() { ...@@ -128,7 +128,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsInteresting', function() {
assertFalse( assertFalse(
SwitchAccessPredicate.isInteresting(t.leaf7, null, cache), SwitchAccessPredicate.isInteresting(t.leaf7, null, cache),
'Leaf7 should not be interesting'); 'Leaf7 should not be interesting');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'IsGroup', function() { TEST_F('SwitchAccessPredicateTest', 'IsGroup', function() {
...@@ -178,7 +178,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsGroup', function() { ...@@ -178,7 +178,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsGroup', function() {
assertFalse( assertFalse(
SwitchAccessPredicate.isGroup(t.leaf7, null, cache), SwitchAccessPredicate.isGroup(t.leaf7, null, cache),
'Leaf7 should not be a group'); 'Leaf7 should not be a group');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'IsInterestingSubtree', function() { TEST_F('SwitchAccessPredicateTest', 'IsInterestingSubtree', function() {
...@@ -225,7 +225,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsInterestingSubtree', function() { ...@@ -225,7 +225,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsInterestingSubtree', function() {
assertFalse( assertFalse(
SwitchAccessPredicate.isInterestingSubtree(t.leaf7, cache), SwitchAccessPredicate.isInterestingSubtree(t.leaf7, cache),
'Leaf7 should not be an interesting subtree'); 'Leaf7 should not be an interesting subtree');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() { TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() {
...@@ -238,7 +238,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() { ...@@ -238,7 +238,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() {
<input type="range" aria-label="slider" value=5 min=0 max=10> <input type="range" aria-label="slider" value=5 min=0 max=10>
<div id="clickable" role="listitem" onclick="2+2"></div> <div id="clickable" role="listitem" onclick="2+2"></div>
<div aria-label="div1"><p>p1</p></div>`; <div aria-label="div1"><p>p1</p></div>`;
this.runWithLoadedTree(treeString, (desktop) => { this.runWithLoadedTree(treeString, (loadedPage) => {
const cache = new SACache(); const cache = new SACache();
const offscreenButton = this.findNodeByNameAndRole('offscreen', 'button'); const offscreenButton = this.findNodeByNameAndRole('offscreen', 'button');
...@@ -251,13 +251,9 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() { ...@@ -251,13 +251,9 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionable', function() {
SwitchAccessPredicate.isActionable(disabledButton, cache), SwitchAccessPredicate.isActionable(disabledButton, cache),
'Disabled objects should not be actionable'); 'Disabled objects should not be actionable');
const rwas = assertFalse(
desktop.findAll({role: chrome.automation.RoleType.ROOT_WEB_AREA}); SwitchAccessPredicate.isActionable(loadedPage, cache),
for (const node of rwas) { 'Root web area should not be directly actionable');
assertFalse(
SwitchAccessPredicate.isActionable(node, cache),
'Root web area should not be directly actionable');
}
const link1 = this.findNodeByNameAndRole('link1', 'link'); const link1 = this.findNodeByNameAndRole('link1', 'link');
assertTrue( assertTrue(
...@@ -318,7 +314,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionableFocusableElements', function() ...@@ -318,7 +314,7 @@ TEST_F('SwitchAccessPredicateTest', 'IsActionableFocusableElements', function()
<p>p2</p> <p>p2</p>
<p>p3</p> <p>p3</p>
</div>`; </div>`;
this.runWithLoadedTree(treeString, (desktop) => { this.runWithLoadedTree(treeString, (loadedPage) => {
const cache = new SACache(); const cache = new SACache();
const noChildren = this.findNodeById('noChildren'); const noChildren = this.findNodeById('noChildren');
...@@ -372,7 +368,7 @@ TEST_F('SwitchAccessPredicateTest', 'LeafPredicate', function() { ...@@ -372,7 +368,7 @@ TEST_F('SwitchAccessPredicateTest', 'LeafPredicate', function() {
assertTrue(leaf(t.leaf1), 'Leaf1 should be a leaf for lower1 tree'); assertTrue(leaf(t.leaf1), 'Leaf1 should be a leaf for lower1 tree');
assertTrue(leaf(t.leaf2), 'Leaf2 should be a leaf for lower1 tree'); assertTrue(leaf(t.leaf2), 'Leaf2 should be a leaf for lower1 tree');
assertTrue(leaf(t.leaf3), 'Leaf3 should be a leaf for lower1 tree'); assertTrue(leaf(t.leaf3), 'Leaf3 should be a leaf for lower1 tree');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'RootPredicate', function() { TEST_F('SwitchAccessPredicateTest', 'RootPredicate', function() {
...@@ -399,7 +395,7 @@ TEST_F('SwitchAccessPredicateTest', 'RootPredicate', function() { ...@@ -399,7 +395,7 @@ TEST_F('SwitchAccessPredicateTest', 'RootPredicate', function() {
assertFalse(root(t.leaf1), 'Leaf1 should not be a root of the lower1 tree'); assertFalse(root(t.leaf1), 'Leaf1 should not be a root of the lower1 tree');
assertFalse(root(t.leaf2), 'Leaf2 should not be a root of the lower1 tree'); assertFalse(root(t.leaf2), 'Leaf2 should not be a root of the lower1 tree');
assertFalse(root(t.leaf3), 'Leaf3 should not be a root of the lower1 tree'); assertFalse(root(t.leaf3), 'Leaf3 should not be a root of the lower1 tree');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'VisitPredicate', function() { TEST_F('SwitchAccessPredicateTest', 'VisitPredicate', function() {
...@@ -432,7 +428,7 @@ TEST_F('SwitchAccessPredicateTest', 'VisitPredicate', function() { ...@@ -432,7 +428,7 @@ TEST_F('SwitchAccessPredicateTest', 'VisitPredicate', function() {
assertFalse(visit(t.lower3), 'Lower3 should not be visited in lower1 tree'); assertFalse(visit(t.lower3), 'Lower3 should not be visited in lower1 tree');
assertFalse(visit(t.leaf6), 'Leaf6 should not be visited in lower1 tree'); assertFalse(visit(t.leaf6), 'Leaf6 should not be visited in lower1 tree');
assertFalse(visit(t.leaf7), 'Leaf7 should not be visited in lower1 tree'); assertFalse(visit(t.leaf7), 'Leaf7 should not be visited in lower1 tree');
}, {returnPage: true}); });
}); });
TEST_F('SwitchAccessPredicateTest', 'Cache', function() { TEST_F('SwitchAccessPredicateTest', 'Cache', function() {
...@@ -476,5 +472,5 @@ TEST_F('SwitchAccessPredicateTest', 'Cache', function() { ...@@ -476,5 +472,5 @@ TEST_F('SwitchAccessPredicateTest', 'Cache', function() {
assertEquals( assertEquals(
locationAccessCount, 1, locationAccessCount, 1,
'Cache should have been used, avoiding second location access'); 'Cache should have been used, avoiding second location access');
}, {returnPage: true}); });
}); });
...@@ -45,7 +45,7 @@ function runTextNavigationTest(testHelper, textParams) { ...@@ -45,7 +45,7 @@ function runTextNavigationTest(testHelper, textParams) {
const website = generateWebsiteWithTextArea( const website = generateWebsiteWithTextArea(
textId, textContent, initialTextIndex, textCols, textWrap); textId, textContent, initialTextIndex, textCols, textWrap);
testHelper.runWithLoadedTree(website, function(desktop) { testHelper.runWithLoadedTree(website, function(root) {
const inputNode = this.findNodeById(textId); const inputNode = this.findNodeById(textId);
assertNotEquals(inputNode, null); assertNotEquals(inputNode, null);
...@@ -104,7 +104,7 @@ function runTextSelectionTest(testHelper, textParams) { ...@@ -104,7 +104,7 @@ function runTextSelectionTest(testHelper, textParams) {
navigationTargetIndex = targetTextStartIndex; navigationTargetIndex = targetTextStartIndex;
} }
testHelper.runWithLoadedTree(website, function(desktop) { testHelper.runWithLoadedTree(website, function(root) {
const inputNode = this.findNodeById(textId); const inputNode = this.findNodeById(textId);
assertNotEquals(inputNode, null); assertNotEquals(inputNode, null);
checkNodeIsFocused(inputNode); checkNodeIsFocused(inputNode);
...@@ -314,7 +314,7 @@ TEST_F( ...@@ -314,7 +314,7 @@ TEST_F(
const website = const website =
generateWebsiteWithTextArea('test', 'test123', 3, 20, 'hard'); generateWebsiteWithTextArea('test', 'test123', 3, 20, 'hard');
this.runWithLoadedTree(website, function(desktop) { this.runWithLoadedTree(website, function(root) {
const inputNode = this.findNodeById('test'); const inputNode = this.findNodeById('test');
assertNotEquals(inputNode, null); assertNotEquals(inputNode, null);
checkNodeIsFocused(inputNode); checkNodeIsFocused(inputNode);
...@@ -335,7 +335,7 @@ TEST_F( ...@@ -335,7 +335,7 @@ TEST_F(
const website = const website =
generateWebsiteWithTextArea('test', 'test 123', 6, 20, 'hard'); generateWebsiteWithTextArea('test', 'test 123', 6, 20, 'hard');
this.runWithLoadedTree(website, function(desktop) { this.runWithLoadedTree(website, function(root) {
const inputNode = this.findNodeById('test'); const inputNode = this.findNodeById('test');
assertNotEquals(inputNode, null); assertNotEquals(inputNode, null);
checkNodeIsFocused(inputNode); checkNodeIsFocused(inputNode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment