Skip to content
Permalink
Browse files

No ticket: improve line-height animation test robustness

(cherry picked from commit 2b6a7b1)
  • Loading branch information
gibson042 committed Aug 26, 2013
1 parent 2ac1cd9 commit 29903f38afc188c250c9a48ee5a7ad4ce62a4a75
Showing with 26 additions and 11 deletions.
  1. +26 −11 test/unit/effects.js
@@ -1412,7 +1412,8 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
});

asyncTest("line-height animates correctly (#13855)", 12, function() {
var
var longDuration = 2000,
shortDuration = 500,
animated = jQuery(
"<p style='line-height: 100;'>unitless</p>" +
"<p style='line-height: 5000px;'>px</p>" +
@@ -1421,29 +1422,43 @@ asyncTest("line-height animates correctly (#13855)", 12, function() {
).appendTo("#qunit-fixture"),
initialHeight = jQuery.map( animated, function( el ) {
return jQuery( el ).height();
});
}),
tolerance = 1.5,
t0 = +(new Date());

animated.animate( { "line-height": "hide" }, 1500 );
animated.animate( { "line-height": "hide" }, longDuration );
setTimeout(function() {
var progress = ( (new Date()) - t0 ) / longDuration;

animated.each(function( i ) {
var label = jQuery.text( this ),
initial = initialHeight[ i ],
height = jQuery( this ).height();
ok( height < initial, "hide " + label + ": upper bound; height: " + height + "; intitial: " + initial );
ok( height > initial / 2, "hide " + label + ": lower bound; height: " + height + "; intitial/2: " + initial / 2 );
height = jQuery( this ).height(),
lower = initial * ( 1 - progress ) / tolerance;
ok( height < initial, "hide " + label + ": upper bound; " +
height + " < " + initial + " @ " + ( progress * 100 ) + "%" );
ok( height > lower, "hide " + label + ": lower bound; " +
height + " > " + lower + " @ " + ( progress * 100 ) + "%" );
});
animated.stop( true, true ).hide().animate( { "line-height": "show" }, 1500 );

t0 = +(new Date());
animated.stop( true, true ).hide().animate( { "line-height": "show" }, longDuration );
setTimeout(function() {
var progress = ( (new Date()) - t0 ) / longDuration;

animated.each(function( i ) {
var label = jQuery.text( this ),
initial = initialHeight[ i ],
height = jQuery( this ).height();
ok( height < initial / 2, "show " + label + ": upper bound; height: " + height + "; intitial/2: " + initial / 2 );
height = jQuery( this ).height(),
upper = initial * progress * tolerance;
ok( height < upper, "show " + label + ": upper bound; " +
height + " < " + upper + " @ " + ( progress * 100 ) + "%" );
});

animated.stop( true, true );
start();
}, 400 );
}, 400 );
}, shortDuration );
}, shortDuration );
});

// Start 1.8 Animation tests

2 comments on commit 29903f3

@markelog

This comment has been minimized.

Copy link
Member

@markelog markelog replied Aug 27, 2013

@gibson042 still unstable in old browsers http://swarm.jquery.org/result/749450 :-(

@gibson042

This comment has been minimized.

Copy link
Member Author

@gibson042 gibson042 replied Aug 28, 2013

hide unitless: upper bound; 20 < 1600 @ 80.45%
hide unitless: lower bound; 20 > 208.53333333333333 @ 80.45%
hide px: upper bound; 61 < 5000 @ 80.45%
hide px: lower bound; 61 > 651.6666666666666 @ 80.45%
hide percent: upper bound; 19 < 800 @ 80.45%
hide percent: lower bound; 19 > 104.26666666666666 @ 80.45%
hide em: upper bound; 19 < 1600 @ 80.45%
hide em: lower bound; 19 > 208.53333333333333 @ 80.45%

Unbelievable. Those assertions are supposed to run at 25% (500 ms). They're executing over a second late!

Please sign in to comment.
You can’t perform that action at this time.