[#480] _cleanup function for map plugin + tests

This commit is contained in:
ScottDowne 2011-04-15 13:05:36 -04:00
Родитель d7834ce3e5
Коммит a17ffa9150
4 изменённых файлов: 50 добавлений и 5 удалений

Просмотреть файл

@ -187,6 +187,10 @@ var googleCallback;
if (map) {
map.getDiv().style.display = "none";
}
},
_cleanup: function( options ) {
// the map must be manually removed
document.getElementById( options.target ).removeChild( newdiv );
}
};
},

Просмотреть файл

@ -1,7 +1,7 @@
test("Popcorn Google Map Plugin", function () {
var popped = Popcorn("#video"),
expects = 10,
expects = 11,
count = 0;
expect(expects);
@ -31,7 +31,7 @@ test("Popcorn Google Map Plugin", function () {
lat: 43.665429,
lng: -79.403323,
zoom: 10
} )
})
.googlemap({
start: 0, // seconds
end: 5, // seconds
@ -39,9 +39,20 @@ test("Popcorn Google Map Plugin", function () {
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 setupId = popped.getLastTrackEventId();
popped.exec( 4, function() {
ok(google.maps, "Google maps is available");
plus();
@ -62,7 +73,13 @@ test("Popcorn Google Map Plugin", function () {
popped.exec( 6, function() {
ok (document.getElementById('actualmap2').style.display === "none" &&
document.getElementById('actualmap1').style.display === "none", "Both maps are no lnger visible" );
document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" );
plus();
popped.pause();
popped.removeTrackEvent( setupId );
ok( !document.getElementById('actualmap3'), "removed map was properly destroyed" );
plus();
});

Просмотреть файл

@ -674,6 +674,7 @@
// Capture the position of the track being removed.
if ( o._id === trackId ) {
indexWasAt = i;
o._natives._cleanup && o._natives._cleanup.call( obj, o );
}
}
});

Просмотреть файл

@ -1358,7 +1358,7 @@ test("Remove Plugin", function () {
p2 = Popcorn("#video"),
rlen = Popcorn.registry.length,
count = 0,
expects = 19,
expects = 21,
interval;
function plus() {
@ -1450,6 +1450,29 @@ test("Remove Plugin", function () {
clearInterval( interval );
}
}, 1);
Popcorn.plugin( "cleanup", {
_setup: function( options ) {
options.exist = true;
},
_cleanup: function( options ) {
ok( true, "cleanup function is called during removal" );
plus();
ok( options.exist, "options object exists at time of cleanup" );
plus();
}
});
p2.cleanup({
start: 2,
end: 3
});
p2.removeTrackEvent( p2.getLastTrackEventId() );
p2.currentTime( 2 ).play();
});