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