Check for disablement of whole composite

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Check for disablement of whole composite

Postby karthik.intels12 » Tue Apr 20, 2010 10:20 pm

i'm facing one problem in indentifing the enablement of composite.

I'm having one page which is created using SWT. There i'm disabling whole composite under some validations. Here In windows tester how can i check the enablement of that composite. If i check for the buttons and combos present in that composite, it is enable only. But actually we cannot access that in UI, Since we have disabled that parent composite.

So jus help me out from this issue.

Thanks and regards,
Thanks and Regards,
Posts: 35
Joined: Wed Mar 31, 2010 4:37 am

Re: Check for disablement of whole composite

Postby Phil Quitslund » Wed Apr 21, 2010 9:34 am

We don't have enablement testing supported on the generic Composite locator. That said, this limitation is easily worked around by querying the Composite reference directly. Here's a snippet that should get you going.

Code: Select all
public void testSomething() throws Exception {
      //Your locator will need more details; this one assumes there is only one composite visible (unlikely!)
      IWidgetReference compRef = (IWidgetReference) ui.find(new SWTWidgetLocator(Composite.class));
      Composite comp = (Composite) compRef.getWidget();
      boolean enabled = getEnablement(comp);
      assertEquals(/*expected*/, enabled);

   private int getEnablement(final Composite comp) {
      final boolean enabled[] = new boolean[1];
      Display.getDefault().syncExec(new Runnable() {
         public void run() {
            enabled[0] = comp.getEnabled();
      return enabled[0];
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest