diff --git a/js/accessibility/AccessibleSiblingTests.js b/js/accessibility/AccessibleSiblingTests.js index e82a57a30..58b989dc1 100644 --- a/js/accessibility/AccessibleSiblingTests.js +++ b/js/accessibility/AccessibleSiblingTests.js @@ -14,6 +14,7 @@ define( function( require ) { const Display = require( 'SCENERY/display/Display' ); const Node = require( 'SCENERY/nodes/Node' ); const Rectangle = require( 'SCENERY/nodes/Rectangle' ); + const Vector2 = require( 'DOT/Vector2' ); // constants const PIXEL_PADDING = 3; @@ -43,6 +44,7 @@ define( function( require ) { const display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); + // test bounds are set for basic input elements const buttonElement = new Rectangle( 5, 5, 5, 5, { tagName: 'button' } ); const divElement = new Rectangle( 0, 0, 20, 20, { tagName: 'div', focusable: true } ); const inputElement = new Rectangle( 10, 3, 25, 5, { tagName: 'input', inputType: 'range' } ); @@ -58,6 +60,24 @@ define( function( require ) { assert.ok( siblingBoundsCorrect( divElement ), 'div element child of root correctly positioned' ); assert.ok( siblingBoundsCorrect( inputElement ), 'input element child of root correctly positioned' ); + // test that bounds are set correctly once we have a hierarchy and add transformations + rootNode.removeChild( buttonElement ); + rootNode.removeChild( divElement ); + rootNode.removeChild( inputElement ); + + rootNode.addChild( divElement ); + divElement.addChild( buttonElement ); + buttonElement.addChild( inputElement ); + + // arbitrary transformations down the tree (should be propagated to input element) + divElement.setCenter( new Vector2( 50, 50 ) ); + buttonElement.setScaleMagnitude( 0.89 ); + inputElement.setRotation( Math.PI / 4 ); + + // udpdate so the display to position elements + display.updateDisplay(); + assert.ok( siblingBoundsCorrect( inputElement ), 'input element descendant incorrectly positioned' ); + // remove the display element so it doesn't interfere with qunit api document.body.removeChild( display.domElement ); } );