aurum: re-arrange files and add guide & scripts for TV
[platform/core/uifw/aurum.git] / protocol / resources / python / tv / multiView.py
1 from __future__ import print_function
2 import os
3 import sys
4 sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
5 from aurum_pb2 import *
6 from aurum_pb2_grpc import BootstrapStub
7 import logging
8 import grpc
9 import time
10
11 # Second view size change and check
12 # Please refer key codes below page
13 # https://code.sec.samsung.net/confluence/display/GFX/VD+Key+Code+Table
14 def MultiViewSizeTest(stub):
15     response = stub.findElement(ReqFindElement(textField='VSComponent2'))
16     if len(response.elements) <= 0: return False
17
18     responseGuide = stub.findElement(ReqFindElement(textField='Guide TextBox'))
19     if len(response.elements) <= 0:
20         stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Return'))
21
22     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Right'))
23     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Up'))
24     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Return'))
25     # Wait until render finished
26     time.sleep(1)
27
28     responseAfter = stub.findElement(ReqFindElement(textField='VSComponent2'))
29     if len(responseAfter.elements) <= 0: return False
30
31     if response.elements[0].geometry.width < responseAfter.elements[0].geometry.width:
32         return True
33
34     return False
35
36 # Launch 3rd-party app and long press back key test
37 def MultiViewContentsTest(stub):
38     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Return'))
39     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Left'))
40     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Up'))
41     stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Return'))
42     # Wait until render finished
43     time.sleep(10)
44
45     # It fails if there is a View
46     response= stub.findElement(ReqFindElement(textField='VSComponent2'))
47     if len(response.elements) > 0: return False
48
49     stub.sendKey(ReqKey(type='XF86', actionType='LONG_STROKE', XF86keyCode='XF86Back'))
50
51     return True
52
53 # Launch application. it returns application running state
54 def launchAppTest(stub):
55     stub.launchApp(ReqLaunchApp(packageName='com.samsung.tv.multiscreen'))
56     time.sleep(5)
57     return stub.getAppInfo(ReqGetAppInfo(packageName='com.samsung.tv.multiscreen')).isRunning
58
59 # Close application. it returns application running state
60 def closeAppTest(stub):
61     stub.closeApp(ReqCloseApp(packageName='com.samsung.tv.multiscreen'))
62     return stub.getAppInfo(ReqGetAppInfo(packageName='com.samsung.tv.multiscreen')).isRunning != True
63
64 def runTest(stub, testFunc):
65     print("Testing started :", testFunc)
66
67     result = testFunc(stub)
68
69     print("Testing result :", result)
70     return True
71
72 def run():
73     with grpc.insecure_channel('127.0.0.1:50051') as channel:
74         stub = BootstrapStub(channel)
75         runTest(stub, launchAppTest)
76         runTest(stub, MultiViewSizeTest)
77         runTest(stub, MultiViewContentsTest)
78         runTest(stub, closeAppTest)
79
80 if __name__ == '__main__':
81     logging.basicConfig()
82     run()