getting Count from combo

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

getting Count from combo

Postby karthik.intels12 » Wed Mar 31, 2010 4:57 am

Hello,

I want to count the number of items present in combo viewer. How can i get that value in SWT Windows tester

Snippets:
******************
IWidgetLocator widgetCombo = ui.find(new NamedWidgetLocator("datatypecombo.widget"));
CComboItemLocator comboItemLocator = new CComboItemLocator("Integer", widgetCombo);
int itemCount = comboItemLocator.getIndex();
assertEquals(2, itemCount);

*****************
here if i use this code it is returning the index value of the combo's particulr selection. But there i couldn find any API to get count. pls help me out !!!
Thanks and Regards,
Karthik.M.S
karthik.intels12
 
Posts: 35
Joined: Wed Mar 31, 2010 4:37 am

Re: getting Count from combo

Postby keertip » Wed Mar 31, 2010 8:48 am

The CComboItemLocator currently does not implement any methods to find the item count for the ccombo. What you can do is this

Code: Select all

IWidgetLocator widgetCombo = ui.find(new NamedWidgetLocator("datatypecombo.widget"));
final CCombo combo = (CCombo) ((IWidgetReference)widgetCombo).getWidget();
int count = getItemCount(combo);
      


method getItemCount

Code: Select all
private int getItemCount(final CCombo combo){
   final Integer[] count = new Integer[1];
   Display.getDefault().syncExec(new Runnable() {
      public void run() {
         count[0] = combo.getItemCount();
      }
   });
   return count[0];
}
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: getting Count from combo

Postby karthik.intels12 » Wed Mar 31, 2010 8:53 pm

Hello,

Thanks boss. its working:-) :) :) :)
Thanks and Regards,
Karthik.M.S
karthik.intels12
 
Posts: 35
Joined: Wed Mar 31, 2010 4:37 am

Re: getting Count from combo

Postby Phil Quitslund » Thu Apr 01, 2010 9:12 am

Good deal.

Thanks for following up!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
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