123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Virtual World Framework</title>
- <script type="text/javascript" src="qunit.js"></script>
- <script type="text/javascript" src="../lib/async.js"></script>
- <script type="text/javascript" src="../lib/crypto.js"></script>
- <script type="text/javascript" src="../lib/md5.js"></script>
- <script type="text/javascript" src="../lib/alea.js"></script>
- <script type="text/javascript" src="../lib/mash.js"></script>
- <script type="text/javascript" src="../lib/vwf.js"></script>
- <script type="text/javascript" src="../lib/require.js"></script>
- <script type="text/javascript">
- require( {
- baseUrl: "../lib",
- paths: {
- jquery: "jquery-1.10.2.min",
- },
- }, [
- "domReady",
- "utility.js",
- // This is the common model implementation and an example model that connects the
- // simulation to a WebGL scene manager.
- "jquery",
- "vwf/configuration",
- "vwf/kernel/model",
- "vwf/model/javascript",
- "vwf/model/object",
- "vwf/model/stage/log",
- "vwf/kernel/view",
- "vwf/kernel/utility",
- "vwf/utility",
- "logger",
- ], function( ready, testUtility ) {
- ready( function() {
- vwf.initialize(
- /* models */ [ "vwf/model/javascript", "vwf/model/object" ],
- /* views */ [ ]
- );
- module( "initialize() inheritance" );
- // node and prototype execute their own initializers.
- asyncTest( "node and prototype initializers", function() {
-
- create_node_prototype_with_initializers( true, true, function( nodeID, prototypeID, cleanup ) {
- equal( vwf.getProperty( nodeID, "property" ), "node", "node's initialization" );
- equal( vwf.getProperty( prototypeID, "property" ), "prototype", "prototype's initialization" );
- cleanup();
- start();
- } );
- } );
- // node's initializer runs for node even when prototype's initializer is not provided.
- asyncTest( "node initializer", function() {
-
- create_node_prototype_with_initializers( true, false, function( nodeID, prototypeID, cleanup ) {
- equal( vwf.getProperty( nodeID, "property" ), "node", "node's initialization" );
- equal( vwf.getProperty( prototypeID, "property" ), null, "prototype's initialization" );
- cleanup();
- start();
- } );
- } );
- // node is initialized by prototype's initializer when it doesn't provide one itself.
- asyncTest( "prototype initializer", function() {
-
- create_node_prototype_with_initializers( false, true, function( nodeID, prototypeID, cleanup ) {
- equal( vwf.getProperty( nodeID, "property" ), "prototype", "node's initialization" );
- equal( vwf.getProperty( prototypeID, "property" ), "prototype", "prototype's initialization" );
- cleanup();
- start();
- } );
- } );
- // no initializers run if none are provided.
- asyncTest( "no initializers", function() {
-
- create_node_prototype_with_initializers( false, false, function( nodeID, prototypeID, cleanup ) {
- equal( vwf.getProperty( nodeID, "property" ), null, "node's initialization" );
- equal( vwf.getProperty( prototypeID, "property" ), null, "prototype's initialization" );
- cleanup();
- start();
- } );
- } );
- // == Helper functions =====================================================================
- // Create a VWF object with two levels of inheritance using the given initializers. Add a
- // "property" property to each.
- function create_node_prototype( node, prototype, callback /* ( nodeID, prototypeID ) */ ) {
- prototype.properties = prototype.properties || {};
- prototype.properties.property = prototype.properties.property || null;
- vwf.createNode( prototype, function( prototypeID ) {
- node.extends = prototypeID;
- node.properties = node.properties || {};
- node.properties.property = node.properties.property || null;
- vwf.createChild( 0, testUtility.uniqueName( "node" ), node, undefined, function( nodeID ) {
- callback( nodeID, prototypeID, function() {
- vwf.deleteNode( nodeID );
- vwf.deleteNode( prototypeID );
- } );
- } );
- } );
- }
- // Create a node with a prototype. Add initialize() methods as specified to set the
- // "property" property.
- function create_node_prototype_with_initializers( node_init, prototype_init, callback /* ( nodeID, prototypeID ) */ ) {
- var node = {};
- if ( node_init ) {
- node.scripts = [ {
- text: "this.initialize = function() { this.property = \"node\" }",
- type: "application/javascript"
- } ];
- }
- var prototype = {};
- if ( prototype_init ) {
- prototype .scripts = [ {
- text: "this.initialize = function() { this.property = \"prototype\" }",
- type: "application/javascript"
- } ];
- }
- create_node_prototype( node, prototype, callback /* ( nodeID, prototypeID ) */ );
- }
- } );
- } );
- </script>
- <link rel="stylesheet" type="text/css" href="qunit.css" />
- </head>
- <body>
- <h1 id="qunit-header">Virtual World Framework</h1>
- <h2 id="qunit-banner"></h2>
- <div id="qunit-testrunner-toolbar"></div>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests"></ol>
- <div id="qunit-fixture">test markup, will be hidden</div>
- </body>
- </html>
|