changeset 666:2c25ca4d7ec6

Really complete state machine with post test commands
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 10 Apr 2015 15:21:49 +0100
parents 88a5278b9332
children 2cc25941c433
files ape.js
diffstat 1 files changed, 33 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ape.js	Fri Apr 10 15:09:33 2015 +0100
+++ b/ape.js	Fri Apr 10 15:21:49 2015 +0100
@@ -303,6 +303,12 @@
 		var testId = currentState.substr(11,currentState.length-10);
 		var preTest = testXMLSetups.find('PreTest')[testId];
 		this.value = preTestButtonClick(preTest,this.value);
+	} else if (currentState.substr(0,11) == 'testRunPost')
+	{
+		// Specific test post-test
+		var testId = currentState.substr(12,currentState.length-11);
+		var preTest = testXMLSetups.find('PostTest')[testId];
+		this.value = preTestButtonClick(preTest,this.value);
 	} else if (currentState == 'postTest')
 	{
 		// At the end of the test, running global post test
@@ -402,6 +408,9 @@
 		// Start the test
 		var testId = currentState.substr(11,currentState.length-10);
 		currentState = 'testRun-'+testId;
+	} else if (currentState.substr(0,11) == 'testRunPost')
+	{
+		testEnded(testId);
 	} else if (currentState.substr(0,7) == 'testRun')
 	{
 		var testId = currentState.substr(8,currentState.length-7);
@@ -409,30 +418,38 @@
 		var postXML = testXMLSetups.find('PostTest')[testId];
 		if (postXML.children.length > 0)
 		{
-			console.log('POST TEST')
+			currentState = 'testRunPost-'+testId; 
+			showPopup();
+			preTestPopupStart(postXML);
 		}
-		// else
+		else {
 		
 		
-		// No post tests, check if we have another test to perform instead
-		if (testXMLSetups.length-1 > testId)
-		{
-			// Yes we have another test to perform
-			currentState = 'testRun-'+Number(testId)+1;
-			loadTest(testId+1);
-		} else {
-			console.log('Testing Completed!');
-			currentState = 'postTest';
-			// Check for any post tests
-			var xmlSetup = projectXML.find('setup');
-			var postTest = xmlSetup.find('PostTest')[0];
-			showPopup();
-			preTestPopupStart(postTest);
+			// No post tests, check if we have another test to perform instead
+			testEnded(testId);
 		}
 	}
 	console.log(currentState);
 }
 
+function testEnded(testId)
+{
+	if (testXMLSetups.length-1 > testId)
+	{
+		// Yes we have another test to perform
+		currentState = 'testRun-'+Number(testId)+1;
+		loadTest(testId+1);
+	} else {
+		console.log('Testing Completed!');
+		currentState = 'postTest';
+		// Check for any post tests
+		var xmlSetup = projectXML.find('setup');
+		var postTest = xmlSetup.find('PostTest')[0];
+		showPopup();
+		preTestPopupStart(postTest);
+	}
+}
+
 function buttonSubmitClick()
 {
 	// This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options