################################################################################
# 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 home = "http://mercurytours.mercuryinteractive.com/";
	auto browser = getenv( "BROWSER" );
	
	rc = web_browser_invoke( (!browser*1 ? IE : browser), home );
	rc+= set_window( "Login", 30 );
	
    return rc;
}


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

public function AUT_close ()
{
	auto rc;
	static wins[] = {
		"MessageBox"
		,"Browser"
	};
	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 ()
{
	return E_OK;
}


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

public function AUT_kill ()
{
	# your code here
}


# Sicherheitshinweis
public function close_security_alerts()
{
	auto again, hit;
	auto rc, ex;
	# maximum of ten etemps
	again=10;

	set_timeout( 1 );
#	printf( "Close unwanted windows" );
	while( again > 0)
	{
		hit=0;
		ex=win_exists( "SecurityAlert" );
#		report_msg( "exists 2:"& ex );
		if( ex == E_OK )
		{
			rc=win_activate( "SecurityAlert" );
			rc=set_window( "SecurityAlert" );
			if ( obj_exists( "No" ) == E_OK )
				rc=button_press( "No" );
			else if ( obj_exists( "OK" ) == E_OK )
				rc=button_press( "OK" );
			else
				rc=win_close( "SecurityAlert" );
			hit=1;
		}
		if( hit != 0 )
		{
			again--;
			wait( 1 );
		}
		else
			again=0;
	} 
	restore_timeout();
}
