Skip to content

Commit

Permalink
more tests for hierarchy, see #852
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 13, 2019
1 parent 51e6388 commit f9c78fb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/accessibility/AccessibleSiblingTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' } );
Expand All @@ -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 );
} );
Expand Down

0 comments on commit f9c78fb

Please sign in to comment.