| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Include test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
| 7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
| 8 | 8 |
| 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); | 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Test fixture for Background. | 12 * Test fixture for Background. |
| 13 * @constructor | 13 * @constructor |
| 14 * @extends {ChromeVoxNextE2ETest} | 14 * @extends {ChromeVoxNextE2ETest} |
| 15 */ | 15 */ |
| 16 function BackgroundTest() { | 16 function BackgroundTest() { |
| 17 ChromeVoxNextE2ETest.call(this); | 17 ChromeVoxNextE2ETest.call(this); |
| 18 } | 18 } |
| 19 | 19 |
| 20 BackgroundTest.prototype = { | 20 BackgroundTest.prototype = { |
| 21 __proto__: ChromeVoxNextE2ETest.prototype, | 21 __proto__: ChromeVoxNextE2ETest.prototype, |
| 22 | 22 |
| 23 /** @override */ | 23 /** @override */ |
| 24 setUp: function() { | 24 setUp: function() { |
| 25 ChromeVoxState.instance.toggleNext(true); | 25 global.backgroundObj.forceChromeVoxNextActive(); |
| 26 window.RoleType = chrome.automation.RoleType; | 26 window.RoleType = chrome.automation.RoleType; |
| 27 window.doCmd = this.doCmd; | 27 window.doCmd = this.doCmd; |
| 28 }, | 28 }, |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @return {!MockFeedback} | 31 * @return {!MockFeedback} |
| 32 */ | 32 */ |
| 33 createMockFeedback: function() { | 33 createMockFeedback: function() { |
| 34 var mockFeedback = new MockFeedback(this.newCallback(), | 34 var mockFeedback = new MockFeedback(this.newCallback(), |
| 35 this.newCallback.bind(this)); | 35 this.newCallback.bind(this)); |
| 36 mockFeedback.install(); | 36 mockFeedback.install(); |
| 37 return mockFeedback; | 37 return mockFeedback; |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Create a function which perform the command |cmd|. | 41 * Create a function which perform the command |cmd|. |
| 42 * @param {string} cmd | 42 * @param {string} cmd |
| 43 * @return {function() : void} | 43 * @return {function() : void} |
| 44 */ | 44 */ |
| 45 doCmd: function(cmd) { | 45 doCmd: function(cmd) { |
| 46 return function() { | 46 return function() { |
| 47 ChromeVoxState.instance.onGotCommand(cmd); | 47 global.backgroundObj.onGotCommand(cmd); |
| 48 }; | 48 }; |
| 49 }, | 49 }, |
| 50 | 50 |
| 51 linksAndHeadingsDoc: function() {/*! | 51 linksAndHeadingsDoc: function() {/*! |
| 52 <p>start</p> | 52 <p>start</p> |
| 53 <a href='#a'>alpha</a> | 53 <a href='#a'>alpha</a> |
| 54 <a href='#b'>beta</a> | 54 <a href='#b'>beta</a> |
| 55 <p> | 55 <p> |
| 56 <h1>charlie</h1> | 56 <h1>charlie</h1> |
| 57 <a href='foo'>delta</a> | 57 <a href='foo'>delta</a> |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 'beta', 'Link', | 244 'beta', 'Link', |
| 245 'charlie', 'Heading 1'); | 245 'charlie', 'Heading 1'); |
| 246 mockFeedback.replay(); | 246 mockFeedback.replay(); |
| 247 }); | 247 }); |
| 248 }); | 248 }); |
| 249 | 249 |
| 250 TEST_F('BackgroundTest', 'InitialFocus', function() { | 250 TEST_F('BackgroundTest', 'InitialFocus', function() { |
| 251 var mockFeedback = this.createMockFeedback(); | 251 var mockFeedback = this.createMockFeedback(); |
| 252 this.runWithLoadedTree('<a href="a">a</a>', | 252 this.runWithLoadedTree('<a href="a">a</a>', |
| 253 function(rootNode) { | 253 function(rootNode) { |
| 254 mockFeedback.expectSpeech('a') | 254 mockFeedback.expectSpeech('data:text/html,<!doctype html>' + |
| 255 '<a href="a">a</a>') |
| 256 .expectSpeech('a') |
| 255 .expectSpeech('Link'); | 257 .expectSpeech('Link'); |
| 256 mockFeedback.replay(); | 258 mockFeedback.replay(); |
| 257 }); | 259 }); |
| 258 }); | 260 }); |
| 259 | 261 |
| 260 TEST_F('BackgroundTest', 'AriaLabel', function() { | 262 TEST_F('BackgroundTest', 'AriaLabel', function() { |
| 261 var mockFeedback = this.createMockFeedback(); | 263 var mockFeedback = this.createMockFeedback(); |
| 262 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', | 264 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', |
| 263 function(rootNode) { | 265 function(rootNode) { |
| 264 rootNode.find({role: RoleType.link}).focus(); | 266 rootNode.find({role: RoleType.link}).focus(); |
| 265 mockFeedback.expectSpeech('foo') | 267 mockFeedback.expectSpeech('foo') |
| 266 .expectSpeech('Link') | 268 .expectSpeech('Link') |
| 267 .expectBraille('foo lnk'); | 269 .expectBraille('foo lnk'); |
| 268 mockFeedback.replay(); | 270 mockFeedback.replay(); |
| 269 } | 271 } |
| 270 ); | 272 ); |
| 271 }); | 273 }); |
| 272 | 274 |
| 273 TEST_F('BackgroundTest', 'ShowContextMenu', function() { | 275 TEST_F('BackgroundTest', 'ShowContextMenu', function() { |
| 274 var mockFeedback = this.createMockFeedback(); | 276 var mockFeedback = this.createMockFeedback(); |
| 275 this.runWithLoadedTree('<p>before</p><a href="a">a</a>', | 277 this.runWithLoadedTree('<a href="a">a</a>', |
| 276 function(rootNode) { | 278 function(rootNode) { |
| 277 mockFeedback.expectSpeech(/menu opened/) | 279 mockFeedback.expectSpeech(/menu opened/) |
| 278 .call(function() { | 280 .call(function() { |
| 279 // When shown, the context menu pushes a new message loop so test | 281 // When shown, the context menu pushes a new message loop so test |
| 280 // messages sent to the browser do not get processed. Ensure we | 282 // messages sent to the browser do not get processed. Ensure we |
| 281 // exit the context menu here. | 283 // exit the context menu here. |
| 282 go.showContextMenu(); | 284 go.showContextMenu(); |
| 283 }); | 285 }); |
| 284 mockFeedback.replay(); | 286 mockFeedback.replay(); |
| 285 | 287 |
| 286 var go = rootNode.find({ role: RoleType.link }); | 288 var go = rootNode.find({ role: RoleType.link }); |
| 287 this.listenOnce(go, 'focus', function(e) { | 289 this.listenOnce(go, 'focus', function(e) { |
| 288 doCmd('contextMenu')(); | 290 doCmd('contextMenu')(); |
| 289 }.bind(this), true); | 291 }.bind(this), true); |
| 290 go.focus(); | 292 go.focus(); |
| 291 }.bind(this)); | 293 }.bind(this)); |
| 292 }); | 294 }); |
| 293 | 295 |
| 294 TEST_F('BackgroundTest', 'BrailleRouting', function() { | 296 TEST_F('BackgroundTest', 'BrailleRouting', function() { |
| 295 var mockFeedback = this.createMockFeedback(); | 297 var mockFeedback = this.createMockFeedback(); |
| 296 var route = function(position) { | 298 var route = function(position) { |
| 297 assertTrue(ChromeVoxState.instance.onBrailleKeyEvent( | 299 assertTrue(global.backgroundObj.onBrailleKeyEvent( |
| 298 {command: cvox.BrailleKeyCommand.ROUTING, | 300 {command: cvox.BrailleKeyCommand.ROUTING, |
| 299 displayPosition: position}, | 301 displayPosition: position}, |
| 300 mockFeedback.lastMatchedBraille)); | 302 mockFeedback.lastMatchedBraille)); |
| 301 }; | 303 }; |
| 302 this.runWithLoadedTree( | 304 this.runWithLoadedTree( |
| 303 function() {/*! | 305 function() {/*! |
| 304 <p>start</p> | 306 <p>start</p> |
| 305 <button id="btn1">Click me</button> | 307 <button id="btn1">Click me</button> |
| 306 <p>Some text</p> | 308 <p>Some text</p> |
| 307 <button id="btn2">Focus me</button> | 309 <button id="btn2">Focus me</button> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 362 |
| 361 TEST_F('BackgroundTest', 'UseEditableState', function() { | 363 TEST_F('BackgroundTest', 'UseEditableState', function() { |
| 362 this.runWithLoadedTree( | 364 this.runWithLoadedTree( |
| 363 function() {/*! | 365 function() {/*! |
| 364 <input type="text"></input> | 366 <input type="text"></input> |
| 365 <p tabindex=0>hi</p> | 367 <p tabindex=0>hi</p> |
| 366 */}, | 368 */}, |
| 367 function(rootNode) { | 369 function(rootNode) { |
| 368 var assertExists = this.newCallback(function (evt) { | 370 var assertExists = this.newCallback(function (evt) { |
| 369 assertNotNullNorUndefined( | 371 assertNotNullNorUndefined( |
| 370 ChromeVoxState.desktopAutomationHandler.textEditHandler_); | 372 global.desktopAutomationHandler.textEditHandler_); |
| 371 evt.stopPropagation(); | 373 evt.stopPropagation(); |
| 372 }); | 374 }); |
| 373 var assertDoesntExist = this.newCallback(function (evt) { | 375 var assertDoesntExist = this.newCallback(function (evt) { |
| 374 assertTrue( | 376 assertTrue(!global.desktopAutomationHandler.editableTextHandler_); |
| 375 !ChromeVoxState.desktopAutomationHandler.editableTextHandler_); | |
| 376 evt.stopPropagation(); | 377 evt.stopPropagation(); |
| 377 }); | 378 }); |
| 378 | 379 |
| 379 var editable = rootNode.find({ role: RoleType.textField }); | 380 var editable = rootNode.find({ role: RoleType.textField }); |
| 380 var nonEditable = rootNode.find({ role: RoleType.paragraph }); | 381 var nonEditable = rootNode.find({ role: RoleType.paragraph }); |
| 381 | 382 |
| 382 this.listenOnce(editable, 'focus', assertExists); | 383 this.listenOnce(editable, 'focus', assertExists); |
| 383 this.listenOnce(nonEditable, 'focus', assertDoesntExist); | 384 this.listenOnce(nonEditable, 'focus', assertDoesntExist); |
| 384 | 385 |
| 385 editable.focus(); | 386 editable.focus(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 .expectSpeech(/slider/) | 428 .expectSpeech(/slider/) |
| 428 .expectEarcon(cvox.Earcon.SLIDER); | 429 .expectEarcon(cvox.Earcon.SLIDER); |
| 429 | 430 |
| 430 mockFeedback.replay(); | 431 mockFeedback.replay(); |
| 431 }.bind(this)); | 432 }.bind(this)); |
| 432 }); | 433 }); |
| 433 | 434 |
| 434 TEST_F('BackgroundTest', 'ToggleChromeVoxVersion', function() { | 435 TEST_F('BackgroundTest', 'ToggleChromeVoxVersion', function() { |
| 435 var mockFeedback = this.createMockFeedback(); | 436 var mockFeedback = this.createMockFeedback(); |
| 436 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { | 437 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { |
| 437 var gotCmd = ChromeVoxState.instance.onGotCommand; | 438 var gotCmd = global.backgroundObj.onGotCommand; |
| 438 | 439 |
| 439 // The command came from the background keyboard handler. | 440 // The command came from the background keyboard handler. |
| 440 var togglerFromBackground = gotCmd.bind(gotCmd, 'toggleChromeVoxVersion'); | 441 var togglerFromBackground = gotCmd.bind(gotCmd, 'toggleChromeVoxVersion'); |
| 441 | 442 |
| 442 // The command came from a content script. | 443 // The command came from a content script. |
| 443 var togglerFromContent = gotCmd.bind(gotCmd, 'toggleChromeVoxVersion', | 444 var togglerFromContent = gotCmd.bind(gotCmd, 'toggleChromeVoxVersion', |
| 444 true); | 445 true); |
| 445 | 446 |
| 446 mockFeedback.call(togglerFromBackground) | 447 mockFeedback.call(togglerFromBackground) |
| 447 .expectSpeech('Switched to Classic ChromeVox') | 448 .expectSpeech('classic') |
| 448 .call(togglerFromContent) | 449 .call(togglerFromContent) |
| 449 .expectSpeech('Switched to ChromeVox Next') | 450 .expectSpeech('next') |
| 450 .call(togglerFromBackground) | 451 .call(togglerFromBackground) |
| 451 .expectSpeech('Switched to Classic ChromeVox'); | 452 .expectSpeech('classic'); |
| 452 mockFeedback.replay(); | 453 mockFeedback.replay(); |
| 453 }); | 454 }); |
| 454 }); | 455 }); |
| 455 | 456 |
| 456 SYNC_TEST_F('BackgroundTest', 'GlobsToRegExp', function() { | 457 SYNC_TEST_F('BackgroundTest', 'GlobsToRegExp', function() { |
| 457 assertEquals('/^()$/', Background.globsToRegExp_([]).toString()); | 458 assertEquals('/^()$/', Background.globsToRegExp_([]).toString()); |
| 458 assertEquals( | 459 assertEquals( |
| 459 '/^(http:\\/\\/host\\/path\\+here)$/', | 460 '/^(http:\\/\\/host\\/path\\+here)$/', |
| 460 Background.globsToRegExp_(['http://host/path+here']).toString()); | 461 Background.globsToRegExp_(['http://host/path+here']).toString()); |
| 461 assertEquals( | 462 assertEquals( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 504 |
| 504 TEST_F('BackgroundTest', 'ModeSwitching', function() { | 505 TEST_F('BackgroundTest', 'ModeSwitching', function() { |
| 505 this.runWithLoadedTree('<button></button>', function(root) { | 506 this.runWithLoadedTree('<button></button>', function(root) { |
| 506 var fakeDesktop = {}; | 507 var fakeDesktop = {}; |
| 507 fakeDesktop.role = 'desktop'; | 508 fakeDesktop.role = 'desktop'; |
| 508 fakeDesktop.root = fakeDesktop; | 509 fakeDesktop.root = fakeDesktop; |
| 509 | 510 |
| 510 var fakeWebRoot = {}; | 511 var fakeWebRoot = {}; |
| 511 fakeWebRoot.root = fakeWebRoot; | 512 fakeWebRoot.root = fakeWebRoot; |
| 512 fakeWebRoot.parent = fakeDesktop; | 513 fakeWebRoot.parent = fakeDesktop; |
| 513 fakeWebRoot.role = RoleType.rootWebArea; | 514 fakeWebRoot.role = 'rootWebArea'; |
| 514 fakeWebRoot.makeVisible = function() {}; | |
| 515 fakeWebRoot.location = {left: 1, top: 1, width: 1, height: 1}; | |
| 516 var fakeSubRoot = {}; | 515 var fakeSubRoot = {}; |
| 517 fakeSubRoot.root = fakeSubRoot; | 516 fakeSubRoot.root = fakeSubRoot; |
| 518 fakeSubRoot.parent = fakeWebRoot; | 517 fakeSubRoot.parent = fakeWebRoot; |
| 519 fakeSubRoot.role = RoleType.rootWebArea; | 518 fakeSubRoot.role = 'rootWebArea'; |
| 520 fakeSubRoot.makeVisible = function() {}; | |
| 521 fakeSubRoot.location = {left: 1, top: 1, width: 1, height: 1}; | |
| 522 var bk = ChromeVoxState.instance; | |
| 523 | 519 |
| 524 // Tests default to force next mode. | 520 // Tests default to force next mode. |
| 525 assertEquals('force_next', bk.mode); | 521 assertEquals('force_next', global.backgroundObj.mode); |
| 526 | 522 |
| 527 // Force next mode stays set regardless of where the range lands. | 523 // Force next mode stays set regardless of where the range lands. |
| 528 fakeWebRoot.docUrl = 'http://google.com'; | 524 fakeWebRoot.docUrl = 'http://google.com'; |
| 529 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | 525 global.backgroundObj.refreshMode(fakeWebRoot); |
| 530 assertEquals('force_next', bk.mode); | 526 assertEquals('force_next', global.backgroundObj.mode); |
| 531 // Empty urls occur before document load or when root is desktop. | 527 // Empty urls occur before document load or when root is desktop. |
| 532 fakeWebRoot.docUrl = ''; | 528 fakeWebRoot.docUrl = ''; |
| 533 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | 529 global.backgroundObj.refreshMode(fakeWebRoot); |
| 534 assertEquals('force_next', bk.mode); | 530 assertEquals('force_next', global.backgroundObj.mode); |
| 535 | 531 |
| 536 // Verify force next -> compat switching. | 532 // Verify compat -> classic switching. |
| 537 localStorage['useNext'] = false; | 533 global.backgroundObj.setMode('compat'); |
| 538 fakeWebRoot.docUrl = 'chrome://foobar'; | |
| 539 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | |
| 540 assertEquals('compat', bk.mode); | |
| 541 | |
| 542 // Compat -> classic. | |
| 543 fakeWebRoot.docUrl = 'http://google.com'; | 534 fakeWebRoot.docUrl = 'http://google.com'; |
| 544 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | 535 global.backgroundObj.refreshMode(fakeWebRoot); |
| 545 assertEquals('classic', bk.mode); | 536 assertEquals('classic', global.backgroundObj.mode); |
| 546 | 537 |
| 547 // Ensure we switch to compat if our current range has focused | 538 // Ensure we switch to compat if our current range has focused |
| 548 // state set and is not in web content. | 539 // state set and is not in web content. |
| 549 assertTrue(root.parent.state.focused); | 540 assertTrue(root.parent.state.focused); |
| 550 bk.setCurrentRange(cursors.Range.fromNode(root.parent)); | 541 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent)); |
| 551 assertEquals('compat', bk.mode); | 542 global.backgroundObj.refreshMode(root.parent); |
| 543 assertEquals('compat', global.backgroundObj.mode); |
| 552 | 544 |
| 553 // And back to classic. | 545 // And back to classic. |
| 554 bk.setCurrentRange(cursors.Range.fromNode(root)); | 546 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root)); |
| 555 assertEquals('classic', bk.mode); | 547 global.backgroundObj.refreshMode(fakeWebRoot); |
| 548 assertEquals('classic', global.backgroundObj.mode); |
| 556 | 549 |
| 557 // Now, verify mode switching uses the top level root. | 550 // Now, try refreshing mode (which we call after tab switching) with a range |
| 551 // that's not actually focused. |
| 552 assertEquals(undefined, root.parent.parent.state.focused); |
| 553 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent.pare
nt)); |
| 554 global.backgroundObj.refreshMode(root.parent.parent); |
| 555 assertEquals('classic', global.backgroundObj.mode); |
| 556 |
| 557 // Now, verify mode refreshes uses the top level root. |
| 558 fakeWebRoot.docUrl = 'http://google.com/#chromevox_next_test'; | 558 fakeWebRoot.docUrl = 'http://google.com/#chromevox_next_test'; |
| 559 fakeSubRoot.docUrl = 'http://chromevox.com'; | 559 fakeSubRoot.docUrl = 'http://chromevox.com'; |
| 560 bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot)); | 560 global.backgroundObj.refreshMode(fakeSubRoot); |
| 561 assertEquals('next', bk.mode); | 561 assertEquals('next', global.backgroundObj.mode); |
| 562 }.bind(this)); | 562 }.bind(this)); |
| 563 }); | 563 }); |
| 564 | 564 |
| 565 TEST_F('BackgroundTest', 'FocusIframe', function() { | 565 TEST_F('BackgroundTest', 'FocusIframe', function() { |
| 566 this.runWithLoadedTree( function() {/*! | 566 this.runWithLoadedTree( function() {/*! |
| 567 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> | 567 <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> |
| 568 <button>outside</button> | 568 <button>outside</button> |
| 569 */}, function(root) { | 569 */}, function(root) { |
| 570 var iframe = root.find({role: RoleType.iframe}); | 570 var iframe = root.find({role: RoleType.iframe}); |
| 571 var button = root.find({role: RoleType.button}); | 571 var button = root.find({role: RoleType.button}); |
| 572 | 572 |
| 573 assertEquals('iframe', iframe.role); | 573 assertEquals('iframe', iframe.role); |
| 574 assertEquals('button', button.role); | 574 assertEquals('button', button.role); |
| 575 | 575 |
| 576 var didFocus = false; | 576 var didFocus = false; |
| 577 iframe.focus = function() { | 577 iframe.focus = function() { |
| 578 didFocus = true; | 578 didFocus = true; |
| 579 }; | 579 }; |
| 580 var b = ChromeVoxState.instance; | 580 var b = global.backgroundObj; |
| 581 b.currentRange_ = cursors.Range.fromNode(button); | 581 b.currentRange_ = cursors.Range.fromNode(button); |
| 582 b.onGotCommand('previousElement'); | 582 b.onGotCommand('previousElement'); |
| 583 assertFalse(didFocus); | 583 assertFalse(didFocus); |
| 584 }.bind(this)); | 584 }.bind(this)); |
| 585 }); | 585 }); |
| 586 | 586 |
| 587 TEST_F('BackgroundTest', 'NoisySlider', function() { | 587 TEST_F('BackgroundTest', 'NoisySlider', function() { |
| 588 var mockFeedback = this.createMockFeedback(); | 588 var mockFeedback = this.createMockFeedback(); |
| 589 this.runWithLoadedTree( function() {/*! | 589 this.runWithLoadedTree( function() {/*! |
| 590 <button id="go">go</button> | 590 <button id="go">go</button> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 if (isChecked) | 622 if (isChecked) |
| 623 go.setAttribute('aria-checked', true); | 623 go.setAttribute('aria-checked', true); |
| 624 else | 624 else |
| 625 go.removeAttribute('aria-checked'); | 625 go.removeAttribute('aria-checked'); |
| 626 isChecked = !isChecked; | 626 isChecked = !isChecked; |
| 627 }); | 627 }); |
| 628 </script> | 628 </script> |
| 629 */}, function(root) { | 629 */}, function(root) { |
| 630 var cbx = root.find({role: RoleType.checkBox}); | 630 var cbx = root.find({role: RoleType.checkBox}); |
| 631 var click = cbx.doDefault.bind(cbx); | 631 var click = cbx.doDefault.bind(cbx); |
| 632 var focus = cbx.focus.bind(cbx); | 632 mockFeedback.call(click) |
| 633 mockFeedback.call(focus) | |
| 634 .expectSpeech('go') | |
| 635 .expectSpeech('Check box') | |
| 636 .expectSpeech('not checked') | |
| 637 .call(click) | |
| 638 .expectSpeech('go') | 633 .expectSpeech('go') |
| 639 .expectSpeech('Check box') | 634 .expectSpeech('Check box') |
| 640 .expectSpeech('checked') | 635 .expectSpeech('checked') |
| 641 .call(click) | 636 .call(click) |
| 642 .expectSpeech('go') | 637 .expectSpeech('go') |
| 643 .expectSpeech('Check box') | 638 .expectSpeech('Check box') |
| 644 .expectSpeech('not checked') | 639 .expectSpeech('not checked') |
| 645 .replay(); | 640 .replay(); |
| 646 }); | 641 }); |
| 647 }); | 642 }); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 }); | 753 }); |
| 759 }); | 754 }); |
| 760 | 755 |
| 761 TEST_F('BackgroundTest', 'ToggleButton', function() { | 756 TEST_F('BackgroundTest', 'ToggleButton', function() { |
| 762 var mockFeedback = this.createMockFeedback(); | 757 var mockFeedback = this.createMockFeedback(); |
| 763 this.runWithLoadedTree(function() {/*! | 758 this.runWithLoadedTree(function() {/*! |
| 764 <div aria-pressed="true" role="button">ok</div> | 759 <div aria-pressed="true" role="button">ok</div> |
| 765 <div aria-pressed="false" role="button">cancel</div> | 760 <div aria-pressed="false" role="button">cancel</div> |
| 766 <div aria-pressed role="button">close</div> | 761 <div aria-pressed role="button">close</div> |
| 767 */}, function(root) { | 762 */}, function(root) { |
| 768 var b = ChromeVoxState.instance; | 763 var b = global.backgroundObj; |
| 769 var move = b.onGotCommand.bind(b, 'nextObject'); | 764 var move = b.onGotCommand.bind(b, 'nextObject'); |
| 770 mockFeedback.call(move) | 765 mockFeedback.call(move) |
| 771 .expectSpeech('ok') | 766 .expectSpeech('ok') |
| 772 .expectSpeech('Button') | 767 .expectSpeech('Button') |
| 773 .expectSpeech('Pressed') | 768 .expectSpeech('Pressed') |
| 774 | 769 |
| 775 .call(move) | 770 .call(move) |
| 776 .expectSpeech('cancel') | 771 .expectSpeech('cancel') |
| 777 .expectSpeech('Button') | 772 .expectSpeech('Button') |
| 778 .expectSpeech('Not pressed') | 773 .expectSpeech('Not pressed') |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 */}, function(root) { | 923 */}, function(root) { |
| 929 mockFeedback.call(doCmd('nextHeading')) | 924 mockFeedback.call(doCmd('nextHeading')) |
| 930 .expectNextSpeechUtteranceIsNot('NE') | 925 .expectNextSpeechUtteranceIsNot('NE') |
| 931 .expectSpeech('NW') | 926 .expectSpeech('NW') |
| 932 .call(doCmd('previousHeading')) | 927 .call(doCmd('previousHeading')) |
| 933 .expectNextSpeechUtteranceIsNot('NE') | 928 .expectNextSpeechUtteranceIsNot('NE') |
| 934 .expectSpeech('NW') | 929 .expectSpeech('NW') |
| 935 .replay(); | 930 .replay(); |
| 936 }); | 931 }); |
| 937 }); | 932 }); |
| OLD | NEW |