Skip to content

Commit

Permalink
add voicing utterances support, #127
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 8, 2021
1 parent 73f0e41 commit 0309c0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 8 additions & 3 deletions js/snapshot-comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function setup( simNames ) {

const diff = document.createElement( 'details' );
const summary = document.createElement( 'summary' );
summary.appendChild( document.createTextNode( `${message}: Description Utterances different. ${oldUtterances.length} vs ${newUtterances.length} utterances` ) );
summary.appendChild( document.createTextNode( `${message}: Utterances different. ${oldUtterances.length} vs ${newUtterances.length} utterances` ) );
diff.appendChild( summary );
const diffGuts = document.createElement( 'div' );
diff.appendChild( diffGuts );
Expand Down Expand Up @@ -308,9 +308,14 @@ function setup( simNames ) {
comparePDOM( oldFrame.pdom.html, newFrame.pdom.html, dataFrameIndex );

}
// Compare description via PDOM html
// Compare description utterances
if ( options.compareDescription && oldFrame.descriptionAlert.hash !== newFrame.descriptionAlert.hash ) {
compareDescriptionAlerts( oldFrame.descriptionAlert.utterances, newFrame.descriptionAlert.utterances, dataFrameIndex );
compareDescriptionAlerts( oldFrame.descriptionAlert.utterances, newFrame.descriptionAlert.utterances, `${dataFrameIndex}, Description` );
}

// Compare voicing utterances
if ( options.compareDescription && oldFrame.voicing.hash !== newFrame.voicing.hash ) {
compareDescriptionAlerts( oldFrame.voicing.utterances, newFrame.voicing.utterances, `${dataFrameIndex}, Voicing` );
}

// Kick off the next iteration if we aren't waiting for images to load
Expand Down
16 changes: 15 additions & 1 deletion js/take-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ function handleFrame() {
utterances: null,
hash: null
};
const voicingResponseData = {
utterances: null,
hash: null
};
if ( options.compareDescription && iframe.contentWindow.phet.joist.display.isAccessible() ) {

const pdomRoot = iframe.contentWindow.phet.joist.display.pdomRootElement;
Expand All @@ -178,6 +182,15 @@ function handleFrame() {
const utterancesHash = hash( utteranceTexts + '' );
descriptionAlertData.hash = utterancesHash;
concatHash += utterancesHash;

if ( iframe.contentWindow.phet.scenery.voicingUtteranceQueue ) {
const voicingUtteranceQueue = iframe.contentWindow.phet.scenery.voicingUtteranceQueue.queue;
const voicingUtteranceTexts = voicingUtteranceQueue.map( voicingUtteranceWrapper => voicingUtteranceWrapper.utterance.toString() );
voicingResponseData.utterances = voicingUtteranceTexts;
const voicingUtterancesHash = hash( voicingUtteranceTexts + '' );
voicingResponseData.hash = voicingUtterancesHash;
concatHash += voicingUtterancesHash;
}
}


Expand All @@ -189,7 +202,8 @@ function handleFrame() {
hash: hashedScreenshotURL
},
pdom: pdomData,
descriptionAlert: descriptionAlertData
descriptionAlert: descriptionAlertData,
voicing: voicingResponseData
} ), '*' );

received = true;
Expand Down

0 comments on commit 0309c0e

Please sign in to comment.