UAT_focusCommand.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. # -*- coding:utf-8 -*-
  2. import time,sys,os
  3. from UAT_tree import UATTree
  4. from UAT_log import error,info,debug
  5. from UAT_PathManage import UATPathManage
  6. from UAT_runnerCommand import UATRunnerCommand
  7. from ssat_sdk.python_uiautomator import PyUIAutomator,DirectionManageAndroid,FocusManageAndroid
  8. ERROR = True
  9. INFO = True
  10. DEBUG = True
  11. '''
  12. 采用uiautomator技术,处理界面定位问题,用于移动焦点到目标组件上
  13. '''
  14. class FocusCommand():
  15. cls = "FocusCommand"
  16. UIObjParam = {
  17. "text": None, # MASK_TEXT,
  18. "textContains": None, # MASK_TEXTCONTAINS,
  19. "textMatches": None, # MASK_TEXTMATCHES,
  20. "textStartsWith": None, # MASK_TEXTSTARTSWITH,
  21. "className": None, # MASK_CLASSNAME
  22. "classNameMatches": None, # MASK_CLASSNAMEMATCHES
  23. "description": None, # MASK_DESCRIPTION
  24. "descriptionContains": None, # MASK_DESCRIPTIONCONTAINS
  25. "descriptionMatches": None, # MASK_DESCRIPTIONMATCHES
  26. "descriptionStartsWith": None, # MASK_DESCRIPTIONSTARTSWITH
  27. "checkable": None, # MASK_CHECKABLE
  28. "checked": None, # MASK_CHECKED
  29. "clickable": None, # MASK_CLICKABLE
  30. "longClickable": None, # MASK_LONGCLICKABLE,
  31. "scrollable": None, # MASK_SCROLLABLE,
  32. "enabled": None, # MASK_ENABLED,
  33. "focusable": None, # MASK_FOCUSABLE,
  34. "focused": None, # MASK_FOCUSED,
  35. "selected": None, # MASK_SELECTED,
  36. "packageName": None, # MASK_PACKAGENAME,
  37. "packageNameMatches": None, # MASK_PACKAGENAMEMATCHES,
  38. "resourceId": None, # MASK_RESOURCEID,
  39. "resourceIdMatches": None, # MASK_RESOURCEIDMATCHES,
  40. "index": None, # MASK_INDEX,
  41. "instance": None # MASK_INSTANCE,
  42. }
  43. UATParamMap = {
  44. "text":"text", # MASK_TEXT,
  45. "textContains":"textContains", # MASK_TEXTCONTAINS,
  46. "textMatch":"textMatches", # MASK_TEXTMATCHES,
  47. "textSWith":"textStartsWith", # MASK_TEXTSTARTSWITH,
  48. "class":"className", # MASK_CLASSNAME
  49. "classMatches":"classNameMatches", # MASK_CLASSNAMEMATCHES
  50. "desc":"description", # MASK_DESCRIPTION
  51. "descContain":"descriptionContains", # MASK_DESCRIPTIONCONTAINS
  52. "descMatch":"descriptionMatches", # MASK_DESCRIPTIONMATCHES
  53. "descSWith":"descriptionStartsWith", # MASK_DESCRIPTIONSTARTSWITH
  54. "checkable":"checkable", # MASK_CHECKABLE
  55. "checked":"checked", # MASK_CHECKED
  56. "clickable":"clickable", # MASK_CLICKABLE
  57. "lClickable":"longClickable", # MASK_LONGCLICKABLE,
  58. "scrollable":"scrollable", # MASK_SCROLLABLE,
  59. "enable":"enabled", # MASK_ENABLED,
  60. "focusable":"focusable", # MASK_FOCUSABLE,
  61. "focused":"focused", # MASK_FOCUSED,
  62. "selected":"selected", # MASK_SELECTED,
  63. "pkg":"packageName", # MASK_PACKAGENAME,
  64. "pkgMatch":"packageNameMatches", # MASK_PACKAGENAMEMATCHES,
  65. "resid":"resourceId", # MASK_RESOURCEID,
  66. "residMatch":"resourceIdMatches", # MASK_RESOURCEIDMATCHES,
  67. "index":"index", # MASK_INDEX,
  68. "instance":"instance" # MASK_INSTANCE,
  69. }
  70. def __init__(self, runnerCommand):
  71. self.runnerCommand = runnerCommand
  72. self.pyU = PyUIAutomator()
  73. self.dm = DirectionManageAndroid()
  74. self.fm = FocusManageAndroid(self.pyU, self.dm)
  75. self.inLayout= False
  76. '''
  77. 在parent界面,将焦点移动到目标option上。
  78. 焦点定位:根据layout是不是限制焦点范围,进行焦点组件寻找,焦点组件类型:focus、select、focusView、long-click
  79. 目标定位:纯粹是根据optionView配置组建坐标定位
  80. :param parent:当前电视界面的parent字典
  81. :param option:目标option字典
  82. :return True/False
  83. '''
  84. def focusOptionView(self, parent, option):
  85. #是否采用layout限制焦点判断范围
  86. layout = parent[UATTree.TAB_LAYOUT]
  87. print "focusOptionView,layout:",layout
  88. self.inLayout = layout[UATTree.Layout_Limit]
  89. # 找到目标optionView参数
  90. layoutUIObj = {}
  91. optionUIObjParam = self.setObjParam(option[UATTree.TAB_OPTION_VIEW])
  92. if self.inLayout == 1:
  93. layoutUIObjParam = self.setObjParam(layout)
  94. else:
  95. layoutUIObjParam = {}
  96. # 获取move key按键
  97. moveKey = parent[UATTree.TAB_MOVE_KEY]
  98. if moveKey[UATTree.Max_Try] != "":
  99. Max_Try = int(moveKey[UATTree.Max_Try])
  100. else:
  101. Max_Try = parent[UATTree.TAB_OPTION].__len__()
  102. findDirection = ["down","up"]
  103. keyType = UATTree.Key_Event
  104. if moveKey[UATTree.Key_Event].__len__() > 1:
  105. findDirection = moveKey[UATTree.Key_Event]
  106. keyType = UATTree.Key_Event
  107. elif moveKey[UATTree.Key_IR].__len__() > 1:
  108. findDirection = moveKey[UATTree.Key_IR]
  109. keyType = UATTree.Key_IR
  110. elif moveKey[UATTree.Key_Input].__len__() > 1:
  111. inputCmd = moveKey[UATTree.Key_Input]
  112. #TODO input情况的处理
  113. return False
  114. else:
  115. error(self.cls, "focusTargetOption", option[UATTree.TAB_NAME] + " option 读取 move_key失败", ERROR)
  116. return False
  117. #获取焦点View和optionview的area参数
  118. osamBounds = option[UATTree.TAB_OPTION_VIEW][UATTree.View_sambounds]
  119. fsamBounds = ""
  120. #获取焦点view参数
  121. fsParam = option[UATTree.TAB_FOCUS_SELECT]
  122. fvParam = option[UATTree.TAB_FOCUSE_VIEW]
  123. fvUIParam = self.setObjParam(fvParam)
  124. if fsParam[UATTree.FS_Type].__len__() > 1:
  125. if fsParam[UATTree.FS_Type].lower() == "focus":
  126. fsParam["focused"] = True
  127. elif fsParam[UATTree.FS_Type].lower() == "select":
  128. fsParam["select"] = True
  129. else:
  130. error(self.cls,"focusOptionView","Option %s focus-select参数异常。"%option[UATTree.TAB_NAME], ERROR)
  131. return False
  132. fsamBounds = fsParam[UATTree.View_sambounds]
  133. fsUIParam = self.setObjParam(fsParam)
  134. return self.toDestObj(optionUIObjParam, fsUIParam,Max_Try,findDirection,keyType,layoutUIObjParam,fsamBounds,osamBounds)
  135. elif fvUIParam.__len__() > 0:
  136. fsamBounds = fvParam[UATTree.View_sambounds]
  137. return self.toDestObj(optionUIObjParam, fvUIParam,Max_Try,findDirection,keyType,layoutUIObjParam,fsamBounds,osamBounds)
  138. else:
  139. error(self.cls, "focusOptionView", "Option %s focusView参数异常。" % option[UATTree.TAB_NAME], ERROR)
  140. return False
  141. def toDestObj(self, destUIParam, focusObjParam, Max_Try=10, findDirections=["down","up"], keyType=UATTree.Key_Event
  142. ,layoutUIParam={},fsamBounds="",osamBounds=""):
  143. # 按照传入的方向寻找Max_Try次,如果仍未聚焦到选中area,则按照传入方向的反方向 反向寻找 2*Max_Try 次
  144. print "toDestObj,enter:",Max_Try,findDirections,keyType
  145. count = 0
  146. Max_Try = Max_Try
  147. directIndex = 0
  148. while (True):
  149. if count >= Max_Try and directIndex >= findDirections.__len__():
  150. break
  151. # 等待聚焦效果刷新完成,稳定之后再获取相关的属性
  152. time.sleep(0.5)
  153. print "toDestObj,focusObjParam:",focusObjParam
  154. focusedUIObject = self.pyU.getUiObject2(focusObjParam)
  155. focusedBounds = focusedUIObject.info['bounds']
  156. # print "focusedBounds:",focusedBounds
  157. if layoutUIParam.__len__() > 0:
  158. layoutUIObj = self.pyU.getUiObject2(layoutUIParam)
  159. destUIObject = layoutUIObj.child(**destUIParam)
  160. else:
  161. destUIObject = self.pyU.getUiObject2(destUIParam)
  162. if destUIObject:
  163. print "focusOptionView,focusedBounds,destUIBounds:",focusedBounds, destUIObject.info['bounds']
  164. try:
  165. destBounds = destUIObject.info['bounds']
  166. # print "destBounds:", destBounds
  167. if self.hasFocusDest(focusedBounds, destBounds, ):
  168. print '成功聚焦到目标焦点:',destUIParam
  169. return True
  170. else:
  171. count = count + 1
  172. direction = self.dm.getTargetDirection(focusedBounds, destBounds)
  173. self.dm.goOneStep(self.pyU, direction, keyType)
  174. except Exception,e:
  175. print "toDestObj,e:",e
  176. # 出现控件出现一半的时候,获取控件信息会报错
  177. if count < Max_Try:
  178. count = count + 1
  179. else:
  180. directIndex = directIndex + 1
  181. self.fm.pressKeyByType(findDirections[directIndex], keyType)
  182. # 如果界面中没有目标文字的控件出现,则按照传入的方向寻找Max_Try次;仍然未找到 则反方向寻找2*Max_Try次
  183. else:
  184. if count < Max_Try:
  185. count = count + 1
  186. self.fm.pressKeyByType(findDirections[directIndex], keyType)
  187. else:
  188. directIndex = directIndex + 1
  189. self.fm.pressKeyByType(findDirections[directIndex], keyType)
  190. print "执行%s 次查找,仍未找到目标焦点!!" % (str(Max_Try))
  191. return False
  192. '''
  193. 根据配置的样本焦点框和OptionView 区域坐标,计算是否聚焦
  194. '''
  195. def hasFocusDest(self,focusedBounds, destBounds, fsamBounds="",osamBounds=""):
  196. if fsamBounds.__len__() < 1 or osamBounds.__len__()<1:
  197. return self.dm.isHasAnotherBounds(focusedBounds, destBounds)
  198. else:#在焦点框bounds特别大时,同时包含多个目标optionView时,用此方法判断是否选中。
  199. fsamBounds = self.strToBounds(fsamBounds)
  200. osamBounds = self.strToBounds(osamBounds)
  201. sdx=fsamBounds[0][0] - osamBounds[0][0]
  202. sdy=fsamBounds[0][1] - osamBounds[0][1]
  203. sdrate = self.calPointAngle(fsamBounds)
  204. focusBounds = self.strToBounds(focusedBounds)
  205. destBounds = self.strToBounds(destBounds)
  206. dx = focusBounds[0][0] - destBounds[0][0]
  207. dy = focusBounds[0][1] - destBounds[0][1]
  208. drate = dy / dx
  209. if (drate - sdrate) < 5:
  210. return True
  211. else:
  212. return False
  213. '''
  214. 计算点p1相对点p2的角度
  215. '''
  216. def calPointAngle(self, p1, p2):
  217. dx = p1[0]-p2[0]
  218. dy = p1[1]-p2[1]
  219. '''
  220. 将‘[801,116][1280,180]’转成数组[[801,116][1280,180]]
  221. '''
  222. def strToBounds(self,bstr):
  223. char = "[]"
  224. print "strToBounds,bstr:",bstr
  225. keyIndex = 1
  226. # key.__len__()-1 为去掉"["的处理
  227. i1 = bstr.find(char[0])
  228. i2 = bstr.find(char[1])
  229. if i1 == -1 or i2 == -1:
  230. return []
  231. str1 = bstr[i1: i2+1]
  232. str2 = bstr[i2+1 : bstr.__len__()]
  233. return [eval(str1),eval(str2)]
  234. '''
  235. 根据传入的uat界面obj参数,转换成UIObject参数
  236. 参数均用字典存储。
  237. '''
  238. def setObjParam(self, uatObjParam):
  239. uiObjParam = {}
  240. for uatKey in uatObjParam:
  241. uatParam = uatObjParam[uatKey]
  242. if self.UATParamMap.has_key(uatKey) and uatParam is not None and str(uatParam).__len__() > 0:
  243. uiObjParam[self.UATParamMap[uatKey]] = uatParam
  244. return uiObjParam
  245. '''
  246. 检测option组件,在电视上是否被选中了
  247. :param option 数据字典
  248. :return -1:未进入option的页面,找不到option UIObject;0:进入了option的页面,未选中option;1 已经选中option
  249. -2:代表未找到焦点
  250. '''
  251. def checkOptionChoose(self, option):
  252. optionUIObj = self.pyU.getUiObject(text=option["optionView"][UATTree.View_Text],
  253. resourceId=option["optionView"][UATTree.View_ID],
  254. description=option["optionView"][UATTree.View_Desc])
  255. if optionUIObj is None or optionUIObj.count == 0:
  256. return -1
  257. curUIObj = self.getChooseUIObj(option)
  258. if curUIObj is None or curUIObj.count == 0:
  259. return -2
  260. if self.dm.isHasAnotherBounds(curUIObj.info["bounds"], optionUIObj.info['bounds']):
  261. return 1
  262. else:
  263. return 0
  264. '''
  265. 根据option配置的焦点方式,返回当前页面焦点组件
  266. '''
  267. def getChooseUIObj(self, option):
  268. print "getChooseUIObj option:", option["focus-select"]
  269. if option["focus-select"]["type"].__len__() > 1:
  270. chooseType = option["focus-select"][UATTree.FS_Type]
  271. if chooseType.lower() == "focus":
  272. return self.pyU.getFocusedUIObject()
  273. elif chooseType.lower() == "select":
  274. return self.pyU.getSelectedUIObject()
  275. elif chooseType.lower() == "no":
  276. resId = option[UATTree.TAB_OPTION_VIEW][UATTree.View_ID]
  277. text = option[UATTree.TAB_OPTION_VIEW][UATTree.View_Text]
  278. className = option[UATTree.TAB_OPTION_VIEW][UATTree.View_Class]
  279. desc = option[UATTree.TAB_OPTION_VIEW][UATTree.View_Desc]
  280. return self.pyU.getUiObject(resourceId=resId, text=text, className=className, description=desc)
  281. else:
  282. error(self.cls, "getChooseUIObj", option["name"] + " option focus-select属性配置异常", ERROR)
  283. return None
  284. elif option["focuseView"][UATTree.Focus_Text].__len__() > 0 \
  285. or option["focuseView"][UATTree.Focus_ID].__len__() > 1 \
  286. or option["focuseView"][UATTree.Focus_Desc].__len__() > 0:
  287. return self.pyU.getUiObject(text=option["focuseView"][UATTree.Focus_Text],
  288. resourceId=option["focuseView"][UATTree.Focus_ID],
  289. description=option["focuseView"][UATTree.Focus_Desc])
  290. else:
  291. error(self.cls, "getChooseUIObj", option["name"] + " option 需要配置 focus-select或者FocusView", ERROR)
  292. return None
  293. '''
  294. 检测parent,在电视上是否被选中了。一个option被选中,表示选中
  295. :param option 数据字典
  296. :return
  297. -3:代表UIView判断未通过;
  298. -2:代表选中了parent,但未找到焦点;
  299. -1:未进入parent的页面,找不到parent layout;
  300. 0:进入了parent的页面,未选中parent;
  301. 1:已经选中parent
  302. '''
  303. def checkParentChoose(self, parent):
  304. debug(self.cls, "checkParentChoose", "parent:" + parent["name"], DEBUG)
  305. chooseTypeDict = {}
  306. layoutResId = parent["layout"][UATTree.Layout_ID]
  307. uiView = parent[UATTree.TAB_UI_VIEW]
  308. uiViewResId = uiView[UATTree.View_ID]
  309. uiViewText = uiView[UATTree.View_Text]
  310. uiViewDesc = uiView[UATTree.View_Desc]
  311. if layoutResId == "" and uiViewResId == "" and uiViewText == "" and uiViewDesc == "":
  312. debug(self.cls, "checkParentChoose",
  313. "Warning:Parent %s的Layout resId和UIView信息获取失败!!请注意检查UATree文件!!!" % parent['name'], DEBUG)
  314. return -1
  315. elif layoutResId != "":
  316. # 如果存在UIView信息,则先判断UIView
  317. if uiViewResId != "" or uiViewText != "" or uiViewDesc != "":
  318. isExist = self.checkUIViewExist(uiView)
  319. if isExist is False:
  320. info(self.cls, "checkParentChoose", "当前页面不存在Parent:%s的UIView组件,判断该界面非此parent" % parent['name'],
  321. INFO)
  322. return -3
  323. else:
  324. info(self.cls, "checkParentChoose", "已识别出Parent:%s的UIView组件" % parent['name'], INFO)
  325. description = parent["layout"][UATTree.Layout_Desc]
  326. if description != "":
  327. layoutUIObj = self.pyU.getUiObject(resourceId=parent["layout"][UATTree.Layout_ID],
  328. description=parent["layout"][UATTree.Layout_Desc])
  329. else:
  330. layoutUIObj = self.pyU.getUiObject(resourceId=parent["layout"][UATTree.Layout_ID])
  331. if layoutUIObj is None or layoutUIObj.count == 0:
  332. # debug(self.cls, "checkParentChoose", "parent isn't " + parent["name"], DEBUG)
  333. return -1
  334. # print "checkParentChoose, layoutUIObj:",layoutUIObj.info
  335. debug(self.cls, "checkParentChoose", "layoutUIObj:" + str(layoutUIObj.info), DEBUG)
  336. for optionName in parent["option"]:
  337. option = parent["option"][optionName]
  338. if option["focus-select"]["type"].__len__() > 1:
  339. chooseTypeDict[option["focus-select"][UATTree.FS_Type]] = option
  340. elif option["focuseView"][UATTree.Focus_Text].__len__() > 0 \
  341. or option["focuseView"][UATTree.Focus_ID].__len__() > 1 \
  342. or option["focuseView"][UATTree.Focus_Desc].__len__() > 0:
  343. chooseTypeDict[option["focuseView"][UATTree.Focus_ID]
  344. + option["focuseView"][UATTree.Focus_Text]
  345. + option["focuseView"][UATTree.Focus_Desc]] = option
  346. info(self.cls, "checkParentChoose", str(chooseTypeDict), INFO)
  347. for key in chooseTypeDict.keys():
  348. option = chooseTypeDict[key]
  349. chooseUIObj = self.getChooseUIObj(option)
  350. # TODO 如果选中效果,是没有type[no],例如快捷键,如何处理?
  351. if chooseUIObj is None or chooseUIObj.count == 0:
  352. return -2
  353. debug(self.cls, "checkParentChoose", "chooseUIObj:" + str(chooseUIObj.info), DEBUG)
  354. # 获取到chooseUIObj后,与layout对比坐标,确认焦点是否存在于layout之中
  355. layoutBounds = layoutUIObj.info['bounds']
  356. choosingBounds = chooseUIObj.info['bounds']
  357. if not self.dm.isHasAnotherBounds(layoutBounds, choosingBounds):
  358. info(self.cls, "checkParentChoose",
  359. "识别出parent %s的Layout,但焦点不在该Layout之中,判断界面未处于该parent" % (parent['name']), INFO)
  360. return -2
  361. # 如果该页面text属性不为空,则确认该parent下所有option的text,是否存在于当前页面中;如果text属性为空,则判断index属性
  362. for optionName in parent["option"]:
  363. option = parent["option"][optionName]
  364. # 如果有text属性则确认Text,是否能对比成功
  365. optionText = option[UATTree.TAB_OPTION_VIEW][UATTree.View_Text]
  366. optionId = option[UATTree.TAB_OPTION_VIEW][UATTree.View_ID]
  367. optionIndex = option[UATTree.TAB_OPTION_VIEW][UATTree.View_Index]
  368. if optionText.__len__() > 0:
  369. info(self.cls, "checkParentChoose",
  370. "checking parent %s text %s" % (parent['name'], optionText), INFO)
  371. textObj = self.pyU.getUiObject(text=optionText)
  372. elif optionId.__len__() > 0:
  373. info(self.cls, "checkParentChoose",
  374. "checking parent %s optionId %s" % (parent['name'], optionId),
  375. INFO)
  376. textObj = self.pyU.getUiObject(resourceId=optionId)
  377. elif optionIndex != "":
  378. # index属性无法用于判断option,如果在以index属性作为判断依据的页面,则直接返回在这个页面
  379. info(self.cls, "checkParentChoose",
  380. "已找到目标parent %s,该页面为Index item页面,无法判断具体option" % parent['name'], INFO)
  381. return 1
  382. else:
  383. error(self.cls, "checkParentChoose", "当前参数不足以判断option %s是否存在" % (option['name']), ERROR)
  384. continue
  385. if textObj.exists:
  386. info(self.cls, "checkParentChoose",
  387. "已找到目标parent %s,并识别出该parent下的option %s" % (parent['name'], option['name']), INFO)
  388. return 1
  389. else:
  390. info(self.cls, "checkParentChoose",
  391. "return 0", INFO)
  392. return 0
  393. else:
  394. isExist = self.checkUIViewExist(uiView)
  395. if not isExist:
  396. return -3
  397. else:
  398. info(self.cls, "checkParentChoose",
  399. "识别出parent %s的UIView参数,判断处于该界面中" % (parent['name']), INFO)
  400. return 1
  401. '''
  402. 检测某个弹窗是否存在。
  403. 弹窗相关的参数放在UIView中配置。
  404. 当存在resId参数时,使用resId获取对象并获取文本,再与text做比较;
  405. 当不存在resId参数时,使用text直接获取对象,判断对象是否存在。
  406. 与checkParentChoose判断不一致,做特殊处理。
  407. '''
  408. def checkDialogExist(self, dialog):
  409. debug(self.cls, "checkDialogExist", "dialog:" + dialog["name"], DEBUG)
  410. dialogText = dialog[UATTree.TAB_UI_VIEW][UATTree.UIView_Text]
  411. dialogResId = dialog[UATTree.TAB_UI_VIEW][UATTree.UIView_ID]
  412. # print "checkDialogExist.dialogText:", dialogText
  413. # print "checkDialogExist.dialogResId:", dialogResId
  414. if dialogResId != "":
  415. textObj = self.pyU.getUiObject(resourceId=dialogResId)
  416. if textObj.exists:
  417. objText = textObj.info['text']
  418. # print "checkDialogExist.objText:", objText
  419. if dialogText in objText:
  420. return 1
  421. else:
  422. return 0
  423. else:
  424. return 0
  425. else:
  426. textObj = self.pyU.getUiObject(text=dialogText)
  427. if textObj.exists:
  428. return 1
  429. else:
  430. return 0
  431. def checkUIViewExist(self, uiView):
  432. resid = uiView[UATTree.View_ID]
  433. text = uiView[UATTree.View_Text]
  434. description = uiView[UATTree.View_Desc]
  435. uiViewObj = self.pyU.getUiObject(resourceId=resid,
  436. text=text,
  437. description=description)
  438. if not uiViewObj.exists:
  439. return False
  440. else:
  441. return True
  442. if __name__ == "__main__":
  443. uatPathManage = UATPathManage()
  444. pyU = PyUIAutomator()
  445. dm = DirectionManageAndroid()
  446. fm = FocusManageAndroid(pyU, dm)
  447. runnerCmd = UATRunnerCommand(uatPathManage, pyU, dm, fm)
  448. focusCmd = FocusCommand(runnerCmd)
  449. focusCmd.strToBounds('[801,116][1280,180]')
  450. # option = focusCmd.runnerCommand.uatPathManage.uatData.getOption("av_devices_settings")
  451. # parent = focusCmd.runnerCommand.uatPathManage.uatData.getParentByOption(option)
  452. # focusCmd.focusOptionView(parent, option)
  453. # print "dump_hierarchy 0:",time.time()
  454. # print focusCmd.pyU.dump_hierarchy()
  455. # print "dump_hierarchy 1:",time.time()
  456. # uiobjg = focusCmd.pyU.getUiObject()