1 from __future__ import print_function
2 from aurum_pb2 import *
8 from PIL import ImageTk,Image
11 stub.touchUp(ReqTouchUp(coordination=Point(x=160,y=30), seqId=0))
12 stub.touchUp(ReqTouchUp(coordination=Point(x=160,y=30), seqId=1))
13 stub.touchUp(ReqTouchUp(coordination=Point(x=160,y=30), seqId=2))
15 res = stub.touchDown(ReqTouchDown(coordination=Point(x=160,y=330)))
19 for yy in range(330, 30, -10):
20 stub.touchMove(ReqTouchMove(coordination=Point(x=160,y=yy), seqId=seq))
21 stub.touchUp(ReqTouchUp(coordination=Point(x=160,y=30), seqId=seq))
27 def traverse(node, canvas, depth):
28 print('traverse', depth)
29 print('size:',node.geometry, node)
32 rect = canvas.create_rectangle(node.geometry.x, node.geometry.y, node.geometry.x+node.geometry.width, node.geometry.y+node.geometry.height, outline='red')
33 for child in node.child:
34 traverse(child, canvas, depth+1)
36 def dumpTest(stub, tkroot):
37 response = stub.findElement(ReqFindElement(maxDepth=1, minDepth=1, isShowing=True))
39 for i in response.elements:
40 response = stub.dumpObjectTree(ReqDumpObjectTree(elementId=i.elementId))
43 responses = stub.takeScreenshot(ReqTakeScreenshot())
44 image = open("screenshot.png", "wb")
46 image.write(res.image)
49 canvas = Canvas(tkroot, width=360, height=360)
52 img = ImageTk.PhotoImage(Image.open("./screenshot.png"))
54 canvas.create_image(0, 0, anchor=NW, image=img)
56 traverse(response.roots[0], canvas, 0)
62 with grpc.insecure_channel('127.0.0.1:50051') as channel:
63 stub = aurum_pb2_grpc.BootstrapStub(channel)
65 root.geometry('360x360')
73 # print(stub.getLocation(ReqGetLocation()).status)
74 # print(stub.sync(ReqEmpty()))
75 # print(stub.getDeviceTime(ReqGetDeviceTime(type='WALLCLOCK')))
76 # print(stub.sendKey(ReqKey(type='WHEELUP')))
78 # print(stub.sendKey(ReqKey(type='WHEELDOWN')))
80 # print(stub.sendKey(ReqKey(type='HOME')))
81 # print(stub.sendKey(ReqKey(type='POWER')))
82 # stub.killServer(aurum_pb2.ReqEmpty())
84 if __name__ == '__main__':