Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Testing Text style(XWT JUnit testing using XWTTestCase)
Testing Text style [message #553542] Tue, 17 August 2010 17:24 Go to next message
St Clair Clarke is currently offline St Clair Clarke
Messages: 118
Registered: March 2010
Senior Member
Hello,
I have successfully tested the style of a Combo by following the ComboTest in the XWT test examples.

However when I apply a similar style test for a Text widget, no error is picked up by JUNIT.

To check the style with a Combo the following statement is use:

public void checkComboStyle( String name, int style )
	{
		Object element = findElementByName( root, name );

		assertTrue( element instanceof Combo );

		Combo combo = ( Combo ) element;

		[B]assertTrue( ( combo.getStyle() & style ) == style );[/B]

	}   // end method checkComboStyle


The above works for different styles.

For text, I use the following below:

public void checkTextStyle( String name, int style )
	{
		Object element = findElementByName( root, name );

		assertTrue( element instanceof Text );

		Text text = ( Text ) element;

		[B]assertTrue( ( text.getStyle() & style ) == style );[/B]

	}   // end method checkTextStyle


	public void run()
	{
		checkTextStyle( "firstNameText", BORDER );
		checkTextStyle( "middleNameText", BORDER );

		// the style is actually BORDER, but the test runs with an
		// error!
		[B]checkTextStyle( "lastNameText", DROP_DOWN );[/B]

	}   // end method run


Note that

checkTextStyle( "lastNameText", DROP_DOWN )


still pases the test for a Text although it cannot have a dropdown style.

What am I doing wrong please.

Thanks

St Clair




Re: Testing Text style [message #553798 is a reply to message #553542] Wed, 18 August 2010 17:41 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Please debug your code to see what is wrong. Just for your information, some
style bits are ignored by SWT.

Best regards
Yves YANG
"St Clair Clarke" <st_clair@flowja.com> wrote in message
news:i4eum3$4sb$1@build.eclipse.org...
> Hello,
> I have successfully tested the style of a Combo by following the ComboTest
> in the XWT test examples.
>
> However when I apply a similar style test for a Text widget, no error is
> picked up by JUNIT.
>
> To check the style with a Combo the following statement is use:
>
> public void checkComboStyle( String name, int style )
> {
> Object element = findElementByName( root, name );
>
> assertTrue( element instanceof Combo );
>
> Combo combo = ( Combo ) element;
>
> assertTrue( ( combo.getStyle() & style ) == style );
>
> } // end method checkComboStyle
>
> The above works for different styles.
>
> For text, I use the following below:
>
> public void checkTextStyle( String name, int style )
> {
> Object element = findElementByName( root, name );
>
> assertTrue( element instanceof Text );
>
> Text text = ( Text ) element;
>
> assertTrue( ( text.getStyle() & style ) == style );
>
> } // end method checkTextStyle
>
>
> public void run()
> {
> checkTextStyle( "firstNameText", BORDER );
> checkTextStyle( "middleNameText", BORDER );
>
> // the style is actually BORDER, but the test runs with an
> // error!
> checkTextStyle( "lastNameText", DROP_DOWN );
>
> } // end method run
>
> Note that
> checkTextStyle( "lastNameText", DROP_DOWN )
>
> still pases the test for a Text although it cannot have a dropdown style.
>
> What am I doing wrong please.
>
> Thanks
>
> St Clair
>
>
>
>
>
Previous Topic:e4 Testing with XWTTestCase
Next Topic:Testing Text style
Goto Forum:
  


Current Time: Wed Aug 20 16:46:13 EDT 2014

Powered by FUDForum. Page generated in 0.02148 seconds