Permalink
Browse files

seperate transition tests, whitespace

  • Loading branch information...
johnbender committed Jan 17, 2012
1 parent 57338ef commit 020f4b7db6d87174059f252f98e93155cffa1f3e
@@ -17,7 +17,6 @@
<link rel="stylesheet" href="../../../external/qunit.css"/>
<script src="../../../external/qunit.js"></script>
- <script type="text/javascript" src="navigation_transitions.js"></script>
<script type="text/javascript" src="navigation_helpers.js"></script>
<script type="text/javascript" src="navigation_core.js"></script>
<script type="text/javascript" src="navigation_paths.js"></script>
@@ -19,11 +19,11 @@
isTransitioningIn = function(page){
return page.hasClass("in") && isTransitioning(page);
},
-
+
disableMaxTransWidth = function(){
$.mobile.maxTransitionWidth = false;
},
-
+
enableMaxTransWidth = function(){
$.mobile.maxTransitionWidth = defaultMaxTrans;
},
@@ -36,15 +36,15 @@
fromQueue = [];
toQueue = [];
},
-
+
onFromComplete = function( f ){
fromQueue.push( f );
},
-
+
onToComplete = function( f ){
toQueue.push( f );
},
-
+
//wipe all urls
clearUrlHistory = function(){
@@ -55,9 +55,11 @@
module('jquery.mobile.navigation.js', {
setup: function(){
+
+
// disable this option so we can test transitions regardless of window width
disableMaxTransWidth();
-
+
//stub to allow callback before function is returned to transition handler
$.fn.animationComplete = function( callback ){
animationCompleteFn.call( this, function(){
@@ -72,6 +74,17 @@
resetQueues();
clearUrlHistory();
+
+ if ( location.hash !== "#harmless-default-page" ) {
+ stop();
+
+ $(document).one("pagechange", function() {
+ start();
+ } );
+
+ location.hash = "#harmless-default-page";
+ }
+
},
teardown: function(){
@@ -80,52 +93,51 @@
enableMaxTransWidth();
}
});
-
- /*
- NOTES:
- Our default transition handler now has either one or two animationComplete calls - two if there are two pages in play (from and to)
+
+ /*
+ NOTES:
+ Our default transition handler now has either one or two animationComplete calls - two if there are two pages in play (from and to)
To is required, so each async function must call start() onToComplete, not onFromComplete.
*/
-
+
asyncTest( "changePage applies perspective class to mobile viewport for flip", function(){
expect(1);
-
+
onToComplete( function( el ){
ok($("body").hasClass(perspective), "has perspective class");
start();
} );
-
- $("#foo > a").click();
+ $("#foo > a").click();
});
-
+
asyncTest( "changePage does not apply perspective class to mobile viewport for transitions other than flip", function(){
expect(1);
-
+
onToComplete( function( el ){
ok(!$("body").hasClass(perspective), "doesn't have perspective class");
start();
} );
-
+
$("#bar > a").click();
});
-
+
asyncTest( "changePage applies transition class to mobile viewport for default transition", function(){
expect(1);
-
+
onToComplete( function( el ){
ok($("body").hasClass(transitioning), "has transitioning class");
start();
} );
-
+
$("#baz > a").click();
});
-
+
asyncTest( "explicit transition preferred for page navigation reversal (ie back)", function(){
expect( 1 );
-
+
onToComplete(function(){
$("#flip-trans > a").click();
onToComplete(function(){
@@ -136,7 +148,7 @@
});
});
});
-
+
$("#fade-trans > a").click();
});
@@ -145,7 +157,7 @@
ok($("#no-trans").hasClass("fade"), "has fade class");
start();
})
-
+
$("#default-trans > a").click();
});
@@ -164,7 +176,7 @@
ok(!isTransitioningIn(firstPage), "first page transition should be complete");
ok(isTransitioningIn(secondPage), "second page should begin transitioning");
start();
-
+
});
});
});
@@ -175,47 +187,43 @@
ok($("#no-trans-dialog").hasClass("pop"), "has pop class" );
start();
});
-
+
$("#default-trans-dialog > a").click();
});
test( "animationComplete return value", function(){
$.fn.animationComplete = animationCompleteFn;
equals($("#foo").animationComplete(function(){})[0], $("#foo")[0]);
});
-
-
+
+
// reusable function for a few tests below
function testTransitionMaxWidth( val, expected ){
expect( 1 );
-
+
$.mobile.maxTransitionWidth = val;
-
+
var transitionOccurred = false;
-
+
onToComplete(function(){
transitionOccurred = true;
});
-
-
+
+
return setTimeout(function(){
ok( transitionOccurred === expected, (expected ? "" : "no ") + "transition occurred" );
start();
}, 5000);
-
+
$.mobile.changePage( $(".ui-page:not(.ui-page-active)").first() );
-
+
}
-
+
asyncTest( "maxTransitionWidth property disables transitions when value is less than browser width", function(){
testTransitionMaxWidth( $( window ).width() - 1, false );
});
-
+
asyncTest( "maxTransitionWidth property disables transitions when value is false", function(){
testTransitionMaxWidth( false, false );
});
-
-
-
-
})(jQuery);
Oops, something went wrong.

0 comments on commit 020f4b7

Please sign in to comment.