AirtestProject / Airtest

UI Automation Framework for Games and Apps
http://airtest.netease.com/
Apache License 2.0
8.29k stars 1.3k forks source link

Airtest/airtest/core /api.py 446行swipe函数vector判断逻辑条件错误 #1173

Open vico6885 opened 1 year ago

vico6885 commented 1 year ago
if v2:
    if isinstance(v2, Template):
        pos2 = loop_find(v2, timeout=ST.FIND_TIMEOUT_TMP)
    else:
        pos2 = v2
elif vector:
    **if vector[0] <= 1 and vector[1] <= 1:** # 该条件会使得当vector[0]、vector[1]为负偏移像素量时,错误作为矢量系数乘以分辨率,从而导致操作量溢出,这里的判断条件应为vector[0]、vector[1]是否同时介于[-1,1]区间
        w, h = G.DEVICE.get_current_resolution()
        vector = (int(vector[0] * w), int(vector[1] * h))
    pos2 = (pos1[0] + vector[0], pos1[1] + vector[1])
else:
    raise Exception("no enough params for swipe")