################################################################################
# LIBRARY:	AUT_lib
################################################################################
# $Revision: 1.2 $
# $Author: drajovic $
# $Date: 2002/12/16 18:34:45 $
# $Source: d:/Archive/CVS_QS/EMOS/EMOS_FRM_EXAMPLES/FlightDemo/Scripts/LIB/AUT_lib/script,v $
# $NoKeywords: $
################################################################################

#/***
#* This library contains application-specific routines such as
#* synchronisation with status object or setting up the typical 
#* initial state (new order).
#*/

#/**
#* Invokes the AUT
#* @return E_OK on success otherwise !E_OK
#*/

public function AUT_invoke ()
{
    auto rc;
	auto appDir = getenv("M_ROOT") & "\\samples\\flight\\app";
	auto app = "flight1a.exe";
	
	rc = invoke_application( app, "", appDir, SW_SHOW );
	rc+= set_window( "Login", 30 );
	
    return rc;
}

#/**
#*	Closes the AUT
#*/

public function AUT_close ()
{
	auto rc;
	static wins[] = {
		"PopupMessage"
		,"Login"
		,"Open Order"
		,"Search Results"
		,"Flight Reservation"
	};
	AUT_reset();
	rc = EMOS_win_close_all( wins );
	if ( rc != E_OK )
		AUT_kill();
}


#/**
#* Closes all windows other than main application window.
#* @return E_OK if set_window() succeeded on main window else !E_OK
#*/

public function AUT_reset ()
{
	auto rc;
	auto mainWindow = "Flight Reservation";
	static wins[] = {
		 "PopupMessage"  
		,"FlightsTable"
		,"Open Order"
		,"Search Results"
	};
	
	if ( win_exists( mainWindow ) != E_OK )
		return rc;
	rc = EMOS_win_close_all( wins );
	if ( rc == E_OK )
		rc = set_window( mainWindow, 1 );
	return rc;
}


#/**
#*	Kills the AUT (via Task Manager or so).
#*/

public function AUT_kill ()
{
	# your code here
}

#/*
#* Waits for the specified <code>label</code> to appear in status object.
#* @param label (in) string to wait for
#* @param time (in) number of seconds (minus default timeout) to wait for
#* @return E_OK if text appeared within given period else !E_OK
#*/

public function AUT_wait_status ( in label, in time )
{
	auto rc;
	rc = set_window("Flight Reservation");
	if ( rc != E_OK )
		return rc;
	rc = obj_wait_info("StatusBar", "label", label, time);
	return rc;
}

#/*
#* Stores the order number in a globar Framework variable.
#* @param varname (in) name of the global Framework variable
#* @return E_OK if the variable was saved else !E_OK
#*/

public function AUT_save_order_nr ( in varname )
{
	auto rc;
	auto val;
	
	rc = set_window("OrderInformation", 10);
	rc += edit_get_text("Order No:", val);
	if ( rc != E_OK )
		return rc;
	# stores the order number in a globar Framework variable
	rc = FRM_setvar( "", varname, val );
	return rc;
}

