Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » e4 Testing with XWTTestCase
e4 Testing with XWTTestCase [message #552870] Fri, 13 August 2010 22:45 Go to next message
St Clair Clarke is currently offline St Clair ClarkeFriend
Messages: 118
Registered: March 2010
Senior Member
Hello,

I am attempting to test the following XWT UI:

<Composite 
    xmlns="http://www.eclipse.org/xwt/presentation" 
    xmlns:x="http://www.eclipse.org/xwt"
    x:Name="root" 
    xmlns:lang="clr-namespace:java.lang"
    xmlns:demography="clr-namespace:biz.epims.reg.data.demography" 
    DataContext="{StaticResource religions}">
    <Composite.Resources>
        <demography:Religion x:Key="religions" />
    </Composite.Resources>
    <Composite.layout>
        <GridLayout numColumns="2"/>
    </Composite.layout>
    <Label text="Religion" x:Name="religionsLbl">
        <Label.layoutData>
            <GridData horizontalAlignment="CENTER"/>
        </Label.layoutData>
    </Label>
    <Label text="Christian Denomination" enabled="false" x:Name="christianDenomLbl">
        <Label.layoutData>
            <GridData horizontalAlignment="CENTER"/>
        </Label.layoutData>
    </Label>
    <Combo x:Name="religionCmbo" text="{Binding path=religion, BindingMode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
        <Combo.layoutData>
            <GridData grabExcessHorizontalSpace="true" horizontalAlignment="FILL"/>
        </Combo.layoutData>
        <Combo.items>
            <lang:String>African Traditional</lang:String>
            <lang:String>Aetheist</lang:String>
            <lang:String>Bahai</lang:String>
            <lang:String>Buddhism</lang:String>
            <lang:String>Cao Dai</lang:String>
            <lang:String>Chinese Traditional</lang:String>
            <lang:String>Christianity</lang:String>
            <lang:String>Hinduism</lang:String>
            <lang:String>Islam</lang:String>
            <lang:String>Jainism</lang:String>
            <lang:String>Juche</lang:String>
            <lang:String>Judaism</lang:String>
            <lang:String>Neo-Paganism</lang:String>
            <lang:String>Primal-Indiginous</lang:String>
            <lang:String>Rastafarianism</lang:String>
            <lang:String>Scientology</lang:String>
            <lang:String>Shinto</lang:String>
            <lang:String>Sikhism</lang:String>
            <lang:String>Spiritism</lang:String>
            <lang:String>Tenrikyo</lang:String>
            <lang:String>Unitarian-Universalism</lang:String>
            <lang:String>Zoroastrianism</lang:String>
        </Combo.items>
        <Combo.Triggers>
            <Trigger property="text" value="Christianity">
                <Setter property="enabled" targetName="christianDenomLbl"/>
                <Setter property="enabled" targetName="christianDenomCmbo"/>
            </Trigger>
        </Combo.Triggers>
    </Combo>
    <Combo x:Name="christianDenomCmbo" enabled="false" text="{Binding path=christianDenomination, BindingMode=TwoWay, UpdateSourceTrigger=PropertyChanged}" visible="true">
        <Combo.layoutData>
            <GridData horizontalAlignment="FILL" grabExcessHorizontalSpace="true"/>
        </Combo.layoutData>
        <Combo.items>
            <lang:String>Christian  denominations</lang:String>
            <lang:String>-----------------------------</lang:String>
            <lang:String>Anglican</lang:String>
            <lang:String>Catholic</lang:String>
            <lang:String>Evangelical</lang:String>
            <lang:String>Jehovah Witnesses</lang:String>
            <lang:String>Latter-day Saints</lang:String>
            <lang:String>Orthodox</lang:String>
            <lang:String>Pentecostal</lang:String>
            <lang:String>-----------------------------</lang:String>
            <lang:String>Non-denominational</lang:String>
        </Combo.items>
    </Combo>
</Composite>


Here is my attempt at testing the religionCmbo:

import biz.epims.reg.ui.demography.ReligionForm;

import biz.epims.shared.test.XWTTestCase;

import java.net.URL;

import static org.eclipse.e4.xwt.IConstants.XWT_EXTENSION_SUFFIX;

import static org.eclipse.e4.xwt.XWT.findElementByName;

import org.eclipse.swt.widgets.Text;


class ReligionFormTest extends XWTTestCase
{
    public void testReligionCmbo()
    {
        URL url = ReligionForm.class.getResource( ReligionForm.class.getSimpleName() + XWT_EXTENSION_SUFFIX );

        runTest( url, new Runnable()
            {
                void checkTrigger()
                {
                    Object religionCmbo = findElementByName( root, "religionCmbo" );

                    // assert religionCmbo instanceof Text
                    assertTrue( religionCmbo instanceof Text );
                } // end method checkTrigger


                public void run()
                {
                    checkTrigger();
                } // end method run
            } );
    } // end method testReligionCmbo
} // end class ReligionFormTest


The url is correct.

However, it does not seem that the code in runTest ever gets executed and the test always runs without errors Embarrassed , something I fail to understand.

Please take a look at the code and let me know where I am going wrong.

Thanks

St Clair
Re: e4 Testing with XWTTestCase [message #553797 is a reply to message #552870] Wed, 18 August 2010 21:39 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
If you can debug it, you can find the error in the line:
assertTrue( religionCmbo instanceof Text );

It should be a Combo

Best regards
Yves YANG
"St Clair Clarke" <st_clair@flowja.com> wrote in message
news:i44hua$9ok$1@build.eclipse.org...
> Hello,
>
> I am attempting to test the following XWT UI:
>
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> x:Name="root" xmlns:lang="clr-namespace:java.lang"
> xmlns:demography="clr-namespace:biz.epims.reg.data.demography "
> DataContext="{StaticResource religions}">
> <Composite.Resources>
> <demography:Religion x:Key="religions" />
> </Composite.Resources>
> <Composite.layout>
> <GridLayout numColumns="2"/>
> </Composite.layout>
> <Label text="Religion" x:Name="religionsLbl">
> <Label.layoutData>
> <GridData horizontalAlignment="CENTER"/>
> </Label.layoutData>
> </Label>
> <Label text="Christian Denomination" enabled="false"
> x:Name="christianDenomLbl">
> <Label.layoutData>
> <GridData horizontalAlignment="CENTER"/>
> </Label.layoutData>
> </Label>
> <Combo x:Name="religionCmbo" text="{Binding path=religion,
> BindingMode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
> <Combo.layoutData>
> <GridData grabExcessHorizontalSpace="true"
> horizontalAlignment="FILL"/>
> </Combo.layoutData>
> <Combo.items>
> <lang:String>African Traditional</lang:String>
> <lang:String>Aetheist</lang:String>
> <lang:String>Bahai</lang:String>
> <lang:String>Buddhism</lang:String>
> <lang:String>Cao Dai</lang:String>
> <lang:String>Chinese Traditional</lang:String>
> <lang:String>Christianity</lang:String>
> <lang:String>Hinduism</lang:String>
> <lang:String>Islam</lang:String>
> <lang:String>Jainism</lang:String>
> <lang:String>Juche</lang:String>
> <lang:String>Judaism</lang:String>
> <lang:String>Neo-Paganism</lang:String>
> <lang:String>Primal-Indiginous</lang:String>
> <lang:String>Rastafarianism</lang:String>
> <lang:String>Scientology</lang:String>
> <lang:String>Shinto</lang:String>
> <lang:String>Sikhism</lang:String>
> <lang:String>Spiritism</lang:String>
> <lang:String>Tenrikyo</lang:String>
> <lang:String>Unitarian-Universalism</lang:String>
> <lang:String>Zoroastrianism</lang:String>
> </Combo.items>
> <Combo.Triggers>
> <Trigger property="text" value="Christianity">
> <Setter property="enabled" targetName="christianDenomLbl"/>
> <Setter property="enabled"
> targetName="christianDenomCmbo"/>
> </Trigger>
> </Combo.Triggers>
> </Combo>
> <Combo x:Name="christianDenomCmbo" enabled="false" text="{Binding
> path=christianDenomination, BindingMode=TwoWay,
> UpdateSourceTrigger=PropertyChanged}" visible="true">
> <Combo.layoutData>
> <GridData horizontalAlignment="FILL"
> grabExcessHorizontalSpace="true"/>
> </Combo.layoutData>
> <Combo.items>
> <lang:String>Christian denominations</lang:String>
> <lang:String>-----------------------------</lang:String>
> <lang:String>Anglican</lang:String>
> <lang:String>Catholic</lang:String>
> <lang:String>Evangelical</lang:String>
> <lang:String>Jehovah Witnesses</lang:String>
> <lang:String>Latter-day Saints</lang:String>
> <lang:String>Orthodox</lang:String>
> <lang:String>Pentecostal</lang:String>
> <lang:String>-----------------------------</lang:String>
> <lang:String>Non-denominational</lang:String>
> </Combo.items>
> </Combo>
> </Composite>
>
> Here is my attempt at testing the religionCmbo:
>
> import biz.epims.reg.ui.demography.ReligionForm;
>
> import biz.epims.shared.test.XWTTestCase;
>
> import java.net.URL;
>
> import static org.eclipse.e4.xwt.IConstants.XWT_EXTENSION_SUFFIX;
>
> import static org.eclipse.e4.xwt.XWT.findElementByName;
>
> import org.eclipse.swt.widgets.Text;
>
>
> class ReligionFormTest extends XWTTestCase
> {
> public void testReligionCmbo()
> {
> URL url = ReligionForm.class.getResource(
> ReligionForm.class.getSimpleName() + XWT_EXTENSION_SUFFIX );
>
> runTest( url, new Runnable()
> {
> void checkTrigger()
> {
> Object religionCmbo = findElementByName( root,
> "religionCmbo" );
>
> // assert religionCmbo instanceof Text
> assertTrue( religionCmbo instanceof Text );
> } // end method checkTrigger
>
>
> public void run()
> {
> checkTrigger();
> } // end method run
> } );
> } // end method testReligionCmbo
> } // end class ReligionFormTest
>
> The url is correct.
>
> However, it does not seem that the code in runTest ever gets executed and
> the test always runs without errors :blush: , something I fail to
> understand.
>
> Please take a look at the code and let me know where I am going wrong.
>
> Thanks
>
> St Clair
Previous Topic:Using XWT Views with Riena
Next Topic:e4 Testing with XWTTestCase
Goto Forum:
  


Current Time: Thu Dec 18 13:37:48 GMT 2014

Powered by FUDForum. Page generated in 0.02131 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software