Spinner tests: Better handling of async focus in IE.

This commit is contained in:
Scott González 2012-12-10 10:35:28 -05:00
parent fbc7956b9f
commit d5f06c319a

View File

@ -131,30 +131,51 @@ asyncTest( "change", function() {
});
}
element.focus();
function focusWrap( fn, next ) {
element[0].focus();
setTimeout( function() {
fn();
setTimeout(function() {
element[0].blur();
setTimeout( next );
});
});
}
function step1() {
focusWrap(function() {
shouldChange( false, "key UP, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldChange( true, "blur after key UP" );
element.blur();
}, step2 );
}
element.focus();
function step2() {
focusWrap(function() {
shouldChange( false, "key DOWN, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( true, "blur after key DOWN" );
element.blur();
}, step3 );
}
element.focus();
function step3() {
focusWrap(function() {
shouldChange( false, "key PAGE_UP, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldChange( true, "blur after key PAGE_UP" );
element.blur();
}, step4 );
}
element.focus();
function step4() {
focusWrap(function() {
shouldChange( false, "key PAGE_DOWN, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldChange( true, "blur after key PAGE_DOWN" );
element.blur();
}, step5 );
}
function step5() {
focusWrap(function() {
shouldChange( false, "many keys, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
simulateKeyDownUp( element, $.ui.keyCode.UP );
@ -162,8 +183,11 @@ asyncTest( "change", function() {
simulateKeyDownUp( element, $.ui.keyCode.UP );
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( true, "blur after many keys" );
element.blur();
}, step6 );
}
function step6() {
focusWrap(function() {
shouldChange( false, "many keys, same final value, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
simulateKeyDownUp( element, $.ui.keyCode.UP );
@ -174,23 +198,29 @@ asyncTest( "change", function() {
shouldChange( false, "button up, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
shouldChange( true, "blur after button up" );
setTimeout(function() {
element.blur();
}, step7 );
}
function step7() {
focusWrap(function() {
shouldChange( false, "button down, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldChange( true, "blur after button down" );
setTimeout(function() {
element.blur();
}, step8 );
}
function step8() {
focusWrap(function() {
shouldChange( false, "many buttons, same final value, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldChange( false, "blur after many buttons, same final value" );
element.blur();
setTimeout(function() {
}, step9 );
}
function step9() {
shouldChange( true, "stepUp" );
element.spinner( "stepUp" );
@ -220,11 +250,10 @@ asyncTest( "change", function() {
shouldChange( false, "min, value not changed" );
element.spinner( "option", "min", 200 );
shouldChange( true, "cleanup" );
start();
});
});
});
}
step1();
});
})( jQuery );