<head></head><body><pre></font><font color="#ff0000"><i>################################################################################</font></i><font color=black>
</font><font color="#ff0000"><i># LIBRARY:	FRM_lib</font></i><font color=black>
</font><font color="#ff0000"><i>################################################################################</font></i><font color=black>
</font><font color="#ff0000"><i># $Revision: 1.3 $</font></i><font color=black>
</font><font color="#ff0000"><i># $Author: drajovic $</font></i><font color=black>
</font><font color="#ff0000"><i># $Date: 2002/12/16 18:34:11 $</font></i><font color=black>
</font><font color="#ff0000"><i># $Source: d:/Archive/CVS_QS/EMOS/EMOS_FRM_EXAMPLES/FlightDemo/Scripts/LIB/FRM_lib/script,v $</font></i><font color=black>
</font><font color="#ff0000"><i># $NoKeywords: $</font></i><font color=black>
</font><font color="#ff0000"><i>################################################################################</font></i><font color=black>

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/***
#* This library contains generic Framework-related functions. 
#* "Generic" means that they are likely to be used in all contexts.
#*/</font></i><font color=black>

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* This is the short version of Prolog() with the difference that it does not attempt 
#* to log in. It ensures that the Login window is open instead of the main AUT window. 
#* This was done so that we can test the login dialog on its own.
#*
#* @see &lt;a href="../../images/Prolog.jpg"&gt;GUI&lt;/a&gt;
#* @see &lt;a href="../../images/Prolog_block.jpg"&gt;Excel&lt;/a&gt;
#*/</font></i><font color=black>

<b>public</b> <b>function</b> FRM_Prolog ( <b>in</b> table, <b>in</b> test, <b>in</b> idx, <b>in</b> mode )
{
	<b>auto</b> rc;
	<b>auto</b> force;
	<b>static</b> wins[] = {
		 </font><font color="#00bb00">"MessageBox"</font><font color=black>  
		,</font><font color="#00bb00">"SecurityAlert"</font><font color=black>
	};

	rc = FRM_init_block( table, test, idx, mode );
	<b>if</b> ( rc != E_OK ) 
		<b>return</b> rc;
	rc = FRM_get_next( table, test, force );  </font><font color="#ff0000"><i># get "Force login?" flag from table</font></i><font color=black>
	<b>if</b> ( rc == E_FRM_SKIP )
		force = </font><font color="#00bb00">"no"</font><font color=black>;			</font><font color="#ff0000"><i># "Force login?" not defined, assume "no"</font></i><font color=black>
	<b>else</b> <b>if</b> ( rc != E_OK )
		<b>return</b> rc;
	<b>if</b> ( yes( force ) )
	{
		AUT_close();
	}
	EMOS_win_close_all( wins );
	<b>if</b> ( win_exists (</font><font color="#00bb00">"Home"</font><font color=black>) != E_OK )
	{
		AUT_invoke();
		rc+=set_window( </font><font color="#00bb00">"Login"</font><font color=black>, 10 );
		rc+=FRM_edit_set( table, test, </font><font color="#00bb00">"username"</font><font color=black> );
		rc+=FRM_edit_set( table, test, </font><font color="#00bb00">"password"</font><font color=black> );
		rc+=web_image_click( </font><font color="#00bb00">"login"</font><font color=black>, 3, 3 );
		rc+=web_sync( 5 );
	}
	rc+=set_window( </font><font color="#00bb00">"Home"</font><font color=black>, 10 );
	<b>return</b> rc;
}

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* @see &lt;a href="../../images/Login.jpg"&gt;GUI&lt;/a&gt;
#* @see &lt;a href="../../images/Login_block.jpg"&gt;Excel&lt;/a&gt;
#*/</font></i><font color=black>

<b>public</b> <b>function</b> FRM_Login ( <b>in</b> table, <b>in</b> test, <b>in</b> idx, <b>inout</b> mode )
{
	<b>auto</b> rc;
	rc = FRM_init_block( table, test, idx, mode );
	<b>if</b> ( rc != E_OK )
		<b>return</b> rc;
	rc+=set_window( </font><font color="#00bb00">"Login"</font><font color=black>, 5 );
	rc+=FRM_edit_set( table, test, </font><font color="#00bb00">"username"</font><font color=black> );
	rc+=FRM_edit_set( table, test, </font><font color="#00bb00">"password"</font><font color=black> );
	rc+=FRM_web_image_click( table, test, </font><font color="#00bb00">"login"</font><font color=black> );
	<b>return</b> rc;
}

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* Provides the possibility to click on up to two images.
#* You may want to add clicks to links as well (makes sense for many AUTs).
#*
#* @see &lt;a href="../../images/Main.jpg"&gt;GUI&lt;/a&gt;
#* @see &lt;a href="../../images/Main_block.jpg"&gt;Excel&lt;/a&gt;
#*/</font></i><font color=black>

