| 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 var result = JSON.parse(JSON.stringify(state)); | 8 delete state[StateType.horizontal]; |
| 9 delete result[StateType.horizontal]; | 9 delete state[StateType.hovered]; |
| 10 delete result[StateType.hovered]; | 10 delete state[StateType.vertical]; |
| 11 delete result[StateType.vertical]; | |
| 12 return result; | |
| 13 }; | 11 }; |
| 14 | 12 |
| 15 var allTests = [ | 13 var allTests = [ |
| 16 function testSimplePage() { | 14 function testSimplePage() { |
| 17 var title = rootNode.docTitle; | 15 var title = rootNode.docTitle; |
| 18 assertEq('Automation Tests', title); | 16 assertEq('Automation Tests', title); |
| 19 | 17 RemoveUntestedStates(rootNode.state); |
| 20 var state = RemoveUntestedStates(rootNode.state); | |
| 21 assertEq( | 18 assertEq( |
| 22 {enabled: true, focusable: true, readOnly: true}, | 19 {enabled: true, focusable: true, readOnly: true}, |
| 23 state); | 20 rootNode.state); |
| 24 | |
| 25 var children = rootNode.children; | 21 var children = rootNode.children; |
| 26 assertEq(RoleType.rootWebArea, rootNode.role); | 22 assertEq(RoleType.rootWebArea, rootNode.role); |
| 27 assertEq(1, children.length); | 23 assertEq(1, children.length); |
| 28 var body = children[0]; | 24 var body = children[0]; |
| 29 assertEq('body', body.htmlTag); | 25 assertEq('body', body.htmlTag); |
| 30 state = RemoveUntestedStates(body.state); | 26 |
| 31 assertEq({enabled: true, readOnly: true}, state); | 27 RemoveUntestedStates(body.state); |
| 28 assertEq({enabled: true, readOnly: true}, |
| 29 body.state); |
| 32 | 30 |
| 33 var contentChildren = body.children; | 31 var contentChildren = body.children; |
| 34 assertEq(3, contentChildren.length); | 32 assertEq(3, contentChildren.length); |
| 35 var okButton = contentChildren[0]; | 33 var okButton = contentChildren[0]; |
| 36 assertEq('Ok', okButton.name); | 34 assertEq('Ok', okButton.name); |
| 37 state = RemoveUntestedStates(okButton.state); | 35 RemoveUntestedStates(okButton.state); |
| 38 assertEq({enabled: true, focusable: true, readOnly: true}, state); | 36 assertEq({enabled: true, focusable: true, readOnly: true}, |
| 37 okButton.state); |
| 39 var userNameInput = contentChildren[1]; | 38 var userNameInput = contentChildren[1]; |
| 40 assertEq('Username', | 39 assertEq('Username', |
| 41 userNameInput.description); | 40 userNameInput.description); |
| 42 state = RemoveUntestedStates(userNameInput.state); | 41 RemoveUntestedStates(userNameInput.state); |
| 43 assertEq({enabled: true, focusable: true}, state); | 42 assertEq({enabled: true, focusable: true}, |
| 43 userNameInput.state); |
| 44 var cancelButton = contentChildren[2]; | 44 var cancelButton = contentChildren[2]; |
| 45 assertEq('Cancel', | 45 assertEq('Cancel', |
| 46 cancelButton.name); | 46 cancelButton.name); |
| 47 state = RemoveUntestedStates(cancelButton.state); | 47 RemoveUntestedStates(cancelButton.state); |
| 48 assertEq({enabled: true, focusable: true, readOnly: true}, state); | 48 assertEq({enabled: true, focusable: true, readOnly: true}, |
| 49 cancelButton.state); |
| 49 | 50 |
| 50 // Traversal. | 51 // Traversal. |
| 51 assertEq(undefined, rootNode.parent); | 52 assertEq(undefined, rootNode.parent); |
| 52 assertEq(rootNode, body.parent); | 53 assertEq(rootNode, body.parent); |
| 53 | 54 |
| 54 assertEq(body, rootNode.firstChild); | 55 assertEq(body, rootNode.firstChild); |
| 55 assertEq(body, rootNode.lastChild); | 56 assertEq(body, rootNode.lastChild); |
| 56 | 57 |
| 57 assertEq(okButton, body.firstChild); | 58 assertEq(okButton, body.firstChild); |
| 58 assertEq(cancelButton, body.lastChild); | 59 assertEq(cancelButton, body.lastChild); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 75 chrome.test.succeed(); | 76 chrome.test.succeed(); |
| 76 }, | 77 }, |
| 77 function testIsRoot() { | 78 function testIsRoot() { |
| 78 assertTrue(rootNode.isRootNode); | 79 assertTrue(rootNode.isRootNode); |
| 79 assertFalse(rootNode.firstChild.isRootNode); | 80 assertFalse(rootNode.firstChild.isRootNode); |
| 80 chrome.test.succeed(); | 81 chrome.test.succeed(); |
| 81 } | 82 } |
| 82 ]; | 83 ]; |
| 83 | 84 |
| 84 setUpAndRunTests(allTests); | 85 setUpAndRunTests(allTests); |
| OLD | NEW |