From a09e6c161d84949126133c8a703d0c0604a81ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=90=A6?= Date: Tue, 17 Jan 2023 11:16:47 +0800 Subject: [PATCH] support ADBTouch (cherry picked from commit 5d4a429dbc95d040140ca2c538a0d04f78837876) --- .../core/android/touch_methods/touch_proxy.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/airtest/core/android/touch_methods/touch_proxy.py b/airtest/core/android/touch_methods/touch_proxy.py index d2320d1c..7864191b 100644 --- a/airtest/core/android/touch_methods/touch_proxy.py +++ b/airtest/core/android/touch_methods/touch_proxy.py @@ -3,6 +3,7 @@ from collections import OrderedDict from airtest.core.android.touch_methods.minitouch import Minitouch from airtest.core.android.touch_methods.maxtouch import Maxtouch +from airtest.core.android.touch_methods.base_touch import BaseTouch from airtest.core.android.constant import TOUCH_METHOD from airtest.utils.logger import get_logger @@ -61,24 +62,19 @@ def auto_setup(cls, adb, default_method=None, ori_transformer=None, size_info=No >>> touch_proxy.touch((100, 100)) """ - print(111111111111111111111111111, default_method) if default_method and default_method in cls.TOUCH_METHODS: touch_method = cls.TOUCH_METHODS[default_method].METHOD_CLASS(adb, size_info=size_info, input_event=input_event) impl = cls.TOUCH_METHODS[default_method](touch_method, ori_transformer) if cls.check_touch(impl): return TouchProxy(impl) - # cls.TOUCH_METHODS中不包含ADBTOUCH,因此即使指定了default_method=ADBTOUCH,也优先尝试初始化其他点击方法 - if default_method and default_method == "ADBTOUCH": - adb_touch = AdbTouchImplementation(adb) - return TouchProxy(adb_touch) - for name, touch_impl in cls.TOUCH_METHODS.items(): - if default_method == name: - continue - touch_method = touch_impl.METHOD_CLASS(adb, size_info=size_info, input_event=input_event) - impl = touch_impl(touch_method, ori_transformer) - if cls.check_touch(impl): - return TouchProxy(impl) + + if not default_method: + for name, touch_impl in cls.TOUCH_METHODS.items(): + touch_method = touch_impl.METHOD_CLASS(adb, size_info=size_info, input_event=input_event) + impl = touch_impl(touch_method, ori_transformer) + if cls.check_touch(impl): + return TouchProxy(impl) # If both minitouch and maxtouch fail to initialize, use adbtouch # 如果minitouch和maxtouch都初始化失败,使用adbtouch @@ -112,6 +108,9 @@ def swipe(self, p1, p2, duration=0.5, *args, **kwargs): duration *= 1000 self.base_touch.swipe(p1, p2, duration=duration) + def teardown(self): + pass + @register_touch class MinitouchImplementation(AdbTouchImplementation):