From 38c6df692cc31ee5963155070928879b58a6280c Mon Sep 17 00:00:00 2001 From: forgetrelease <36836126+forgetrelease@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=90=8E=E7=82=B9=E5=87=BB=E5=B1=8F=E5=B9=95=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/cloud/sonic/agent/bridge/ios/SibTool.java | 11 +++++++++++ .../sonic/agent/tests/handlers/IOSStepHandler.java | 14 +++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java index 3535adb5..3a9dbe4e 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java @@ -803,6 +803,17 @@ public static String getSize(String udId) { } return size; } + public static int getScreenScale(String udId) { + String commandLine = "%s info -d com.apple.mobile.iTunes -u %s"; + String re = ProcessCommandTool.getProcessLocalCommandStr(String.format(commandLine, sib, udId)); + int size = 2; + try { + JSONObject r = JSON.parseObject(re); + size = r.getInteger("ScreenScaleFactor"); + } catch (Throwable ignored) { + } + return size; + } public static void mount(String udId) { String commandLine = "%s mount -u %s"; diff --git a/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java b/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java index 56f77025..8ccf6ed7 100755 --- a/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java +++ b/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java @@ -844,17 +844,9 @@ public void clickByImg(HandleContext handleContext, String des, String pathValue } if (findResult != null) { try { - String[] size = SibTool.getSize(udId).split("x"); - WindowSize windowSize = iosDriver.getWindowSize(); - int width; - int ori = SibTool.getOrientation(udId); - if (ori == 1 || ori == 2) { - width = windowSize.getWidth(); - } else { - width = windowSize.getHeight(); - } - iosDriver.tap(findResult.getX() / (Integer.parseInt(size[0]) / width), - findResult.getY() / (Integer.parseInt(size[0]) / width)); + double scale = SibTool.getScreenScale(udId); + iosDriver.tap((int) (findResult.getX()*1.0 / scale), + (int) (findResult.getY()*1.0 / scale)); } catch (Exception e) { log.sendStepLog(StepType.ERROR, "点击" + des + "失败!", ""); handleContext.setE(e);