-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added timing constructor test #220
Open
samthor
wants to merge
12
commits into
web-animations:master
Choose a base branch
from
samthor:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6a55d47
added timing constructor test
samthor c5821ba
confusing timing tests
samthor f6e1dd2
moved timing test to maxifill; fixed test (understanding of tick++)
samthor 60c8702
more timing tests
samthor fe27436
'fixed' test, updated comment
samthor 0ac11ea
composing playbackRate is broken
samthor 21c2ea9
updated test naming, added pause/scrub tests
samthor c978019
Merge remote-tracking branch 'upstream/master'
samthor a01ea58
scrub group test
samthor 64e0140
Merge remote-tracking branch 'upstream/master'
samthor 68dba03
Merge remote-tracking branch 'upstream/master'
samthor 0eb0ef5
Merge remote-tracking branch 'upstream/master'
samthor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
suite('timing-tests', function() { | ||
setup(function() { | ||
document.timeline._players = []; | ||
}); | ||
|
||
test('changing timing iterations mid-animation', function() { | ||
var animation = new Animation(document.body, [], { duration: 1000 }); | ||
|
||
// TODO: access internal _timing for now, until .timing is properly generated | ||
var timing = animation._timing; | ||
|
||
assert.equal(timing.duration, 1000); | ||
assert.equal(timing.iterations, 1.0); | ||
|
||
var player = document.timeline.play(animation); | ||
tick(50); | ||
assert.equal(player.currentTime, 0); | ||
|
||
tick(350); | ||
assert.equal(player.currentTime, 300); | ||
|
||
timing.iterations = 0.5; | ||
animation.timing.iterations = 0.5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI these don't work because we don't yet support these maxifill feature (exposed timing, modifiable timing). They're not on the roadmap for the m39 release. |
||
tick(850); | ||
assert.equal(player.currentTime, 500); | ||
}); | ||
|
||
test('immediate pause and play later', function() { | ||
var animation = new Animation(document.body, [], { duration: 1000 }); | ||
var player = document.timeline.play(animation); | ||
player.pause(); | ||
|
||
tick(50); | ||
assert(!player.currentTime); | ||
assert(!player.startTime); | ||
|
||
tick(150); | ||
assert(!player.currentTime); | ||
assert(!player.startTime); | ||
|
||
player.play(); | ||
|
||
tick(250); | ||
assert.equal(player.currentTime, 100); | ||
assert.equal(player.startTime, 150); | ||
}); | ||
|
||
test('composing playbackRate', function() { | ||
var target = document.createElement('div'); | ||
target.style.position = 'absolute'; | ||
document.body.appendChild(target); | ||
|
||
var timing = { duration: 1000, playbackRate: 0.5 }; | ||
var animation = new Animation(target, [ | ||
{ left: '0px' }, | ||
{ left: '1000px' } | ||
], timing); | ||
|
||
// 0.5 * 2.0 == 1, so offsetLeft==currentTime | ||
var group = new AnimationGroup([animation], { playbackRate: 2.0 }); | ||
var player = document.timeline.play(animation); | ||
|
||
tick(50); | ||
assert.equal(player.startTime, 50); | ||
|
||
tick(150); | ||
assert.equal(player.currentTime, 100); | ||
assert.equal(target.offsetLeft, 100); | ||
}); | ||
|
||
test('player playbackRate', function() { | ||
var target = document.createElement('div'); | ||
target.style.position = 'absolute'; | ||
document.body.appendChild(target); | ||
|
||
var timing = { duration: 1000, playbackRate: 0.5 }; | ||
var animation = new Animation(target, [ | ||
{ left: '0px' }, | ||
{ left: '1000px' } | ||
], timing); | ||
|
||
var player = document.timeline.play(animation); | ||
|
||
// 0.5 * 2.0 == 1, so offsetLeft==currentTime | ||
player.playbackRate = 2.0; | ||
|
||
tick(50); | ||
assert.equal(player.startTime, 50); | ||
|
||
tick(150); | ||
assert.equal(player.currentTime, 100); | ||
assert.equal(target.offsetLeft, 100); | ||
}); | ||
|
||
test('pause and scrub', function() { | ||
// note that this functions natively. However, note that AnimationGroup | ||
// is not native on M41, so it still fails there. | ||
var animation = new Animation(document.body, [], { duration: 1000 }); | ||
var player = document.timeline.play(animation); | ||
player.pause(); | ||
|
||
player.currentTime = 500; | ||
assert.equal(player.currentTime, 500); | ||
}); | ||
|
||
test('pause and scrub group', function() { | ||
// note that this functions natively. However, note that AnimationGroup | ||
// is not native on M41, so it still fails there. | ||
var animation = new Animation(document.body, [], { duration: 1000 }); | ||
var group = new AnimationGroup([animation]); | ||
var player = document.timeline.play(group); | ||
player.pause(); | ||
|
||
player.currentTime = 500; | ||
assert.equal(player.currentTime, 500); | ||
}); | ||
|
||
test('pause, scrub and play', function() { | ||
var target = document.createElement('div'); | ||
document.body.appendChild(target); | ||
|
||
var animation = new Animation(target, [ | ||
{ background: 'blue' }, | ||
{ background: 'red' } | ||
], { duration: 1000 }); | ||
var player = document.timeline.play(animation); | ||
tick(100); | ||
player.pause(); | ||
|
||
player.currentTime = 200; | ||
// http://www.w3.org/TR/web-animations/#the-current-time-of-a-player | ||
// currentTime should now mean 'hold time' - this allows scrubbing. | ||
assert.equal(player.currentTime, 200); | ||
player.play(); | ||
|
||
tick(200); | ||
assert.equal(player.currentTime, 300); | ||
assert.equal(player.startTime, -100); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timing.js
is a minifill test, but the Animation constructor is only in the maxifill.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed