#!/bin/sh

. functions

output=${1:-validity}

test1() {
cat <<EOF
def eventFunc (form) :
    return form.check.__events__.onclick()
EOF
}

test2() {
cat <<EOF
def eventFunc (form) :
    form.Field_1.value = 'text'
    form.Field_2.value = 'text'
    form.Choice_1.setCurrentItem(0, 0)
    form.Choice_2.setCurrentItem(0, 1)
    return form.check.__events__.onclick()
EOF
}

test3() {
cat <<EOF
def eventFunc (form) :
    form.Field_1.value = 'text'
    form.Field_2.value = '123'
    form.Choice_1.setCurrentItem(0, 1)
    form.Choice_2.setCurrentItem(0, 1)
    return form.check.__events__.onclick()
EOF
}


$rekall $style --skipSplash RekallAutoTest.rkl 2>/dev/null &
     PID=$!
rekallID=$rekall-$PID
   retry=0

waitForRekall $rekallID

[ $output == 'validity' ] && {
	mkdir -p validity
	clean	 validity
}

echo "DCOP Validity test:"

$dcop $rekallID rekall-part-form  'openObject(QString,QString,int)' 'MySQL' "Validity" 1 > /dev/null
$dcop $rekallID rekall-form/Validity  'executeScript(QString)' "`test1`" > $output/Test1
$dcop $rekallID rekall-form/Validity  'executeScript(QString)' "`test2`" > $output/Test2
$dcop $rekallID rekall-form/Validity  'executeScript(QString)' "`test3`" > $output/Test3

kill	$PID
