#!/bin/bash

source ../share/apkg-funclib

echo "GUI Protocol test suite"
cyan; echo "* TWO"; normal;
echo

autopackage_pipe="pipe$$"
mkfifo $autopackage_pipe

( # fork a subshell

waitForHELLO "W00t";

outputStatus "Testing status function...."

outputTest "for passed test"
outputTestPass
outputTest "for failed test"
outputTestFail
outputTest "with a recommended this time"
outputTestRecommend

outputFail "This is just a test failure, we're doing OK really"
outputStatus ""

interactString "VAR1" "Kickass" "What is autopackage?"
switchGroup "cool_group" "The coolest group"
interactString "VAR2" "The Avenger" "What is your name"
interactPath "VAR3" "~/foo" "Where is foo installed?"
interactString "VAR4" "drool" "Matrix 2?"
switchGroup "default"
interactString "VAR5" "ok" "And back to the default group"

waitForInteractions

var1=`get VAR1`
switchGroup "cool_group"
var2=`get VAR2`
var3=`get VAR3`
var4=`get VAR4`

outputStatus "
autopackage is $var1
your name is $var2
demo of tilde expansion = $var3
the matrix is $var4"

outputStatus "Entering new session"

waitForHELLO "Test 2"
outputTest "one"
outputTestPass
outputTest "two"
outputTestRecommend
terminateFE;

outputStatus "That's all folks!"

terminateFE;
usleep 100000

) &     # the above script will be forked into the background, so the ttyfe will gain control of stdin/stdout

../share/apkg-ttyfe "$autopackage_pipe"
rm $autopackage_pipe
