[LDTP-Dev] How to use the array returned by getallstates()

Wang Qi, Scott wangqi.s at gmail.com
Fri Oct 16 17:54:49 PDT 2009


Hi, Nagappan,

I found a not-so-perfect work-around for this issue.

I can use ldtp.generatekeyevent ('<alt>F') (i.e. Ctrl-F) to request the
root-menu 'File' to display all the sub-menus. Then, do a
ldtp.generatekeyevent ('esc').

One issue with this solution is that AUT must get the focus (not like other
LDTP API).

Another even-worse solution is to update the application code to add a
trigger for EVT_UPDATE_UI for all menu's event handler function. But this
seems a big change and no-optimized update.

Or does anyone have better solutions?

Thanks
Scott




On Wed, Oct 14, 2009 at 9:57 PM, Wang Qi, Scott <wangqi.s at gmail.com> wrote:

> Hi, Nagappan,
>
> I tried your method. Both work great.
>
> But I found another interesting issue. For the APP I am testing, the state
> of the menu item such as SENSITIVE is updated in a wx.EVT_UPDATE_UI event.
> I think different UI framework get different name. But the basic mechanism
> should work the same. The state of menu item only changes when user click on
> the root menu. For example, I must try to manually click on 'mnuFile' to
> show the menu list to make the state of 'mnuFile;mnuClose' get change
> (updated in the wx.EVT_UPDATE_UI event handler).
>
> So my question is how to trigger this wx.EVT_UPDATE_UI event in the test
> script? I tried ldtp.selectmenuitem(win_name, 'mnuFile'). This call does not
> do the same thing as what a manual click on 'mnuFile' item does, which
> trigger the EVT_UPATE_UI event.
>
> Thanks
> Scott
>
> P.S: I tried gedit and find the state of menu item is updated instantly.
> For example, the SENSITIVE state of 'mnuFile;mnuClose' will change to off as
> soon as the last edit tab is closed in gedit.
>
>
> On Fri, Sep 25, 2009 at 10:28 AM, Nagappan A <nalagappan at vmware.com>wrote:
>
>> Hi Scott,
>>
>> You can check with:
>>
>> 1. hasstate('window', 'object', state.ENABLED)
>> 2. getallstates, from return value of it you can check:
>>    enabled = False
>>    for currentState in states:
>>       if state.ENABLED == currentState:
>>          print 'Enabled'
>>          enabled = True
>>          break
>>
>> In case of menu state.SENSITIVE will be checked.
>>
>> Thanks
>> Nagappan
>>
>>
>> Wang Qi, Scott wrote:
>>
>>> Hi, Nagappan,
>>>
>>> It seems ldtp.getallstates() return an array of integer. I look in the
>>> online doc about how to use the index. Seems there is no information on it.
>>>
>>> Also, how to tell if a mnu is enabled or not? Seems button' state can be
>>> get by calling stateenabled (). But stateenabled() will always return 0 for
>>> mnu?
>>>
>>> Thanks
>>> Scott Wang
>>>
>>>
>>>
>> --
>> Linux Desktop Testing Project - http://ldtp.freedesktop.org
>> http://nagappanal.blogspot.com
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/ldtp-dev/attachments/20091017/67cc2799/attachment.html 


More information about the LDTP-dev mailing list