More improvements
authorPhilippe Le Hégaret <plh@w3.org>
Sun, 30 Nov 2008 15:39:38 +0000
changeset 29 bbf9126163c6
parent 28 7e5cf36bcff7
child 30 6e425f448e80
More improvements
testsuite/web-framework/JWP.js
testsuite/web-framework/NCAM.js
testsuite/web-framework/START.html
testsuite/web-framework/functions.js
testsuite/web-framework/sample_player.js
testsuite/web-framework/style.css
testsuite/web-framework/tests.js
--- a/testsuite/web-framework/JWP.js	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/JWP.js	Sun Nov 30 15:39:38 2008 +0000
@@ -1,19 +1,22 @@
 // Display a video with the specified DFXP captioning document
 
-var JWP_NAME = "JW FLV Media Player 4.2";
+function JWP() {
+}
 
-addPlayer(JWP_NAME, "startJWPPlayer", "activeJWPTest", "stopJWPTest", "stopJWPPlayer");
+JWP.prototype.name = function() {
+    return "JW FLV Media Player 4.2";
+}
 
-function startJWPPlayer()
+JWP.prototype.startPlayer = function ()
 {
     if (document.URL.substring(0, 5) != "http:") {
 	alert("Note that the "
-	      + JWP_NAME
+	      + this.name()
 	      + " only works properly when accessing captioning files from a web server.");
     }
 }
 
-function activeJWPTest(test_number, filename, autostart, div) 
+JWP.prototype.startTest = function (test_number, filename, autostart, div) 
 {
 
     div.innerHTML = '';
@@ -38,11 +41,13 @@
     div.appendChild(embed);
 }
 
-function stopJWPTest(test_number) 
+JWP.prototype.stopTest = function (test_number) 
 {
 }
 
-function stopJWPPlayer()
+JWP.prototype.stopPlayer = function ()
 {
-    // nothing can be done?
-}
\ No newline at end of file
+    // nothing can be done
+}
+
+addPlayer(new JWP());
--- a/testsuite/web-framework/NCAM.js	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/NCAM.js	Sun Nov 30 15:39:38 2008 +0000
@@ -1,14 +1,16 @@
-addPlayer("NCAM Player 3.0.1", 
-	  "startNCAMPlayer", 
-	  "startNCAMTest", 
-	  "stopNCAMTest", 
-	  "stopNCAMPlayer");
 