<b>public</b> <b>function</b> FRM_Main ( <b>in</b> table, <b>in</b> test, <b>in</b> idx, <b>in</b> mode )
{
	<b>auto</b> rc;
	rc = FRM_init_block( table, test, idx, mode );
	<b>if</b> ( rc != E_OK ) 
		<b>return</b> rc;
</font><font color="#ff0000"><i>#	rc+=set_window ("Home", 60);</font></i><font color=black>
	rc+=web_sync(5);
	rc+=FRM_web_image_click( table, test );
	rc+=web_sync(5);
	rc+=close_security_alerts();
	rc+=FRM_web_image_click( table, test );
	rc+=web_sync(5);
	rc+=close_security_alerts();
	<b>return</b> rc;
}

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* Provides the possibility to click on three images/buttons on left-side
#* navigation bar.
#* Note how we have solved the problem of having to click on same images
#* within different frames. We have replaced the inital set_window()
#* with web_sync() and included phisical properties instead of the logical names.
#*
#* @see &lt;a href="../../images/Navbar.jpg"&gt;GUI&lt;/a&gt;
#* @see &lt;a href="../../images/Navbar_block.jpg"&gt;Excel&lt;/a&gt;
#*/</font></i><font color=black>

<b>public</b> <b>function</b> FRM_Navbar ( <b>in</b> table, <b>in</b> test, <b>in</b> idx, <b>inout</b> mode )
{
	<b>auto</b> rc;
	rc = FRM_init_block( table, test, idx, mode );
	<b>if</b> ( rc != E_OK )
		<b>return</b> rc;
	rc+=web_sync( 5 );
	rc+=FRM_web_image_click( table, test, </font><font color="#00bb00">"{class:object, MSW_class: html_rect,html_name:&#92;&#34;Search Flights Button&#92;&#34;}"</font><font color=black> );
	rc+=FRM_web_image_click( table, test, </font><font color="#00bb00">"{class:object, MSW_class: html_rect,html_name:&#92;&#34;Home Button&#92;&#34;}"</font><font color=black> );
	rc+=FRM_web_image_click( table, test, </font><font color="#00bb00">"{class:object, MSW_class: html_rect,html_name:&#92;&#34;SignOff Button&#92;&#34;}"</font><font color=black> );
	rc+=web_sync( 5 );
	rc+=close_security_alerts();
	<b>return</b> rc;
}

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* Handles the dynamic popup message dialog. The tester can define three deisions: whether
#* the dialog was expected or not, what message should be desplayed and what button to
#* use to close the dialog. Different types of message dialogs are handled with the same
#* function, e.g. OK, Yes/No, OK/Cancel. You have to make sure that the GUI-map is 
#* propeprly configured (not a trivial task).
#*/</font></i><font color=black>

<b>public</b> <b>function</b> FRM_PopUp_Message ( <b>in</b> table, <b>in</b> test, <b>in</b> idx, <b>in</b> mode )
{
	<b>auto</b> rc, usr, pwd, force;
	rc = FRM_init_block( table, test, idx, mode );
	<b>if</b> ( rc != E_OK ) 
		<b>return</b> rc;
	rc = FRM_CheckPopUpMessage( table, test, </font><font color="#00bb00">"MessageBox"</font><font color=black>, 1 );
	<b>return</b> rc;
}

</font><font color="#ff0000"><i>###################</font></i><font color=black>
</font><font color="#ff0000"><i># Private Functions</font></i><font color=black>
</font><font color="#ff0000"><i>###################</font></i><font color=black>

</font><font color="#ff0000"><i>#</font></i><font color=black></font><font color="#ff0000"><i>/**
#* Handles the pop-up message dialog. It reads up to three lines fom the data
#* table and checks whether the dialog popped up and whether the expected
#* message matches (i.e. regular expresion) the given string. It also handles
#* situations when message window is not expected.
#* @param table (in)	index of the data table
#* @param test (in)		test
#* @param window (in)	logical name of the popup window
#* @param timeout (in)	timeout in seconds to wait for popup window
#*/</font></i><font color=black>

<b>static</b> <b>function</b> FRM_CheckPopUpMessage ( <b>in</b> table, <b>in</b> test, <b>in</b> window, <b>in</b> timeout )
{
	<b>auto</b> rc;
	<b>auto</b> is_win_expected;
	
	</font><font color="#ff0000"><i># do nothing in CHK/GEN/ATR mode</font></i><font color=black>
	</font><font color="#ff0000"><i>#if ( FRM_get_mode( table ) != FRM_SET_MODE )</font></i><font color=black>
	</font><font color="#ff0000"><i>#	return E_OK;</font></i><font color=black>

	rc=FRM_get_next( table, test, is_win_expected );	

	<b>switch</b> ( rc )
	{
	<b>case</b> E_OK:			</font><font color="#ff0000"><i># first value provided</font></i><font color=black>
	
		<b>if</b>( yes( is_win_expected ) )	</font><font color="#ff0000"><i># we expect message window to show up</font></i><font color=black>
			rc = process_expected_popup_win( table, test, window, timeout );
		<b>else</b>
			rc = process_unexpected_popup_win( table, test, window, timeout );
		<b>return</b> rc;
		
	<b>case</b> E_FRM_SKIP:	</font><font color="#ff0000"><i># first value not provided</font></i><font color=black>

		rc = ignore_popup_win( table, test, window, timeout );
		<b>return</b> rc;

	<b>default</b>:			</font><font color="#ff0000"><i># error retrieving first value</font></i><font color=black>
	
		<b>return</b> rc;
	}
}

