1010import socket
1111import os
1212
13- DEBUG = True
13+ DEBUG = False
1414
1515ANDROID_HOME = os .environ ['ANDROID_HOME' ] if os .environ .has_key ('ANDROID_HOME' ) else '/opt/android-sdk'
1616VIEW_SERVER_HOST = 'localhost'
@@ -26,6 +26,10 @@ class View:
2626 '''
2727
2828 def __init__ (self , map , device ):
29+ '''
30+ Constructor
31+ '''
32+
2933 self .map = map
3034 self .device = device
3135
@@ -34,7 +38,7 @@ def __getitem__(self, key):
3438
3539 def __getattr__ (self , name ):
3640 if DEBUG :
37- print "__getattr__(%s)" % (name )
41+ print >> sys . stderr , "__getattr__(%s)" % (name )
3842
3943 # I should try to see if 'name' is a defined method
4044 # but it seems that if I call locals() here an infinite loop is entered
@@ -80,16 +84,24 @@ def __call__(self, *args, **kwargs):
8084 print "__call__(%s)" % (args if args else None )
8185
8286 def getXY (self ):
87+ '''
88+ Returns the coordinates of this View
89+ '''
90+
8391 # FIXME: it's not always a CheckBox
84- x = int (map ['layout:mLeft' ]) + int (map ['layout:layout_leftMargin' ]) + CHECK_BOX / 2
85- y = int (map ['layout:mTop' ]) + int (map ['layout:layout_topMargin' ]) + STATUS_BAR + TITLE + CHECK_BOX / 2
92+ x = int (self . map ['layout:mLeft' ]) + int (self . map ['layout:layout_leftMargin' ]) + CHECK_BOX / 2
93+ y = int (self . map ['layout:mTop' ]) + int (self . map ['layout:layout_topMargin' ]) + STATUS_BAR + TITLE + CHECK_BOX / 2
8694 return (x , y )
8795
8896 # FIXME: should be MonkeyDevice.DOWN_AND_UP
89- def touch (self , type = "DOWN_AND_UP" ):
97+ def touch (self , type = "DOWN_AND_UP" ):
98+ '''
99+ Touches this View
100+ '''
101+
90102 (x , y ) = self .getXY ()
91103 if DEBUG :
92- print "should click @ (%d, %d)" % (x , y )
104+ print >> sys . stderr , "should click @ (%d, %d)" % (x , y )
93105 self .device .touch (x , y , type )
94106
95107 def allPossibleNamesWithColon (self , name ):
0 commit comments