diff options
author | gnarf <gnarf@gnarf.net> | 2011-06-14 15:11:43 -0500 |
---|---|---|
committer | gnarf <gnarf@gnarf.net> | 2011-06-14 15:11:43 -0500 |
commit | db96e2a51f83c2b1e42b18d7995e356025083ec7 (patch) | |
tree | 05590cb926129244196b78fbe9d95dc806769e7a /tests/unit/effects | |
parent | c1f71f1c2f732e58a8fbca91185a284ea8db6b1b (diff) | |
download | jquery-ui-db96e2a51f83c2b1e42b18d7995e356025083ec7.tar.gz jquery-ui-db96e2a51f83c2b1e42b18d7995e356025083ec7.zip |
Tests: Adding visual/unit tests for scale effect.
Diffstat (limited to 'tests/unit/effects')
-rw-r--r-- | tests/unit/effects/effects.html | 76 | ||||
-rw-r--r-- | tests/unit/effects/effects_scale.js | 61 |
2 files changed, 107 insertions, 30 deletions
diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 6956ebcda..e3c6d2f4e 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -28,40 +28,54 @@ <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> <script src="effects_core.js"></script> - + <script src="effects_scale.js"></script> + <script src="../swarminject.js"></script> <style type="text/css"> - .hidden { - display: none; - } - .test { - background: #000; - border: 0; - width: 100px; - height: 100px; - } - .testAddBorder { - border: 10px solid #000; - } - .testChildren, - .testChangeBackground { - background: #fff; - } - .test h2 { - font-size: 10px; - } - .testChildren h2 { - font-size: 20px; - } - - .relWidth { - width: 50%; - } + #qunit-fixture { + width: 1000px; + height: 1000px; + } + .hidden { + display: none; + } + .test { + background: #000; + border: 0; + width: 100px; + height: 100px; + } + .testAddBorder { + border: 10px solid #000; + } + .testChildren, + .testChangeBackground { + background: #fff; + } + .test h2 { + font-size: 10px; + } + .testChildren h2 { + font-size: 20px; + } + + .relWidth { + width: 50%; + } + + .relHeight { + height: 50%; + } + + .testScale { + border: 5px solid #000; + padding: 5px; + margin: 5px; + width: 50px; + height: 50px; + } - .relHeight { - height: 50%; - } </style> </head> <body> @@ -81,6 +95,8 @@ <div class="relWidth relHeight testAddBorder"> <h2>Slide with relative width</d2> </div> + <div class="testScale"> + </div> </div> </body> diff --git a/tests/unit/effects/effects_scale.js b/tests/unit/effects/effects_scale.js new file mode 100644 index 000000000..1436cd030 --- /dev/null +++ b/tests/unit/effects/effects_scale.js @@ -0,0 +1,61 @@ +(function( $ ) { +module( "effect.scale: Scale" ); + +function run( position, v, h, vo, ho ) { + var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")"; + asyncTest( desc, function() { + var test = $( ".testScale" ), + css = { + position: position + }, + effect = { + effect: "scale", + mode: "effect", + percent: 200, + origin: [ vo, ho ], + complete: complete, + duration: 1 + }, + target = {}, + relative = position === "relative"; + + css[ h ] = 33; + css[ v ] = 33; + target[ h ] = h === ho ? css[ h ] : ho == "center" ? css[ h ] - 35 : css[ h ] - 70; + target[ v ] = v === vo ? css[ v ] : vo == "middle" ? css[ v ] - 35 : css[ v ] - 70; + if ( relative && h == "right" ) { + target[ h ] += 70; + } + if ( relative && v == "bottom" ) { + target[ v ] += 70; + } + test.css( css ); + test.effect( effect ); + + function complete() { + equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc ); + equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc ); + start(); + } + }); +} + +function suite( position ) { + run( position, "top", "left", "top", "left" ); + run( position, "top", "left", "middle", "center" ); + run( position, "top", "left", "bottom", "right" ); + run( position, "bottom", "right", "top", "left" ); + run( position, "bottom", "right", "middle", "center" ); + run( position, "bottom", "right", "bottom", "right" ); +} + +$(function() { + suite( "absolute" ); + suite( "relative" ); + $.offset.initialize(); + if ( $.offset.supportsFixedPosition ) { + suite( "fixed" ); + } +}); + +})( jQuery ); |