|
@@ -8,6 +8,7 @@ from UIParamUtil import UIParamUtil
|
|
|
from ssat_sdk.python_uiautomator import PyUIAutomator,DirectionManageAndroid,FocusManageAndroid
|
|
|
import math
|
|
|
import traceback
|
|
|
+import copy
|
|
|
|
|
|
ERROR = True
|
|
|
INFO = True
|
|
@@ -139,6 +140,7 @@ class FocusCommand():
|
|
|
break
|
|
|
time.sleep(0.1)
|
|
|
destUIObject = self.getOptionUIObj(option, layoutUIObjParam)
|
|
|
+
|
|
|
if destUIObject and destUIObject.exists():
|
|
|
info(self.cls,"getNoFocusedObj","找到目标option %s"%option[UATTree.TAB_NAME],INFO)
|
|
|
return True
|
|
@@ -166,6 +168,14 @@ class FocusCommand():
|
|
|
focusCount = 0 # 当目标和聚焦点在一个页面同时存在时,从当前聚焦点到目标的移动次数
|
|
|
focusedBoundsPre = {u'top': 0, u'left': 0, u'right': 0, u'bottom': 0} # 上一轮聚焦点的坐标
|
|
|
destBoundsPre = {u'top': 0, u'left': 0, u'right': 0, u'bottom': 0} # 上一轮目标的坐标
|
|
|
+ hb_keyDict = parent[UATTree.TAB_OTHERS][UATTree.Key_HeartBeat]
|
|
|
+ # print "##########", hb_keyDict
|
|
|
+ # print "##########", parent[UATTree.TAB_OTHERS]
|
|
|
+ if hb_keyDict != {}:
|
|
|
+ # 执行心跳按键
|
|
|
+ info(self.cls, "toDestObj", "executeHeartBeatKey:%s"%hb_keyDict, INFO)
|
|
|
+ self.fm.executeHeartBeatKey(hb_keyDict)
|
|
|
+
|
|
|
while (True):
|
|
|
if count >= Max_Try and directIndex >= findDirections.__len__()-1:
|
|
|
break
|
|
@@ -213,7 +223,7 @@ class FocusCommand():
|
|
|
focusCount += 1 # 如果focusCount=0,则将当前聚焦点和目标坐标赋值给前一次
|
|
|
focusedBoundsPre = focusedBounds
|
|
|
destBoundsPre = destBounds
|
|
|
- info(self.cls,"toDestObj.focusCount.countStart")
|
|
|
+ info(self.cls,"toDestObj.focusCount.countStart", "focusCount:%s"%focusCount,INFO)
|
|
|
continue
|
|
|
else:
|
|
|
error(self.cls, "toDestObj", "未找到目标焦点!!!", ERROR)
|
|
@@ -327,6 +337,12 @@ class FocusCommand():
|
|
|
def checkOptionExist(self, option, parent):
|
|
|
# print "checkOptionExist,option:",option
|
|
|
moveKey = parent[UATTree.TAB_MOVE_KEY]
|
|
|
+ hb_keyDict = parent[UATTree.TAB_OTHERS][UATTree.Key_HeartBeat]
|
|
|
+ if hb_keyDict != {}:
|
|
|
+ # 执行心跳按键
|
|
|
+ info(self.cls, "checkOptionExist", "executeHeartBeatKey:%s"%hb_keyDict, INFO)
|
|
|
+ self.fm.executeHeartBeatKey(hb_keyDict)
|
|
|
+
|
|
|
optionName = option['name']
|
|
|
print "checkOptionExist,moveKey:", moveKey
|
|
|
Max_Try = moveKey[UATTree.Max_Try]
|
|
@@ -340,32 +356,69 @@ class FocusCommand():
|
|
|
Reversecount = 0
|
|
|
lastObj = ""
|
|
|
|
|
|
- while (True):
|
|
|
- if count >= Max_Try and Reversecount >= Reverse_Max_Try:
|
|
|
- break
|
|
|
- # 如果找到目标直接返回
|
|
|
- debug(self.cls,"checkOptionExist","optionView:%s"%option,DEBUG)
|
|
|
- opUIParam = UIParamUtil.setObjParam(option["optionView"])
|
|
|
- ###
|
|
|
- try:
|
|
|
- opOBJ = self.pyU.getUiObject2(opUIParam)
|
|
|
- opOBJInfo = opOBJ.info
|
|
|
- debug(self.cls,"checkOptionExist","opOBJInfo: %s"%opOBJInfo,DEBUG)
|
|
|
- break
|
|
|
- except Exception,e:
|
|
|
- opOBJ = None
|
|
|
- if count < Max_Try:
|
|
|
- flag = 1
|
|
|
- count += 1
|
|
|
- print "now count:", count
|
|
|
- else:
|
|
|
- flag = 0
|
|
|
- Reversecount += 1
|
|
|
- print "now Reversecount:", Reversecount
|
|
|
- self.runnerCommand.executeMoveKey(moveKey, flag)
|
|
|
- if opOBJ is not None and opOBJ.exists():
|
|
|
- info(self.cls, "checkOptionExist", "当前页面已找到option: %s" % optionName, INFO)
|
|
|
- return True
|
|
|
+ opUIParam = UIParamUtil.setObjParam(option["optionView"])
|
|
|
+
|
|
|
+ # 为了兼容多文本,逐个遍历文本,针对text属性做特殊处理
|
|
|
+ if "text" in opUIParam and type(opUIParam['text']) == type([]):
|
|
|
+ for text in opUIParam['text']:
|
|
|
+ uiParam = copy.deepcopy(opUIParam)
|
|
|
+ uiParam['text'] = text
|
|
|
+ while (True):
|
|
|
+ if count >= Max_Try and Reversecount >= Reverse_Max_Try:
|
|
|
+ break
|
|
|
+ # 如果找到目标直接返回
|
|
|
+ debug(self.cls,"checkOptionExist","optionView:%s"%option,DEBUG)
|
|
|
+ ###
|
|
|
+ try:
|
|
|
+ opOBJ = self.pyU.getUiObject2(uiParam)
|
|
|
+ opOBJInfo = opOBJ.info
|
|
|
+ debug(self.cls,"checkOptionExist","opOBJInfo: %s"%opOBJInfo,DEBUG)
|
|
|
+ break
|
|
|
+ except Exception,e:
|
|
|
+ opOBJ = None
|
|
|
+ if count < Max_Try:
|
|
|
+ flag = 1
|
|
|
+ count += 1
|
|
|
+ print "now count:", count
|
|
|
+ else:
|
|
|
+ flag = 0
|
|
|
+ Reversecount += 1
|
|
|
+ print "now Reversecount:", Reversecount
|
|
|
+ self.runnerCommand.executeMoveKey(moveKey, flag)
|
|
|
+ # print "###",type(opOBJ),opOBJ
|
|
|
+ if opOBJ is not None:
|
|
|
+ if opOBJ.exists:
|
|
|
+ info(self.cls, "checkOptionExist", "当前页面已找到option: %s" % optionName, INFO)
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ while (True):
|
|
|
+ if count >= Max_Try and Reversecount >= Reverse_Max_Try:
|
|
|
+ break
|
|
|
+ # 如果找到目标直接返回
|
|
|
+ debug(self.cls, "checkOptionExist", "optionView:%s" % option, DEBUG)
|
|
|
+ ###
|
|
|
+ try:
|
|
|
+ opOBJ = self.pyU.getUiObject2(opUIParam)
|
|
|
+ opOBJInfo = opOBJ.info
|
|
|
+ debug(self.cls, "checkOptionExist", "opOBJInfo: %s" % opOBJInfo, DEBUG)
|
|
|
+ break
|
|
|
+ except Exception, e:
|
|
|
+ opOBJ = None
|
|
|
+ if count < Max_Try:
|
|
|
+ flag = 1
|
|
|
+ count += 1
|
|
|
+ print "now count:", count
|
|
|
+ else:
|
|
|
+ flag = 0
|
|
|
+ Reversecount += 1
|
|
|
+ print "now Reversecount:", Reversecount
|
|
|
+ self.runnerCommand.executeMoveKey(moveKey, flag)
|
|
|
+ # print "###", type(opOBJ), opOBJ
|
|
|
+ if opOBJ is not None:
|
|
|
+ if opOBJ.exists:
|
|
|
+ info(self.cls, "checkOptionExist", "当前页面已找到option: %s" % optionName, INFO)
|
|
|
+ return True
|
|
|
+
|
|
|
info(self.cls, "checkOptionExist", "注意!!!当前页面未找到option: %s" % optionName, INFO)
|
|
|
return False
|
|
|
|
|
@@ -475,6 +528,7 @@ class FocusCommand():
|
|
|
destUIParam = UIParamUtil.setObjParam(option[UATTree.TAB_OPTION_VIEW])
|
|
|
debug(self.cls, "getOptionUIObj", "destUIParam:" + str(destUIParam), DEBUG)
|
|
|
destUITextExist = False
|
|
|
+ destUIObject = None
|
|
|
try:
|
|
|
destUIText = destUIParam['text']
|
|
|
destUITextExist = True
|
|
@@ -564,6 +618,7 @@ class FocusCommand():
|
|
|
return -3
|
|
|
else:
|
|
|
debug(self.cls, "checkParentChoose", "已识别出Parent:%s的UIView组件" % parent[UATTree.TAB_NAME], DEBUG)
|
|
|
+ # debug(self.cls, "checkParentChoose", "UIView组件内容:%s" % uiView, DEBUG)
|
|
|
# 判断Layout是否存在
|
|
|
layoutUIObj = self.pyU.getUiObject2(layoutUIParam)
|
|
|
if layoutUIObj is None or layoutUIObj.exists() is False:
|
|
@@ -646,10 +701,12 @@ class FocusCommand():
|
|
|
return True
|
|
|
uiviewObjParam = UIParamUtil.setObjParam(uiView)
|
|
|
uiViewObj = self.pyU.getUiObject2(uiviewObjParam)
|
|
|
- if uiViewObj is None or uiViewObj.exists is False:
|
|
|
+ if uiViewObj is None:
|
|
|
return False
|
|
|
- else:
|
|
|
+ elif uiViewObj.exists:
|
|
|
return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
|
|
|
|
|
|
def moveToCheckedRedioButton(self, fsParam, findDirection="down", keyType=UATTree.Key_Event, maxTry=20):
|