<b>static</b> <b>function</b> process_expected_popup_win( <b>in</b> table, <b>in</b> test, <b>in</b> window, <b>in</b> timeout )
{
	<b>auto</b> rc;
	<b>auto</b> txt_expected;
	<b>auto</b> txt_actual;
	
	set_timeout( timeout );
	rc = win_exists( window, 1 );
	restore_timeout();
	<b>if</b>( rc != E_OK )
	{
		<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, FAIL, </font><font color="#00bb00">"No message window shown"</font><font color=black> );
		<b>return</b> E_NOT_FOUND;
	}
	<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, PASS, </font><font color="#00bb00">"Expected message window shown"</font><font color=black> );
	set_window( window );
	rc = FRM_get_next( table, test, txt_expected );	
	<b>if</b> ( rc == E_OK )		</font><font color="#ff0000"><i># check message if text provided</font></i><font color=black>
	{
		rc = static_get_text( </font><font color="#00bb00">"message"</font><font color=black>, txt_actual );
		<b>if</b> ( rc == E_OK )
		{
			<b>report_msg</b>( </font><font color="#00bb00">"Message: '"</font><font color=black> &amp; txt_actual &amp; </font><font color="#00bb00">"'"</font><font color=black> );
			<b>if</b> ( match( txt_actual, txt_expected ) &gt; 0 )
			{
				<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, PASS, </font><font color="#00bb00">"matches '"</font><font color=black> &amp; txt_expected &amp; </font><font color="#00bb00">"'"</font><font color=black> );
				rc = E_OK;
			}
			<b>else</b> 
			{
				<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, FAIL, </font><font color="#00bb00">"does not match '"</font><font color=black> &amp; txt_expected &amp; </font><font color="#00bb00">"'"</font><font color=black> );
				rc = E_MISMATCH;
			}
		}
		<b>else</b>
		{
			<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, FAIL, </font><font color="#00bb00">"error retrieving message text [rc="</font><font color=black> &amp; rc &amp; </font><font color="#00bb00">"]"</font><font color=black> );
		}
	}
	rc += FRM_button_press( table, test );
	<b>return</b> rc;
}

<b>static</b> <b>function</b> process_unexpected_popup_win( <b>in</b> table, <b>in</b> test, <b>in</b> window, <b>in</b> timeout )
{
	<b>auto</b> rc;
	<b>auto</b> txt_actual;

	set_timeout( timeout );
	rc = win_exists( window, 1 );
	restore_timeout();
	<b>if</b>( rc != E_OK )
	{
		<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, PASS, </font><font color="#00bb00">"Message window not shown"</font><font color=black> );
		<b>return</b> E_OK;
	}
	rc = E_UNEXP_WIN;
	<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, FAIL, </font><font color="#00bb00">"Unexpected message window shown"</font><font color=black> );
	set_window( window );
	static_get_text( </font><font color="#00bb00">"message"</font><font color=black>, txt_actual );
	<b>tl_step</b>( </font><font color="#00bb00">"Message"</font><font color=black>, FAIL, </font><font color="#00bb00">"displayed '"</font><font color=black> &amp; txt_actual &amp; </font><font color="#00bb00">"'"</font><font color=black> );
	FRM_skip( table, test );  </font><font color="#ff0000"><i># skip the cell with expected text (irelevant in this case)</font></i><font color=black>
	rc += FRM_button_press( table, test );	</font><font color="#ff0000"><i># then press the button to close the window</font></i><font color=black>
	<b>return</b> rc;
}

<b>static</b> <b>function</b> ignore_popup_win( <b>in</b> table, <b>in</b> test, <b>in</b> window, <b>in</b> timeout )
{
	<b>auto</b> rc;
	<b>auto</b> txt_actual;

	set_timeout( timeout );
	rc = win_exists( window, 1 );
	restore_timeout();
	<b>if</b>( rc != E_OK )
	{
		<b>return</b> E_OK;
	}
	<b>report_msg</b>( </font><font color="#00bb00">"Popup window ignored"</font><font color=black> );
	set_window( window );
	static_get_text( </font><font color="#00bb00">"message"</font><font color=black>, txt_actual );
	<b>report_msg</b>( </font><font color="#00bb00">"Message displayed '"</font><font color=black> &amp; txt_actual &amp; </font><font color="#00bb00">"'"</font><font color=black> );
	FRM_skip( table, test );  </font><font color="#ff0000"><i># skip the cell with expected text (irelevant in this case)</font></i><font color=black>
	rc += FRM_button_press( table, test );	</font><font color="#ff0000"><i># then press the button to close the window</font></i><font color=black>
	<b>return</b> rc;
}

</pre></body>