~ubuntu-branches/ubuntu/karmic/ldtp/karmic

« back to all changes in this revision

Viewing changes to python/ldtplib/pushbutton.py

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2008-12-04 16:44:34 UTC
  • mfrom: (1.1.5 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20081204164434-6ez1x999y5bw0btb
Tags: 1.4.0-1
* New upstream release
* debian/rules:
  + Some scripts are no longer needed to make executable
* debian/watch:
  + Fixed for upstream location change, notified to upstream
* debian/*.1:
  + Fixed typo in my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from ldtplibutils import *
 
2
 
 
3
global _ldtpDebug
 
4
 
 
5
class PushButton:
 
6
    def isPushButtonEnabled (self, accessible):
 
7
        # FIXME: Implement wait_till_object_state_contains
 
8
        return True
 
9
 
 
10
    def click (self, accessible):
 
11
        if self.isPushButtonEnabled (accessible) == False:
 
12
            return LdtpErrorCode.INVALID_OBJECT_STATE
 
13
        _component = accessible.queryComponent ()
 
14
        _flag = False
 
15
        if _component:
 
16
            _flag = _component.grabFocus ()
 
17
            if _ldtpDebug:
 
18
                print 'Grab focus %s' % _flag
 
19
            _component.unref ()
 
20
        _action = accessible.queryAction ()
 
21
        _flag = False
 
22
        if _action:
 
23
            _flag = _action.doAction (0) # FIXME: Do action based on event, instead of 0
 
24
            _action.unref ()
 
25
        if _flag:
 
26
            return LdtpErrorCode.SUCCESS
 
27
        else:
 
28
            return LdtpErrorCode.CLICK_FAILED
 
29
 
 
30
def pushButtonMain (cctxt, cmd):
 
31
    pushButtonInst = PushButton ()
 
32
    if cmd == command.CLICK:
 
33
        status = pushButtonInst.click (cctxt.guiHandle.handle)
 
34
        pushButtonInst = None
 
35
        return status
 
36
    elif cmd == command.GRABFOCUS:
 
37
        status = grabFocus (cctxt.guiHandle.handle)
 
38
        pushButtonInst = None
 
39
        return status
 
40
    else:
 
41
        pushButtonInst = None
 
42
        return LdtpErrorCode.COMMAND_NOT_IMPLEMENTED