#! /bin/sh

progname=`echo $0 | sed -e 's%.*/%%g'`
curdir=`pwd`
bindir=/usr/bin
libdir=/usr/lib
pkglibdir=/usr/lib/ccafe-0.8.8
pkgdatadir=/usr/share/ccafe-0.8.8
binsuffix=
tmpfile=""
if test ! -w $curdir ; then
  tmpfile=`mktemp -q /tmp/$progname.out.XXXXXXXXX`
  if [ $? -ne 0 ]; then
     echo "$progname: Can't create temp file /tmp/$progname.out. Exiting..."
     exit 1
  fi
else
  tmpfile=`mktemp -q $curdir/$progname.out.XXXXXXXXX`
  if [ $? -ne 0 ]; then
     echo "$progname: Can't create temp file $curdir/$progname.out. Exiting..."
     exit 1
  fi
fi
#LD_LIBRARY_PATH=/usr/lib:"$LD_LIBRARY_PATH"; export LD_LIBRARY_PATH
#SIDL_DLL_PATH=$libdir;export SIDL_DLL_PATH
answer1="Instance Name: PP_1 Class Name: ::ccafeopq::ports::ParameterPort"
answer2="Instance Name: ppf Class Name: ::ccafeopq::ports::ParameterPortFactory"
answer3="WITHOUT babel"
answer4="BPPFTEST:  sVar = some value"
echo "====================================================================="
echo "                  Testing the opaque dialog svc ...                    "

echo "proceeding with env vars:"
echo "# LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo "# SIDL_DLL_PATH=$SIDL_DLL_PATH"

frame_opts="--ccafe-rc $pkgdatadir/EmptyRC"

if $bindir/ccafe-single$binsuffix $frame_opts << EOF >$tmpfile 2>&1

path set $libdir
path append $pkgdatadir/components
# Do Babel stuff now ...
repository get-global ccafe4.ParameterPortFactoryTest
instantiate ccafe4.ParameterPortFactoryTest
display component ParameterPortFactoryTest0
go ParameterPortFactoryTest0 go
display component ParameterPortFactoryTest0
# test ui setting
configure ParameterPortFactoryTest0 PP_1 sVar
configure ParameterPortFactoryTest0 PP_1 sVar changedValue
configure ParameterPortFactoryTest0 PP_1 sVar

bye
EOF
then
	echo -n "didn't crash or hang up early ...  "
else
	echo -n "didn't make it all the way through ...  "
fi
if (grep "$answer1" $tmpfile >/dev/null 2>&1) && 
   (grep "$answer2" $tmpfile >/dev/null 2>&1) &&
   (grep "$answer4" $tmpfile >/dev/null 2>&1) 
then
	echo looks like it is working.
	dumptrash=yes
else
	echo "The output indicates parameterservice stuff is inoperative."
	echo "But this is expected for now... This is just a linking test."
	echo "Results are in $tmpfile"
fi
echo      done with testBabelParameterPortFactory
echo "====================================================================="
if test "X$dumptrash" = "XYes" ; then
	rm -f $tmpfile
fi

