There was one aspect of BookPlayerPageGenerator that I hadn't tested yet, and that was the syncing between the current position of the audio element and the relevant chapter object's position property. This is set up as a timeupdate listener that sets the position property from currentTime.
I had no good way of testing this, so this is what I came up with (reproduced below)
This is a gross way to test chapter position updates, but I can't set the currentTime property unless the audio has actually loaded metadata (so that the element knows the source length), and I don't know if I should bother with it. Since currentTime is 0 by default (and can be called even without metadata loaded), this tests the behavior by setting the position to -1 and then checking to see if it has 'updated' to 0.
It's times like this that I realize I have no idea what I'm doing when it comes to testing HTML elements.
Ahh, Mr. Hirschberg, but the fact that you know what you don't know is a strong sign that you're well on the way to figuring it out! ;-)
ReplyDelete