Skip to content

Commit

Permalink
fix: add on_method_ready to yosemite_ext
Browse files Browse the repository at this point in the history
(cherry picked from commit ab1ec3e)
  • Loading branch information
yimelia committed Sep 27, 2023
1 parent a4b447c commit b4e7c1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airtest/core/android/yosemite.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _install_apk_upgrade(self, apk_path, package):
LOGGING.info(
"local version code is {}, installed version code is {}".format(apk_version, installed_version))
try:
self.adb.install_app(apk_path, replace=True, install_options=["-t", "-g"])
self.adb.pm_install(apk_path, replace=True, install_options=["-t"])
except:
if installed_version is None:
raise
Expand Down
8 changes: 6 additions & 2 deletions airtest/core/android/yosemite_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .constant import YOSEMITE_APK, YOSEMITE_PACKAGE
from airtest.core.android.yosemite import Yosemite
from airtest.core.error import AirtestError
from airtest.utils.snippet import on_method_ready
from airtest.utils.logger import get_logger
LOGGING = get_logger(__name__)

Expand All @@ -17,6 +18,7 @@ def path(self):
self._path = self.adb.path_app(YOSEMITE_PACKAGE)
return self._path

@on_method_ready('install_or_upgrade')
def device_op(self, op_name, op_args=""):
"""
Perform device operations
Expand Down Expand Up @@ -46,7 +48,7 @@ def get_clipboard(self):

def set_clipboard(self, text):
"""
Set clipboard content
Set clipboard content, will automatically replace single quotes with double quotes
Args:
text: text to be set
Expand All @@ -55,7 +57,9 @@ def set_clipboard(self, text):
None
"""
ret = self.device_op("clipboard", f'--TEXT "{text}"')
if "\'" in text:
text = text.replace("\'", "\"")
ret = self.device_op("clipboard", f"--TEXT '{text}'")
if ret and "Exception" in ret:
raise AirtestError("set clipboard failed: %s" % ret)

Expand Down

0 comments on commit b4e7c1e

Please sign in to comment.