-function startNCAMPlayer() {
+function NCAM() {
+}
+
+NCAM.prototype.name = function() {
+    return "NCAM Player 3.0.1";
+}
+
+NCAM.prototype.startPlayer = function() {
     // nothing needs to be done
 }
 
-function startNCAMTest(test_number, filename, autostart, div) {
+NCAM.prototype.startTest = function(test_number, filename, autostart, div) {
 
     var value = "ccPlayer.swf?ccVideoName=dfxp_movie.flv&ccVideoAutoStart="
 		   + autostart
@@ -63,12 +65,15 @@
 
 }
 
-function stopNCAMTest(test_number)
+NCAM.prototype.stopTest = function(test_number)
 {
     // nothing needs to be done
 }
 
-function stopNCAMPlayer()
+NCAM.prototype.stopPlayer = function()
 {
     // nothing needs to be done
-}
\ No newline at end of file
+}
+
+addPlayer(new NCAM());
+
--- a/testsuite/web-framework/START.html	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/START.html	Sun Nov 30 15:39:38 2008 +0000
@@ -9,9 +9,7 @@
     <script type="text/javascript" src='tests.js'></script>
     <script type="text/javascript" src='NCAM.js'></script>
     <script type="text/javascript" src='JWP.js'></script>
-<!--
     <script type="text/javascript" src='sample_player.js'></script>
--->
   </head>
   <body onload='init();'>
     <div id='header'>
--- a/testsuite/web-framework/functions.js	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/functions.js	Sun Nov 30 15:39:38 2008 +0000
@@ -1,3 +1,14 @@
+if (typeof XMLHttpRequest == "undefined" ) {
+    // Provide the XMLHttpRequest class for IE 5.x-6.x:
+    XMLHttpRequest = function() {
+	try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
+	try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
+	try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
+	try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
+	throw new Error( "This browser does not support XMLHttpRequest." )
+    };
+}
+
 
 //****************************
 // Handling the lists of tests
@@ -7,17 +18,19 @@
 // list of tests
 var tests = new Array();
 
-// Some constants to make it easier
-var NAME         = 0;
-var FILE         = 1;
-var DESCRIPTION  = 2;
-var CATEGORY     = 3;
-var CATEGORY_NUM = 4;
+function Test(name, filename, description, cat)
+{
+    this.name = name;
+    this.filename = filename;
+    this.description = description;
+    this.category = cat;
+}
+
 
 function addTest(filename, name, description, category)
 {
     var cat = addCategory(category);
-    tests[tests.length] = new Array(name, filename, description, cat);
+    tests[tests.length] = new Test(name, filename, description, cat);
 }
 
 //*********************************
@@ -71,33 +84,17 @@
 // list of players
 var players = new Array();
 // the player in use
-var player = 0;
+var player = null;
 var autostart = false;
 
-// A constant to make it easier to access the array
-// var NAME = 0; is already defined
-var START_PLAYER_FUNCTION_NAME = 1;
-var START_TEST_FUNCTION_NAME   = 2;
-var STOP_TEST_FUNCTION_NAME    = 3;
-var STOP_PLAYER_FUNCTION_NAME  = 4;
-
-function addPlayer(name,
-		   startFunctionName,
-		   startTestFunctionName, 
-		   stopTestFunctionName, 
-		   stopFunctionName)
+function addPlayer(player)
 {
-    players[players.length] = new Array(name,
-					startFunctionName,
-					startTestFunctionName, 
-					stopTestFunctionName, 
-					stopFunctionName);
+    players[players.length] = player;
 }
 
 
 // switch from one player to an other
 function switchPlayer(nPlayer) {
-
     // remove the test currently in use
     clearTestArea();
 
@@ -108,15 +105,16 @@
     var report_content = document.getElementById("report_content");
     report_content.innerHTML = '';
 
-    if (player > 0) {
-	eval(players[player-1][STOP_PLAYER_FUNCTION_NAME] + "()");
+    if (player != null) {
+	player.stopPlayer();
     }
 
     // switch
-    player = nPlayer;
-
-    if (player > 0) {
-	eval(players[player-1][START_PLAYER_FUNCTION_NAME] + "()");
+    if (nPlayer == 0) {
+	player = null;
+    } else {
+	player = players[nPlayer-1];
+	player.startPlayer();
     }
 }
 
@@ -144,35 +142,23 @@
     }
 }
 
-if (typeof XMLHttpRequest == "undefined" ) {
-    // Provide the XMLHttpRequest class for IE 5.x-6.x:
-    XMLHttpRequest = function() {
-	try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
-	try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
-	try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
-	try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
-	throw new Error( "This browser does not support XMLHttpRequest." )
-    };
-}
 
 // Display the source of a test
-function displayTest(test_number) 
+function displayTest(test) 
 {
     var title=document.getElementById("title");
     var div = document.getElementById('testobject');
 
     clearTestArea();
 
-    if (test_number > -1 && test_number < tests.length) {
-	title.innerHTML = tests[test_number][FILE];
-	try {
-	    var xhr = new XMLHttpRequest();
-	    xhr.onreadystatechange = source_handler;
-	    xhr.open("GET", tests[test_number][FILE], true);
-	    xhr.send("");
-	} catch (e) {
-	    div.innerHTML = "<p style='font-weight: bold'>No player selected...</p>";
-	}
+    title.innerHTML = test.filename;
+    try {
+	var xhr = new XMLHttpRequest();
+	xhr.onreadystatechange = source_handler;
+	xhr.open("GET", test.filename, true);
+	xhr.send("");
+    } catch (e) {
+	div.innerHTML = "<p style='font-weight: bold'>Unable to retrieve the source code?</p>";
     }
 }
 
@@ -185,19 +171,18 @@
     if (test_number > -1 && test_number < tests.length) {
 	stopTest(currentTest);
 
-	title.innerHTML = tests[test_number][NAME];
-	descr.innerHTML = tests[test_number][DESCRIPTION];
-	if (player == 0) {
+	title.innerHTML = tests[test_number].name;
+	descr.innerHTML = tests[test_number].description;
+	if (player == null) {
 	    var div = document.getElementById('testobject');
 	    div.innerHTML = '<p><b>Choose a player...</b></p>';	    
 	} else {
 	    addResultButtons(test_number);
 	    
-	    eval(players[player-1][START_TEST_FUNCTION_NAME] + "("
-		 + test_number + ",\""
-		 + tests[test_number][FILE] + "\","
-		 + autostart
-		 + ", document.getElementById('testobject'))");
+	    player.startTest(test_number,
+			     tests[test_number].filename,
+			     autostart,
+			     document.getElementById('testobject'));
 	}
 	currentTest = test_number;
     }
@@ -208,7 +193,7 @@
 {
     var i = test_number + 1;
     while (i < results.length) {
-	if (category == 0 || category == tests[i][CATEGORY]) {
+	if (category == 0 || category == tests[i].category) {
 	    return i;
 	}
 	i++;
@@ -232,9 +217,8 @@
 function stopTest(test_number)
 {
     if (test_number > -1 && test_number < tests.length) {
-	if (player > 0) {
-	    eval(players[player-1][STOP_TEST_FUNCTION_NAME] + "("
-		 + test_number + ")");
+	if (player != null) {
+	    player.stopTest(test_number);
 	    currentTest = -1;
 	}
     }
@@ -437,8 +421,8 @@
     var report_content = document.getElementById("report_content");
     report_content.innerHTML = '';
 
-    if (player == 0 || total == 0) {
-	if (player == 0) {
+    if (player == null || total == 0) {
+	if (player == null) {
 	    var p = document.createElement("p");	    
 	    p.innerHTML = "Choose a player.";
 	    report_content.appendChild(p);
@@ -459,7 +443,7 @@
     report_content.appendChild(p);
 
     p = document.createElement("p");
-    p.innerHTML = "DFXP Player: " + players[player-1][NAME];
+    p.innerHTML = "DFXP Player: " + player.name();
     report_content.appendChild(p);
     
     var version = getFlashPlayerVersion();
@@ -484,7 +468,7 @@
 		if (s != '') {
 		    s += ', ';
 		}
-		s += tests[pass[i]][NAME];
+		s += tests[pass[i]].name;
 	    }
 	    p.innerHTML = pass.length + " test"
 		+ ((pass.length>1)?"s":"") + " passed: " + s + ".";
@@ -497,7 +481,7 @@
 		if (s != '') {
 		    s += ', ';
 		}
-		s += tests[fail[i]][NAME];
+		s += tests[fail[i]].name;
 	    }
 	    p.innerHTML = fail.length + " test" 
 		+ ((fail.length>1)?"s ":" ") + " failed:" + s + ".";
@@ -510,7 +494,7 @@
 		if (s != '') {
 		    s += ', ';
 		}
-		s += tests[cant_tell[i]][NAME];
+		s += tests[cant_tell[i]].name;
 	    }
 	    p.innerHTML = cant_tell.length + " test" 
 		+ ((cant_tell.length>1)?"s ":" ") + " cannot tell:" + s + ".";
@@ -543,13 +527,13 @@
 // onClick handler to display the tests
 //********************************************
 function onClickHandlerDisplayTest() {
-    displayTest(parseInt(this.getAttribute("test")));
+    displayTest(this.test);
 }
 //********************************************
 // onClick handler to activate the tests
 //********************************************
 function onClickHandlerActiveTest() {
-    activeTest(parseInt(this.getAttribute("test")));
+    activeTest(this.test_number);
 }
 
 //********************************************
@@ -579,12 +563,9 @@
     select.appendChild(opt);
     for (i=0; i < players.length; i++) {
 	opt = document.createElement("option");
-	opt.innerHTML = players[i][NAME];
+	opt.innerHTML = players[i].name();
 	select.appendChild(opt);
     }
-    if (players.length > 0) {
-	player = 0;
-    }
 
     // populate the category list
     var select = document.getElementById("categories");
@@ -618,27 +599,27 @@
 	var tbody = document.createElement("tbody");
 	table.setAttribute("id", "tcat" + c);
 	for (i=0; i < tests.length; i++) {
-	    if (c == tests[i][CATEGORY]) {
+	    if (c == tests[i].category) {
 		var tr = document.createElement("tr");
 		var th = document.createElement("th");
 		var b = document.createElement("input");
 		b.setAttribute("type", "button");
 		// b.setAttribute("onclick", "activeTest(i)"); doesn't work on IE :-(
 		// so here is a workaround
-		b.setAttribute("test", (i).toString(10));
+		b.test_number = i;
 		b.onclick = onClickHandlerActiveTest;
-		b.setAttribute("value", tests[i][NAME]);
+		b.setAttribute("value", tests[i].name);
 		th.appendChild(b);
 		tr.appendChild(th);
 		td = document.createElement("td"); // for the source
 		if (!isRemote) {
 		    var a = document.createElement("a");
-		    a.setAttribute("href", tests[i][FILE]);
+		    a.setAttribute("href", tests[i].filename);
 		    a.innerHTML = "[source]";
 		    td.appendChild(a);
 		} else {
 		    var span = document.createElement("span");
-		    span.setAttribute("test", (i).toString(10));
+		    span.test = tests[i];
 		    span.onclick = onClickHandlerDisplayTest;
 		    span.innerHTML = "[source]";
 		    td.appendChild(span);		    
--- a/testsuite/web-framework/sample_player.js	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/sample_player.js	Sun Nov 30 15:39:38 2008 +0000
@@ -1,46 +1,52 @@
-// Display a video with the specified DFXP captioning document
-// 1. Create one function with no parameter to start your player.
-// 2. Create a function to start your player with a test, as follows:
-//    a. the function takes five parameters:
-//       1. integer: The test unique number
-//       2. string: filename of the test
-//       3. boolean: if autostart should be on or off
-//       4. DOM Element: the DOM div element containing your player object
-//    b. the player goes in <div id="testarea">
-// 3. Create a function to stop your player, as follows:
-//    a. the function takes one parameter:
-//       1. integer: The test unique number
-// 4. Create one function with no parameter to stop your player.
-// 5. Invoke addPlayer("name of the player",
-//                     "yourStartPlayerFunctionName",
-//                     "yourStartTestFunctionName", 
-//                     "yourStopTestFunctionName",
-//                     "yourStopPlayerFunctionName") to add your player
+// This is a sample of what needs to be implement for
+// a DFXP presentation processor in order to add it in
+// the test framework
 
-addPlayer("Sample Player 3.0.1", 
-	  "startSamplePlayer", 
-	  "startSampleTest", 
-	  "stopSampleTest", 
-	  "stopSamplePlayer");
+function SamplePlayer() {
+}
 
-function startSamplePlayer() {
+// The name of your player.
+
+SamplePlayer.prototype.name = function () {
+  return "Sample Player";
+}
+
+// Start your player.
+
+SamplePlayer.prototype.startPlayer = function() {
     // nothing needs to be done
     alert("Start the sample player.");
 }
 
-function startSampleTest(test_number, filename, autostart, div) {
+// Run your player with a test
+//  test_number (integer): The test unique number
+//  filename (string): relative URI of the test
+//  autostart (boolean): if the player should start automatically or not
+//  div (DOM Element): the DOM div element containing your player object
+
+SamplePlayer.prototype.startTest = function(test_number, filename, autostart, div) {
 
     alert("Start the sample player with the test " + test_number);
 }
 
-function stopSampleTest(test_number)
+// Stop your player running wit a certain test
+//   test_number (integer): The test unique number
+
+SamplePlayer.prototype.stopTest = function(test_number)
 {
     // nothing needs to be done
     alert("Stop the sample player with the test " + test_number);
 }
 
-function stopSamplePlayer()
+// Stop your player.
+
+SamplePlayer.prototype.stopPlayer = function()
 {
     // nothing needs to be done
     alert("Stop the sample player.");
-}
\ No newline at end of file
+}
+
+// Add your player in the list
+
+addPlayer(new SamplePlayer());
+
--- a/testsuite/web-framework/style.css	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/style.css	Sun Nov 30 15:39:38 2008 +0000
@@ -30,11 +30,12 @@
               padding-top: 1em;
               }
 #testobject pre { 
-              margin-top: -1em;
-              font-size: small;
-              width: 85ex;
-              height: 33em;
-              overflow: scroll;
+                  margin-top: -1em;
+                  font-size: small;
+                  width: auto;
+                  height: 33em;
+                  overflow: auto;
+                  border: 1px solid black;
               }
 
 /* The set of options in the top area */
@@ -76,6 +77,8 @@
   position: absolute;
   top: 8.5em;
   left: 50ex;
+  right: 1ex;
+  bottom: 1ex;
   border-left: 2px solid #ccc;
   padding-left: 1ex;
 }
--- a/testsuite/web-framework/tests.js	Wed Nov 26 14:51:09 2008 +0000
+++ b/testsuite/web-framework/tests.js	Sun Nov 30 15:39:38 2008 +0000
@@ -16,6 +16,15 @@
 addTest("../Content/tt001.xml","tt001","Test the tt element without an xml:space attribute.","Content Test");
 addTest("../Content/tt002.xml","tt002","Test the tt element with xml:space preserve.","Content Test");
 addTest("../Content/tt003.xml","tt003","Test the tt element with xml:space default.","Content Test");
+addTest("../Styling/BackgroundColor001.xml","BackgroundColor001","Test tts:backgroundColor attribute using a named color expression in a div.","Styling Test");
+addTest("../Styling/BackgroundColor002.xml","BackgroundColor002","Test tts:backgroundColor attribute using a hash (#rrggbb) color expression in a div.","Styling Test");
+addTest("../Styling/BackgroundColor003.xml","BackgroundColor003","Test tts:backgroundColor attribute using a hash (#rrggbbaa) color expression with opacity on the body.","Styling Test");
+addTest("../Styling/BackgroundColor004.xml","BackgroundColor004","Test tts:backgroundColor attribute using a rgb() color function on the body.","Styling Test");
+addTest("../Styling/BackgroundColor005.xml","BackgroundColor005","Test tts:backgroundColor attribute using a rgba() color function using a span.","Styling Test");
+addTest("../Styling/BackgroundColor006.xml","BackgroundColor006","Test tts:backgroundColor attribute using a transparent value.","Styling Test");
+addTest("../Styling/BackgroundColor007.xml","BackgroundColor007","Test tts:backgroundColor using a named color expression on the div element.","Styling Test");
+addTest("../Styling/BackgroundColor008.xml","BackgroundColor008","Test tts:backgroundColor style using a named color expression in style.","Styling Test");
+addTest("../Styling/BackgroundColor009.xml","BackgroundColor009","Test tts:backgroundColor using a named color expression on the body.","Styling Test");
 addTest("../Styling/Color001.xml","Color001","Test tts:color attribute using a named color expression.","Styling Test");
 addTest("../Styling/Color002.xml","Color002","Test tts:color attribute using a hash (#rrggbb) color expression.","Styling Test");
 addTest("../Styling/Color003.xml","Color003","Test tts:color attribute using a hash (#rrggbbaa) color expression with opacity.","Styling Test");
@@ -25,12 +34,21 @@
 addTest("../Styling/Color007.xml","Color007","Test tts:color attribute using a transparent value.","Styling Test");
 addTest("../Styling/Color008.xml","Color008","Test tts:color attribute with span elements.","Styling Test");
 addTest("../Styling/Color009.xml","Color009","Test tts:color style using a named color expression.","Styling Test");
+addTest("../Styling/Style001.xml","Style001","Test style attributes in the style element.","Styling Test");
+addTest("../Styling/Styling001.xml","Styling001","Test two different styles in the style element.","Styling Test");
+addTest("../Styling/TextAlign001.xml","TextAlign001","Test tts:textAlign attribute with the right value in a paragraph.","Styling Test");
+addTest("../Styling/TextAlign002.xml","TextAlign002","Test tts:textAlign attribute with the left value in a span.","Styling Test");
+addTest("../Styling/TextAlign003.xml","TextAlign003","Test tts:textAlign attribute with the center value in style.","Styling Test");
+addTest("../Styling/TextAlign004.xml","TextAlign004","Test tts:textAlign attribute with the right value on the body.","Styling Test");
+addTest("../Styling/TextAlign005.xml","TextAlign005","Test tts:textAlign attribute with the left value on div.","Styling Test");
+addTest("../Styling/TextAlign006.xml","TextAlign006","Test tts:textAlign attribute with the center value on a span.","Styling Test");
+addTest("../Styling/TextDecoration001.xml","TextDecoration001","Test tts:textDecoration attribute using the none value.","Styling Test");
+addTest("../Styling/TextDecoration002.xml","TextDecoration002","Test tts:textDecoration attribute using the underline value in a span.","Styling Test");
+addTest("../Styling/TextDecoration003.xml","TextDecoration003","Test tts:textDecoration attribute using the none value in a span.","Styling Test");
+addTest("../Styling/TextDecoration004.xml","TextDecoration004","Test tts:textDecoration attribute using the underline value in style.","Styling Test");
+addTest("../Styling/TextDecoration005.xml","TextDecoration005","Test tts:textDecoration attribute with the underline value in a div.","Styling Test");
+addTest("../Styling/TextDecoration006.xml","TextDecoration006","Test tts:textDecoration attribute with the underline value in the body.","Styling Test");
 addTest("../Timing/BeginDur001.xml","BeginDur001","Test the begin and dur attributes on p elements.","Timing Test");
 addTest("../Timing/BeginEnd001.xml","BeginEnd001","Test the begin and end attributes on p elements.","Timing Test");
 addTest("../Timing/BeginEnd002.xml","BeginEnd002","Test the begin attribute with no end or dur attribute on p elements.","Timing Test");
 addTest("../Timing/BeginEnd003.xml","BeginEnd003","Test the begin and end attributes on p elements in random order. @@Is it a valid test?","Timing Test");
-addTest("../Specification/DocumentExample120.xml","DocumentExample120","This test contains the document example from the section 1.2 of the DFXP 1.0 specification, without the layout region.","Specification Test");
-addTest("../Specification/DocumentExample822.xml","DocumentExample822","This test contains the document example from the section 8.2.2 of the DFXP 1.0 specification, with the region replacing with a styling.","Specification Test");
-addTest("../Specification/DocumentExample823.xml","DocumentExample823","This test contains the document example from the section 8.2.3 of the DFXP 1.0 specification, with the region replacing with a styling.","Specification Test");
-addTest("../Specification/DocumentExample824.xml","DocumentExample824","This test contains the document example from the section 8.2.4 of the DFXP 1.0 specification, with the region replacing with a styling.","Specification Test");
-addTest("../Specification/DocumentExample825.xml","DocumentExample825","This test contains the document example from the section 8.2.5 of the DFXP 1.0 specification, with the region replacing with a styling.","Specification Test");