| 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 // Do not test orientation or hover attributes (similar to exclusions on native | 5 // Do not test orientation or hover attributes (similar to exclusions on native |
| 6 // accessibility), since they can be inconsistent depending on the environment. | 6 // accessibility), since they can be inconsistent depending on the environment. |
| 7 var RemoveUntestedStates = function(state) { | 7 var RemoveUntestedStates = function(state) { |
| 8 delete state['horizontal']; | 8 delete state['horizontal']; |
| 9 delete state['hovered']; | 9 delete state['hovered']; |
| 10 delete state['vertical']; | 10 delete state['vertical']; |
| 11 }; | 11 }; |
| 12 | 12 |
| 13 var allTests = [ | 13 var allTests = [ |
| 14 function testSimplePage() { | 14 function testSimplePage() { |
| 15 var title = tree.root.attributes['docTitle']; | 15 tree.addEventListener('loadComplete', function() { |
| 16 assertEq('Automation Tests', title); | 16 var title = tree.root.attributes['docTitle']; |
| 17 RemoveUntestedStates(tree.root.state); | 17 assertEq('Automation Tests', title); |
| 18 assertEq( | 18 RemoveUntestedStates(tree.root.state); |
| 19 {enabled: true, focusable: true, readOnly: true}, | 19 assertEq( |
| 20 tree.root.state); | 20 {enabled: true, focusable: true, readOnly: true}, |
| 21 var children = tree.root.children(); | 21 tree.root.state); |
| 22 assertEq(1, children.length); | 22 var children = tree.root.children(); |
| 23 assertEq(1, children.length); |
| 23 | 24 |
| 24 var body = children[0]; | 25 var body = children[0]; |
| 25 assertEq('body', body.attributes['htmlTag']); | 26 assertEq('body', body.attributes['htmlTag']); |
| 26 | 27 |
| 27 RemoveUntestedStates(body.state); | 28 RemoveUntestedStates(body.state); |
| 28 assertEq({enabled: true, readOnly: true}, | 29 assertEq({enabled: true, readOnly: true}, |
| 29 body.state); | 30 body.state); |
| 30 | 31 |
| 31 var contentChildren = body.children(); | 32 var contentChildren = body.children(); |
| 32 assertEq(3, contentChildren.length); | 33 assertEq(3, contentChildren.length); |
| 33 var okButton = contentChildren[0]; | 34 var okButton = contentChildren[0]; |
| 34 assertEq('Ok', okButton.attributes['name']); | 35 assertEq('Ok', okButton.attributes['name']); |
| 35 RemoveUntestedStates(okButton.state); | 36 RemoveUntestedStates(okButton.state); |
| 36 assertEq({enabled: true, focusable: true, readOnly: true}, | 37 assertEq({enabled: true, focusable: true, readOnly: true}, |
| 37 okButton.state); | 38 okButton.state); |
| 38 var userNameInput = contentChildren[1]; | 39 var userNameInput = contentChildren[1]; |
| 39 assertEq('Username', | 40 assertEq('Username', |
| 40 userNameInput.attributes['description']); | 41 userNameInput.attributes['description']); |
| 41 RemoveUntestedStates(userNameInput.state); | 42 RemoveUntestedStates(userNameInput.state); |
| 42 assertEq({enabled: true, focusable: true}, | 43 assertEq({enabled: true, focusable: true}, |
| 43 userNameInput.state); | 44 userNameInput.state); |
| 44 var cancelButton = contentChildren[2]; | 45 var cancelButton = contentChildren[2]; |
| 45 assertEq('Cancel', | 46 assertEq('Cancel', |
| 46 cancelButton.attributes['name']); | 47 cancelButton.attributes['name']); |
| 47 RemoveUntestedStates(cancelButton.state); | 48 RemoveUntestedStates(cancelButton.state); |
| 48 assertEq({enabled: true, focusable: true, readOnly: true}, | 49 assertEq({enabled: true, focusable: true, readOnly: true}, |
| 49 cancelButton.state); | 50 cancelButton.state); |
| 50 | 51 |
| 51 // Traversal. | 52 // Traversal. |
| 52 assertEq(undefined, tree.root.parent()); | 53 assertEq(undefined, tree.root.parent()); |
| 53 assertEq(tree.root, body.parent()); | 54 assertEq(tree.root, body.parent()); |
| 54 | 55 |
| 55 assertEq(body, tree.root.firstChild()); | 56 assertEq(body, tree.root.firstChild()); |
| 56 assertEq(body, tree.root.lastChild()); | 57 assertEq(body, tree.root.lastChild()); |
| 57 | 58 |
| 58 assertEq(okButton, body.firstChild()); | 59 assertEq(okButton, body.firstChild()); |
| 59 assertEq(cancelButton, body.lastChild()); | 60 assertEq(cancelButton, body.lastChild()); |
| 60 | 61 |
| 61 assertEq(body, okButton.parent()); | 62 assertEq(body, okButton.parent()); |
| 62 assertEq(body, userNameInput.parent()); | 63 assertEq(body, userNameInput.parent()); |
| 63 assertEq(body, cancelButton.parent()); | 64 assertEq(body, cancelButton.parent()); |
| 64 | 65 |
| 65 assertEq(undefined, okButton.previousSibling()); | 66 assertEq(undefined, okButton.previousSibling()); |
| 66 assertEq(undefined, okButton.firstChild()); | 67 assertEq(undefined, okButton.firstChild()); |
| 67 assertEq(userNameInput, okButton.nextSibling()); | 68 assertEq(userNameInput, okButton.nextSibling()); |
| 68 assertEq(undefined, okButton.lastChild()); | 69 assertEq(undefined, okButton.lastChild()); |
| 69 | 70 |
| 70 assertEq(okButton, userNameInput.previousSibling()); | 71 assertEq(okButton, userNameInput.previousSibling()); |
| 71 assertEq(cancelButton, userNameInput.nextSibling()); | 72 assertEq(cancelButton, userNameInput.nextSibling()); |
| 72 | 73 |
| 73 assertEq(userNameInput, cancelButton.previousSibling()); | 74 assertEq(userNameInput, cancelButton.previousSibling()); |
| 74 assertEq(undefined, cancelButton.nextSibling()); | 75 assertEq(undefined, cancelButton.nextSibling()); |
| 75 | 76 |
| 76 chrome.test.succeed(); | 77 chrome.test.succeed(); |
| 78 }); |
| 77 } | 79 } |
| 78 ]; | 80 ]; |
| 79 | 81 |
| 80 setUpAndRunTests(allTests); | 82 setUpAndRunTests(allTests); |
| OLD | NEW |