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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs

Issue 2092743002: Revert of Make ChromeVox Next a setting in options page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
index 82ed14ec140feec0c0cc37f1b92f5f03e2a297f0..91534f1953c7fd06e9b70bab628903849b8d6076 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
@@ -22,7 +22,7 @@
/** @override */
setUp: function() {
- ChromeVoxState.instance.toggleNext(true);
+ global.backgroundObj.forceChromeVoxNextActive();
window.RoleType = chrome.automation.RoleType;
window.doCmd = this.doCmd;
},
@@ -44,7 +44,7 @@
*/
doCmd: function(cmd) {
return function() {
- ChromeVoxState.instance.onGotCommand(cmd);
+ global.backgroundObj.onGotCommand(cmd);
};
},
@@ -251,7 +251,9 @@
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree('<a href="a">a</a>',
function(rootNode) {
- mockFeedback.expectSpeech('a')
+ mockFeedback.expectSpeech('data:text/html,<!doctype html>' +
+ '<a href="a">a</a>')
+ .expectSpeech('a')
.expectSpeech('Link');
mockFeedback.replay();
});
@@ -272,7 +274,7 @@
TEST_F('BackgroundTest', 'ShowContextMenu', function() {
var mockFeedback = this.createMockFeedback();
- this.runWithLoadedTree('<p>before</p><a href="a">a</a>',
+ this.runWithLoadedTree('<a href="a">a</a>',
function(rootNode) {
mockFeedback.expectSpeech(/menu opened/)
.call(function() {
@@ -294,7 +296,7 @@
TEST_F('BackgroundTest', 'BrailleRouting', function() {
var mockFeedback = this.createMockFeedback();
var route = function(position) {
- assertTrue(ChromeVoxState.instance.onBrailleKeyEvent(
+ assertTrue(global.backgroundObj.onBrailleKeyEvent(
{command: cvox.BrailleKeyCommand.ROUTING,
displayPosition: position},
mockFeedback.lastMatchedBraille));
@@ -367,12 +369,11 @@
function(rootNode) {
var assertExists = this.newCallback(function (evt) {
assertNotNullNorUndefined(
- ChromeVoxState.desktopAutomationHandler.textEditHandler_);
+ global.desktopAutomationHandler.textEditHandler_);
evt.stopPropagation();
});
var assertDoesntExist = this.newCallback(function (evt) {
- assertTrue(
- !ChromeVoxState.desktopAutomationHandler.editableTextHandler_);
+ assertTrue(!global.desktopAutomationHandler.editableTextHandler_);
evt.stopPropagation();
});
@@ -434,7 +435,7 @@
TEST_F('BackgroundTest', 'ToggleChromeVoxVersion', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.linksAndHeadingsDoc, function() {
- var gotCmd = ChromeVoxState.instance.onGotCommand;
+ var gotCmd = global.backgroundObj.onGotCommand;
// The command came from the background keyboard handler.
var togglerFromBackground = gotCmd.bind(gotCmd, 'toggleChromeVoxVersion');
@@ -444,11 +445,11 @@
true);
mockFeedback.call(togglerFromBackground)
- .expectSpeech('Switched to Classic ChromeVox')
+ .expectSpeech('classic')
.call(togglerFromContent)
- .expectSpeech('Switched to ChromeVox Next')
+ .expectSpeech('next')
.call(togglerFromBackground)
- .expectSpeech('Switched to Classic ChromeVox');
+ .expectSpeech('classic');
mockFeedback.replay();
});
});
@@ -510,55 +511,54 @@
var fakeWebRoot = {};
fakeWebRoot.root = fakeWebRoot;
fakeWebRoot.parent = fakeDesktop;
- fakeWebRoot.role = RoleType.rootWebArea;
- fakeWebRoot.makeVisible = function() {};
- fakeWebRoot.location = {left: 1, top: 1, width: 1, height: 1};
+ fakeWebRoot.role = 'rootWebArea';
var fakeSubRoot = {};
fakeSubRoot.root = fakeSubRoot;
fakeSubRoot.parent = fakeWebRoot;
- fakeSubRoot.role = RoleType.rootWebArea;
- fakeSubRoot.makeVisible = function() {};
- fakeSubRoot.location = {left: 1, top: 1, width: 1, height: 1};
- var bk = ChromeVoxState.instance;
+ fakeSubRoot.role = 'rootWebArea';
// Tests default to force next mode.
- assertEquals('force_next', bk.mode);
+ assertEquals('force_next', global.backgroundObj.mode);
// Force next mode stays set regardless of where the range lands.
fakeWebRoot.docUrl = 'http://google.com';
- bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
- assertEquals('force_next', bk.mode);
+ global.backgroundObj.refreshMode(fakeWebRoot);
+ assertEquals('force_next', global.backgroundObj.mode);
// Empty urls occur before document load or when root is desktop.
fakeWebRoot.docUrl = '';
- bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
- assertEquals('force_next', bk.mode);
-
- // Verify force next -> compat switching.
- localStorage['useNext'] = false;
- fakeWebRoot.docUrl = 'chrome://foobar';
- bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
- assertEquals('compat', bk.mode);
-
- // Compat -> classic.
+ global.backgroundObj.refreshMode(fakeWebRoot);
+ assertEquals('force_next', global.backgroundObj.mode);
+
+ // Verify compat -> classic switching.
+ global.backgroundObj.setMode('compat');
fakeWebRoot.docUrl = 'http://google.com';
- bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
- assertEquals('classic', bk.mode);
+ global.backgroundObj.refreshMode(fakeWebRoot);
+ assertEquals('classic', global.backgroundObj.mode);
// Ensure we switch to compat if our current range has focused
// state set and is not in web content.
assertTrue(root.parent.state.focused);
- bk.setCurrentRange(cursors.Range.fromNode(root.parent));
- assertEquals('compat', bk.mode);
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent));
+ global.backgroundObj.refreshMode(root.parent);
+ assertEquals('compat', global.backgroundObj.mode);
// And back to classic.
- bk.setCurrentRange(cursors.Range.fromNode(root));
- assertEquals('classic', bk.mode);
-
- // Now, verify mode switching uses the top level root.
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root));
+ global.backgroundObj.refreshMode(fakeWebRoot);
+ assertEquals('classic', global.backgroundObj.mode);
+
+ // Now, try refreshing mode (which we call after tab switching) with a range
+ // that's not actually focused.
+ assertEquals(undefined, root.parent.parent.state.focused);
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent.parent));
+ global.backgroundObj.refreshMode(root.parent.parent);
+ assertEquals('classic', global.backgroundObj.mode);
+
+ // Now, verify mode refreshes uses the top level root.
fakeWebRoot.docUrl = 'http://google.com/#chromevox_next_test';
fakeSubRoot.docUrl = 'http://chromevox.com';
- bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
- assertEquals('next', bk.mode);
+ global.backgroundObj.refreshMode(fakeSubRoot);
+ assertEquals('next', global.backgroundObj.mode);
}.bind(this));
});
@@ -577,7 +577,7 @@
iframe.focus = function() {
didFocus = true;
};
- var b = ChromeVoxState.instance;
+ var b = global.backgroundObj;
b.currentRange_ = cursors.Range.fromNode(button);
b.onGotCommand('previousElement');
assertFalse(didFocus);
@@ -629,12 +629,7 @@
*/}, function(root) {
var cbx = root.find({role: RoleType.checkBox});
var click = cbx.doDefault.bind(cbx);
- var focus = cbx.focus.bind(cbx);
- mockFeedback.call(focus)
- .expectSpeech('go')
- .expectSpeech('Check box')
- .expectSpeech('not checked')
- .call(click)
+ mockFeedback.call(click)
.expectSpeech('go')
.expectSpeech('Check box')
.expectSpeech('checked')
@@ -765,7 +760,7 @@
<div aria-pressed="false" role="button">cancel</div>
<div aria-pressed role="button">close</div>
*/}, function(root) {
- var b = ChromeVoxState.instance;
+ var b = global.backgroundObj;
var move = b.onGotCommand.bind(b, 'nextObject');
mockFeedback.call(move)
.expectSpeech('ok')

Powered by Google App Engine
This is Rietveld 408576698