Testing Text style [message #580924] |
Tue, 17 August 2010 21:24 |
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;
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
|
|
|
Re: Testing Text style [message #580976 is a reply to message #580924] |
Wed, 18 August 2010 21:41 |
Yves YANG Messages: 688 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
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03809 seconds