|
@@ -1,9 +1,15 @@
|
|
|
module( "Serialization" );
|
|
|
|
|
|
-test( "Test Serialization", function() {
|
|
|
+asyncTest( "Test Serialization", function() {
|
|
|
|
|
|
// setup
|
|
|
var editor = new Editor();
|
|
|
+ editor.storage.init( function () {
|
|
|
+
|
|
|
+ performTests();
|
|
|
+ start(); // continue running other tests
|
|
|
+
|
|
|
+ } );
|
|
|
|
|
|
var green = 12581843; // bffbd3
|
|
|
|
|
@@ -100,7 +106,6 @@ test( "Test Serialization", function() {
|
|
|
return "setGeometry";
|
|
|
};
|
|
|
|
|
|
-
|
|
|
var setGeometryValue = function() {
|
|
|
|
|
|
var box = aBox( 'Geometry Value Box' );
|
|
@@ -270,56 +275,60 @@ test( "Test Serialization", function() {
|
|
|
setValue
|
|
|
];
|
|
|
|
|
|
- // Forward tests
|
|
|
+ function performTests() {
|
|
|
|
|
|
- for ( var i = 0; i < setups.length ; i++ ) {
|
|
|
+ // Forward tests
|
|
|
|
|
|
- var name = setups[i]();
|
|
|
+ for ( var i = 0; i < setups.length ; i++ ) {
|
|
|
|
|
|
- // Check for correct serialization
|
|
|
+ var name = setups[i]();
|
|
|
|
|
|
- editor.history.goToState( 0 );
|
|
|
- editor.history.goToState( 1000 );
|
|
|
+ // Check for correct serialization
|
|
|
|
|
|
- var history = JSON.stringify( editor.history.toJSON() );
|
|
|
+ editor.history.goToState( 0 );
|
|
|
+ editor.history.goToState( 1000 );
|
|
|
|
|
|
- editor.history.clear();
|
|
|
+ var history = JSON.stringify( editor.history.toJSON() );
|
|
|
|
|
|
- editor.history.fromJSON( JSON.parse( history ) );
|
|
|
+ editor.history.clear();
|
|
|
|
|
|
- editor.history.goToState( 0 );
|
|
|
- editor.history.goToState( 1000 );
|
|
|
+ editor.history.fromJSON( JSON.parse( history ) );
|
|
|
|
|
|
- var history2 = JSON.stringify( editor.history.toJSON() );
|
|
|
+ editor.history.goToState( 0 );
|
|
|
+ editor.history.goToState( 1000 );
|
|
|
|
|
|
- ok( history == history2 , "OK, forward serializing was successful for " + name );
|
|
|
+ var history2 = JSON.stringify( editor.history.toJSON() );
|
|
|
|
|
|
- editor.clear();
|
|
|
+ ok( history == history2 , "OK, forward serializing was successful for " + name );
|
|
|
|
|
|
- }
|
|
|
+ editor.clear();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Backward tests
|
|
|
|
|
|
- // Backward tests
|
|
|
+ for (var i = 0; i < setups.length ; i++ ) {
|
|
|
|
|
|
- for (var i = 0; i < setups.length ; i++ ) {
|
|
|
+ var name = setups[i]();
|
|
|
|
|
|
- var name = setups[i]();
|
|
|
+ editor.history.goToState( 0 );
|
|
|
|
|
|
- editor.history.goToState( 0 );
|
|
|
+ var history = JSON.stringify( editor.history.toJSON() );
|
|
|
|
|
|
- var history = JSON.stringify( editor.history.toJSON() );
|
|
|
+ editor.history.clear();
|
|
|
|
|
|
- editor.history.clear();
|
|
|
+ editor.history.fromJSON( JSON.parse( history ) );
|
|
|
|
|
|
- editor.history.fromJSON( JSON.parse( history ) );
|
|
|
+ editor.history.goToState( 1000 );
|
|
|
+ editor.history.goToState( 0 );
|
|
|
|
|
|
- editor.history.goToState( 1000 );
|
|
|
- editor.history.goToState( 0 );
|
|
|
+ var history2 = JSON.stringify( editor.history.toJSON() );
|
|
|
|
|
|
- var history2 = JSON.stringify( editor.history.toJSON() );
|
|
|
+ ok( history == history2 , "OK, backward serializing was successful for " + name );
|
|
|
|
|
|
- ok( history == history2 , "OK, backward serializing was successful for " + name );
|
|
|
+ editor.clear();
|
|
|
|
|
|
- editor.clear();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|