From 9d4919c943df69d9e2ab79c2db306f6a29e2cccb Mon Sep 17 00:00:00 2001 From: YeungHoiChiu <1005935991@qq.com> Date: Tue, 3 Sep 2024 18:55:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=83=E7=B4=A0=E6=8E=A7=E4=BB=B6=E5=89=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/transport/TransportServer.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java index f322988f..bab57944 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java @@ -18,6 +18,7 @@ package org.cloud.sonic.controller.transport; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import jakarta.websocket.*; import jakarta.websocket.server.PathParam; @@ -25,6 +26,8 @@ import lombok.extern.slf4j.Slf4j; import org.cloud.sonic.controller.config.WsEndpointConfigure; import org.cloud.sonic.controller.models.domain.Agents; +import org.cloud.sonic.controller.models.dto.ElementsDTO; +import org.cloud.sonic.controller.models.dto.StepsDTO; import org.cloud.sonic.controller.models.interfaces.AgentStatus; import org.cloud.sonic.controller.models.interfaces.ConfType; import org.cloud.sonic.controller.services.*; @@ -33,6 +36,8 @@ import org.springframework.stereotype.Component; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; @Component @@ -147,6 +152,13 @@ public void onMessage(String message, Session session) { case "errCall": agentsService.errCall(jsonMsg.getInteger("agentId"), jsonMsg.getString("udId"), jsonMsg.getInteger("tem"), jsonMsg.getInteger("type")); break; + case "checkLocation": + JSONObject step = generateStep(jsonMsg, "runStep"); + Session agentSession2 = BytesTool.agentSessionMap.get(jsonMsg.getInteger("agentId")); + if (agentSession2 != null) { + BytesTool.sendText(agentSession2, step.toJSONString()); + } + break; } } @@ -170,6 +182,36 @@ private JSONObject findSteps(JSONObject jsonMsg, String msg) { return steps; } + /** + * 用作调试元素定位是否准确时,生成点击事件的测试步骤 + * + * @param jsonMsg + * @param msg + * @return + */ + private JSONObject generateStep(JSONObject jsonMsg, String msg) { + StepsDTO stepsDTO = new StepsDTO(); + ElementsDTO elementsDTO = new ElementsDTO(); + elementsDTO.setEleType(jsonMsg.getString("eleType")) + .setEleValue(jsonMsg.getString("element")); + List elements = new ArrayList<>(); + elements.add(elementsDTO); + stepsDTO.setStepType("click") + .setElements(elements) + .setPlatform(jsonMsg.getInteger("pf")); + JSONArray step = new JSONArray(); + step.add(stepsDTO); + JSONObject stepObj = new JSONObject(); + stepObj.put("msg", msg); + stepObj.put("pf", jsonMsg.getInteger("pf")); + stepObj.put("steps", step); + stepObj.put("sessionId", jsonMsg.getString("sessionId")); + stepObj.put("pwd", jsonMsg.getString("pwd")); + stepObj.put("udId", jsonMsg.getString("udId")); + return stepObj; + } + + @OnClose public void onClose(Session session) { log.info("Agent: {} disconnected.", session.getId()); From b7f8e1c4d1640e21bca4cb1ec9cd827b1b422717 Mon Sep 17 00:00:00 2001 From: YeungHoiChiu <1005935991@qq.com> Date: Wed, 4 Sep 2024 20:46:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=83=E7=B4=A0=E6=8E=A7=E4=BB=B6=E5=89=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6--=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/sonic/controller/transport/TransportServer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java index bab57944..29150a2e 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java @@ -152,7 +152,7 @@ public void onMessage(String message, Session session) { case "errCall": agentsService.errCall(jsonMsg.getInteger("agentId"), jsonMsg.getString("udId"), jsonMsg.getInteger("tem"), jsonMsg.getInteger("type")); break; - case "checkLocation": + case "generateStep": JSONObject step = generateStep(jsonMsg, "runStep"); Session agentSession2 = BytesTool.agentSessionMap.get(jsonMsg.getInteger("agentId")); if (agentSession2 != null) { @@ -196,7 +196,9 @@ private JSONObject generateStep(JSONObject jsonMsg, String msg) { .setEleValue(jsonMsg.getString("element")); List elements = new ArrayList<>(); elements.add(elementsDTO); - stepsDTO.setStepType("click") + String stepType = jsonMsg.getString("eleType").equals("point") ? "tap" : "click"; + stepsDTO.setStepType(stepType) + .setConditionType(0) .setElements(elements) .setPlatform(jsonMsg.getInteger("pf")); JSONArray step = new JSONArray(); From 6716d882482b8a821525acd0cda3e3c56fd6e889 Mon Sep 17 00:00:00 2001 From: YeungHoiChiu <1005935991@qq.com> Date: Wed, 4 Sep 2024 20:48:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=83=E7=B4=A0=E6=8E=A7=E4=BB=B6=E5=89=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6--=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/cloud/sonic/controller/transport/TransportServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java index 29150a2e..b2d0c2a1 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java @@ -183,7 +183,7 @@ private JSONObject findSteps(JSONObject jsonMsg, String msg) { } /** - * 用作调试元素定位是否准确时,生成点击事件的测试步骤 + * 增加元素定位时,为了方便验证定位是否有效,此时可能还没有入库,所以先生成一个临时的步骤 * * @param jsonMsg * @param msg From be0fcc6e8bf152a3fa77d26f26b0ad9d2d1c5cf7 Mon Sep 17 00:00:00 2001 From: YeungHoiChiu <1005935991@qq.com> Date: Wed, 4 Sep 2024 21:41:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=83=E7=B4=A0=E6=8E=A7=E4=BB=B6=E5=89=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6--=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Ddebug=E6=8E=A7=E4=BB=B6=E6=97=B6=EF=BC=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=B2=A1=E6=9C=89=E6=8E=A7=E4=BB=B6=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/cloud/sonic/controller/transport/TransportServer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java index b2d0c2a1..a6e96a63 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/transport/TransportServer.java @@ -193,7 +193,8 @@ private JSONObject generateStep(JSONObject jsonMsg, String msg) { StepsDTO stepsDTO = new StepsDTO(); ElementsDTO elementsDTO = new ElementsDTO(); elementsDTO.setEleType(jsonMsg.getString("eleType")) - .setEleValue(jsonMsg.getString("element")); + .setEleValue(jsonMsg.getString("element")) + .setEleName("定位控件测试"); List elements = new ArrayList<>(); elements.add(elementsDTO); String stepType = jsonMsg.getString("eleType").equals("point") ? "tap" : "click";