From db96e2a51f83c2b1e42b18d7995e356025083ec7 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 14 Jun 2011 15:11:43 -0500 Subject: [PATCH] Tests: Adding visual/unit tests for scale effect. --- tests/unit/effects/effects.html | 76 ++++++---- tests/unit/effects/effects_scale.js | 61 ++++++++ tests/visual/{ => effects}/effects.all.css | 1 + tests/visual/{ => effects}/effects.all.html | 38 ++--- tests/visual/{ => effects}/effects.all.js | 0 tests/visual/effects/effects.scale.html | 159 ++++++++++++++++++++ 6 files changed, 286 insertions(+), 49 deletions(-) create mode 100644 tests/unit/effects/effects_scale.js rename tests/visual/{ => effects}/effects.all.css (98%) rename tests/visual/{ => effects}/effects.all.html (65%) rename tests/visual/{ => effects}/effects.all.js (100%) create mode 100644 tests/visual/effects/effects.scale.html 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 @@ - + + @@ -81,6 +95,8 @@

Slide with relative width

+
+
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 ); diff --git a/tests/visual/effects.all.css b/tests/visual/effects/effects.all.css similarity index 98% rename from tests/visual/effects.all.css rename to tests/visual/effects/effects.all.css index d2ed94026..1d531b026 100644 --- a/tests/visual/effects.all.css +++ b/tests/visual/effects/effects.all.css @@ -5,6 +5,7 @@ body,html { font-size: 12px; font-family: Arial; background: #191919; + color: #fff; } body { margin: 1em; } diff --git a/tests/visual/effects.all.html b/tests/visual/effects/effects.all.html similarity index 65% rename from tests/visual/effects.all.html rename to tests/visual/effects/effects.all.html index fed35de8a..a2f8f62ef 100644 --- a/tests/visual/effects.all.html +++ b/tests/visual/effects/effects.all.html @@ -1,25 +1,25 @@ - + - + jQuery UI Effects Test Suite - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/tests/visual/effects.all.js b/tests/visual/effects/effects.all.js similarity index 100% rename from tests/visual/effects.all.js rename to tests/visual/effects/effects.all.js diff --git a/tests/visual/effects/effects.scale.html b/tests/visual/effects/effects.scale.html new file mode 100644 index 000000000..9521a1872 --- /dev/null +++ b/tests/visual/effects/effects.scale.html @@ -0,0 +1,159 @@ + + + + + jQuery UI Effects Test Suite + + + + + + + + + +
+
+
+
+
+ + + + +
+ + + + +
+ \ No newline at end of file -- 2.39.5