# HG changeset patch # User Nicholas Jillings # Date 1428675709 -3600 # Node ID 2c25ca4d7ec604b71731c95ab21abb39d45f85a2 # Parent 88a5278b93323e51c6f3b0f0b1053cef906d91b6 Really complete state machine with post test commands diff -r 88a5278b9332 -r 2c25ca4d7ec6 ape.js --- 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