1 from __future__ import print_function
8 def sendKey(stub, key):
9 rsp_key = stub.sendKey(aurum_pb2.ReqKey(
16 def launchApp(stub, pkgname):
17 rsp_launch = stub.launchApp(aurum_pb2.ReqLaunchApp(
21 def closeApp(stub, pkgname):
22 rsp_launch = stub.closeApp(aurum_pb2.ReqCloseApp(
26 def getAppInfo(stub, pkgname):
27 rsp_info = stub.getAppInfo(aurum_pb2.ReqGetAppInfo(packageName=pkgname))
30 def touchdown(stub, xx, yy):
31 rsp = stub.touchDown(aurum_pb2.ReqTouchDown(coordination=aurum_pb2.Point(x=xx,y=yy)))
34 def touchmove(stub, xx, yy):
35 rsp = stub.touchMove(aurum_pb2.ReqTouchMove(coordination=aurum_pb2.Point(x=xx,y=yy)))
38 def touchup(stub, xx, yy):
39 rsp = stub.touchUp(aurum_pb2.ReqTouchUp(coordination=aurum_pb2.Point(x=xx,y=yy)))
43 touchdown(stub, 630,1140)
45 touchup(stub, 630,1140)
48 def findElementByText(stub, text):
49 rsp_find = stub.findElement(aurum_pb2.ReqFindElement(
54 for item in rsp_find.elements:
58 def findElementsByText(stub, text):
59 rsp_find = stub.findElement(aurum_pb2.ReqFindElement(
64 return rsp_find.elements
66 def clickById(stub, id):
67 stub.click(aurum_pb2.ReqClick(
74 foundId = findElementByText(stub, 'All apps')
77 clickById(stub, foundId)
80 foundId = findElementByText(stub, 'Memo')
83 clickById(stub, foundId)
86 def set_text(stub, text):
87 foundId = findElementByText(stub, 'Title')
89 clickById(stub, foundId)
91 stub.setValue(aurum_pb2.ReqSetValue(
94 foundIds = findElementsByText(stub, "Memo")
95 if len(foundIds) >= 2:
96 stub.setValue(aurum_pb2.ReqSetValue(
97 elementId=foundIds[1].elementId,
100 foundId = findElementByText(stub, 'DONE')
102 clickById(stub, foundId)
104 def clear_text(stub, el):
105 print(stub.clear(aurum_pb2.ReqClear(elementId=el)))
108 with grpc.insecure_channel('127.0.0.1:50051') as channel:
109 stub = aurum_pb2_grpc.BootstrapStub(channel)
111 foundId = findElementByText(stub, 'Title')
113 clear_text(stub, foundId)
115 # foundId = findElementByText(stub, 'Photos')
117 # foundId = findElementByText(stub, 'Resume')
119 # if foundId != None:
120 # clickById(stub, foundId)
124 # foundId = findElementByText(stub, 'STOP')
126 # if foundId != None:
127 # clickById(stub, foundId)
129 if __name__ == '__main__':
130 logging.basicConfig()