From: David Seifried Date: Tue, 17 May 2011 16:04:39 +0000 (-0400) Subject: Added unit tests, also made a few changes to simplify the use a bit X-Git-Tag: v0.6~3^2~1^2~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ac4bd757de1c37c77b11366681196ac76c49a69e;p=popcorn-js.git Added unit tests, also made a few changes to simplify the use a bit --- diff --git a/plugins/googlemap/popcorn.googlemap.html b/plugins/googlemap/popcorn.googlemap.html index a351a57..d0cac64 100644 --- a/plugins/googlemap/popcorn.googlemap.html +++ b/plugins/googlemap/popcorn.googlemap.html @@ -31,7 +31,7 @@ heading: "180", pitch: "1", interval: 1000, - endLoc: "York university" + tween: "York university" }) .googlemap({ start: 0, // seconds @@ -45,7 +45,7 @@ heading: "180", pitch: "1", interval: 1000, - endLoc: "Ottawa" + tween: "Ottawa" }) .googlemap({ start: 0, // seconds @@ -146,3 +146,4 @@ + diff --git a/plugins/googlemap/popcorn.googlemap.js b/plugins/googlemap/popcorn.googlemap.js index 4dc4d01..3214b77 100644 --- a/plugins/googlemap/popcorn.googlemap.js +++ b/plugins/googlemap/popcorn.googlemap.js @@ -49,13 +49,13 @@ var googleCallback; * cause and error. * * Tweening works using the following specifications: - * -Location is the start point when using an auto generated route - * -endLoc is the end location when using an auto generated route - * Note that both location and endLoc must be present when using an auto generated route, or the map will not tween - * -Interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds ) + * -location is the start point when using an auto generated route + * -tween when used in this context is a string which specifies the end location for your route + * Note that both location and tween must be present when using an auto generated route, or the map will not tween + * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds ) * Heading, Zoom, and Pitch streetview values are also used in tweening with the autogenerated route * - * -Tween is an array of objects, each containing data for one frame of a tween + * -tween is an array of objects, each containing data for one frame of a tween * -position is an object with has two paramaters, lat and lng, both which are mandatory for a tween to work * -pov is an object which houses heading, pitch, and zoom paramters, which are all optional, if undefined, these values default to 0 * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds ) @@ -186,14 +186,14 @@ var googleCallback; ); - + // Function to handle tweening using a set timeout var tween = function ( rM, t ) { setTimeout( function () { - + // Checks whether this is a generated route or not - if( options.tween ){ + if( typeof options.tween === "array" ){ for ( var i = 0; i < rM.length; i++ ) { @@ -244,7 +244,7 @@ var googleCallback; // Determines if we should use hardcoded values ( using options.tween ), // or if we should use a start and end location and let google generate // the route for us - if ( !options.tween && ( options.location && options.endLoc ) ){ + if ( options.location && typeof options.tween === "string" ){ // Creating another variable to hold the streetview map for tweening, // Doing this because if there was more then one streetview map, the tweening would sometimes appear in other maps @@ -262,7 +262,7 @@ var googleCallback; var request = { origin: options.location, - destination: options.endLoc, + destination: options.tween, travelMode: google.maps.TravelMode.DRIVING }; @@ -289,7 +289,7 @@ var googleCallback; } } - else if( options.tween ){ + else if( typeof options.tween === "array" ){ // Same as the above to stop streetview maps from overflowing into one another var sView3 = sView; diff --git a/plugins/googlemap/popcorn.googlemap.unit.html b/plugins/googlemap/popcorn.googlemap.unit.html index 476d0bf..e37ab4f 100644 --- a/plugins/googlemap/popcorn.googlemap.unit.html +++ b/plugins/googlemap/popcorn.googlemap.unit.html @@ -39,6 +39,8 @@
-
+
+
+ diff --git a/plugins/googlemap/popcorn.googlemap.unit.js b/plugins/googlemap/popcorn.googlemap.unit.js index 778a59d..a4d6b53 100644 --- a/plugins/googlemap/popcorn.googlemap.unit.js +++ b/plugins/googlemap/popcorn.googlemap.unit.js @@ -24,6 +24,9 @@ test("Popcorn Google Map Plugin", function () { ok ( document.getElementById('map2').innerHTML === "", "initially, there is nothing inside the map2" ); plus(); + ok ( document.getElementById('map3').innerHTML === "", "initially, there is nothing inside the map3" ); + plus(); + popped.googlemap({ start: 0, // seconds end: 5, // seconds @@ -34,23 +37,26 @@ test("Popcorn Google Map Plugin", function () { zoom: 10 }) .googlemap({ - start: 0, // seconds - end: 5, // seconds - type: 'SATELLITE', - target: 'map2', - location:'boston', - zoom: 15 - }) - .volume(0); - - popped.googlemap({ start: 0, // seconds end: 10, // seconds type: 'SATELLITE', target: 'map2', location:'toronto', zoom: 15 - }); + }); + var mapz = popped.googlemap({ + start: 0, // seconds + end: 15, // seconds + type: "STREETVIEW", + target: "map3", + location: "6th Line, Oakville, Ontario", + zoom: "1", + heading: "180", + pitch: "1", + interval: 1000, + tween: "York university" + }) + .volume(0); setupId = popped.getLastTrackEventId(); @@ -72,18 +78,25 @@ test("Popcorn Google Map Plugin", function () { plus(); }); - popped.exec( 6, function() { + popped.exec( 4, function() { + equals (document.getElementById('actualmap3').offsetParent.id, "map3", "Tweening map is inside the 'map3' div" ); + plus(); + }); + + popped.exec( 20, function() { ok (document.getElementById('actualmap2').style.display === "none" && - document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" ); + document.getElementById('actualmap1').style.display === "none" && + document.getElementById('actualmap3').style.display === "none", "All maps are no longer visible" ); plus(); popped.pause(); popped.removeTrackEvent( setupId ); - ok( !document.getElementById('actualmap3'), "removed map was properly destroyed" ); + ok( !document.getElementById('actualmap4'), "removed map was properly destroyed" ); plus(); }); popped.play(); }); +