Skip to content

Commit

Permalink
doc: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Apr 27, 2023
1 parent 90a0ea9 commit 999baa6
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.cloud.sonic.driver.android.service.impl.AndroidElementImpl;
import org.cloud.sonic.driver.android.service.impl.UiaClientImpl;
import org.cloud.sonic.driver.common.enums.PasteboardType;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.common.models.WindowSize;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum AndroidSelector {
UIAUTOMATOR("-android uiautomator");

private final String selector;

AndroidSelector(String selector) {
this.selector = selector;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.cloud.sonic.driver.common.models.BaseElement;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.common.models.ElementRect;

/**
* @author Eason
Expand All @@ -30,7 +29,7 @@ public interface AndroidElement extends BaseElement {

void sendKeys(String text) throws SonicRespException;

void sendKeys(String text,boolean isCover) throws SonicRespException;
void sendKeys(String text, boolean isCover) throws SonicRespException;

void clear() throws SonicRespException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package org.cloud.sonic.driver.android.service;

import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.common.models.WindowSize;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.cloud.sonic.driver.android.service.AndroidElement;
import org.cloud.sonic.driver.android.service.UiaClient;
import org.cloud.sonic.driver.common.models.BaseResp;
import org.cloud.sonic.driver.common.models.ElementRect;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.common.models.ElementRect;

import java.util.Base64;

Expand Down Expand Up @@ -66,7 +66,7 @@ public void sendKeys(String text, boolean isCover) throws SonicRespException {
data.put("replace", isCover);
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/value")
+ uiaClient.getSessionId() + "/element/" + id + "/value")
.body(data.toJSONString()), 60000);
if (b.getErr() == null) {
logger.info("send key to %s.", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.cloud.sonic.driver.android.service.UiaClient;
import org.cloud.sonic.driver.common.models.BaseResp;
import org.cloud.sonic.driver.common.models.SessionInfo;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;

import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum PasteboardType {
URL("url");

private final String type;

PasteboardType(String pasteboardType) {
this.type = pasteboardType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

public interface BaseElement {
ElementRect getRect() throws SonicRespException;

String getAttribute(String name) throws SonicRespException;

// the xpath or id or csspath...
String getUniquelyIdentifies() throws SonicRespException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public BaseResp getResp(HttpRequest httpRequest, int timeout) throws SonicRespEx

public BaseResp initResp(String response) {
if (response.contains("traceback") || response.contains("stacktrace")) {
return initErrorMsg(response.replace("stacktrace","traceback"));
return initErrorMsg(response.replace("stacktrace", "traceback"));
} else {
return JSON.parseObject(response, BaseResp.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.cloud.sonic.driver.common.tool;

public class SonicRespException extends Exception{
public class SonicRespException extends Exception {
public SonicRespException(String message) {
super(message);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/cloud/sonic/driver/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.driver.common.enums.PasteboardType;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.ios.enums.*;
import org.cloud.sonic.driver.ios.models.*;
import org.cloud.sonic.driver.ios.service.WdaClient;
import org.cloud.sonic.driver.ios.models.TouchActions;
import org.cloud.sonic.driver.ios.service.IOSElement;
import org.cloud.sonic.driver.ios.service.WdaClient;
import org.cloud.sonic.driver.ios.service.impl.IOSElementImpl;
import org.cloud.sonic.driver.ios.service.impl.WdaClientImpl;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;

import java.util.List;

Expand Down Expand Up @@ -416,7 +416,7 @@ public IOSElement findElement(IOSSelector iosSelector, String value) throws Soni
* @throws SonicRespException
*/
public IOSElement findElement(String wdaElementID) throws SonicRespException {
return new IOSElementImpl(wdaElementID,wdaClient);
return new IOSElementImpl(wdaElementID, wdaClient);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum ActionType {
RELEASE("release");

private final String type;

ActionType(String type) {
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum IOSSelector {
PARTIAL_LINK_TEXT("partial link text");

private final String selector;

IOSSelector(String selector) {
this.selector = selector;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum SystemButton {
VOLUME_DOWN("volumeDown");

private final String button;

SystemButton(String button) {
this.button = button;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public enum XCUIElementType {
MENU_BAR_ITEM("XCUIElementTypeMenuBarItem"),

INCREMENT_ARROW("XCUIElementTypeIncrementArrow"),
DECREMENT_ARROW("XCUIElementTypeDecrementArrow"),;
DECREMENT_ARROW("XCUIElementTypeDecrementArrow"),
;

private final String type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class Options {
private Integer ms;
}

public TouchAction(ActionType actionType){
public TouchAction(ActionType actionType) {
this.action = actionType.getType();
this.options = new Options();
}
}

public TouchActions(){
public TouchActions() {
actions = new ArrayList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.cloud.sonic.driver.ios.service;

import org.cloud.sonic.driver.common.models.BaseElement;
import org.cloud.sonic.driver.common.models.ElementRect;
import org.cloud.sonic.driver.common.tool.SonicRespException;

/**
Expand All @@ -30,7 +29,7 @@ public interface IOSElement extends BaseElement {

void sendKeys(String text) throws SonicRespException;

void sendKeys(String text,int frequency) throws SonicRespException;
void sendKeys(String text, int frequency) throws SonicRespException;

void clear() throws SonicRespException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package org.cloud.sonic.driver.ios.service;

import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.ios.models.TouchActions;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.ios.models.TouchActions;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import org.cloud.sonic.driver.common.models.BaseResp;
import org.cloud.sonic.driver.common.models.ElementRect;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.common.models.ElementRect;
import org.cloud.sonic.driver.ios.service.WdaClient;
import org.cloud.sonic.driver.ios.service.IOSElement;
import org.cloud.sonic.driver.ios.service.WdaClient;

import java.util.Base64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.driver.common.models.BaseResp;
import org.cloud.sonic.driver.common.models.SessionInfo;
import org.cloud.sonic.driver.ios.service.IOSElement;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.ios.models.TouchActions;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.ios.service.IOSElement;
import org.cloud.sonic.driver.ios.service.WdaClient;

import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public PocoElement(RootElement root, Element currentNodeXmlElement) {

public Payload getPayload() {

if (rootElement.getVersion()!=getVersion()){
if (rootElement.getVersion() != getVersion()) {
Element xmlPocoNode = rootElement.getXmlElement().select(currentNodeSelector).first();
if (xmlPocoNode == null) {
return null;
Expand All @@ -126,7 +126,7 @@ public Payload getPayload() {

public List<PocoElement> getChildren() {

if (rootElement.getVersion()!=getVersion()){
if (rootElement.getVersion() != getVersion()) {
Element xmlPocoNode = rootElement.getXmlElement().select(currentNodeSelector).first();

if (xmlPocoNode == null) {
Expand All @@ -139,7 +139,7 @@ public List<PocoElement> getChildren() {

Elements childList = xmlPocoNode.children();

for (Element child:childList) {
for (Element child : childList) {
children.add(new PocoElement(rootElement, child));
}

Expand All @@ -158,7 +158,7 @@ public void parseXmlNode(Element xmlNode) {
payload.texture = xmlNode.attr("texture");

String _instanceId = xmlNode.attr("_instanceId");
payload._instanceId = _instanceId.isEmpty()? 0 : Integer.parseInt(_instanceId);
payload._instanceId = _instanceId.isEmpty() ? 0 : Integer.parseInt(_instanceId);

String _ilayer = xmlNode.attr("_ilayer");
payload._ilayer = _ilayer.isEmpty() ? 0 : Integer.parseInt(_ilayer);
Expand Down Expand Up @@ -195,20 +195,20 @@ private List<Float> parseFloatAttrList(String floatAttrStr) {
return result;
}

public Boolean currentTheNodeExists(){
return rootElement.getXmlElement().select(currentNodeSelector).first()!=null;
public Boolean currentTheNodeExists() {
return rootElement.getXmlElement().select(currentNodeSelector).first() != null;
}

public PocoElement getParentNode(){
public PocoElement getParentNode() {
Element xmlPocoNode = rootElement.getXmlElement().select(currentNodeSelector).first();

if (xmlPocoNode == null) {
return null;
}
Element parentNode = xmlPocoNode.parent();
if (parentNode==null){
if (parentNode == null) {
return null;
}
return new PocoElement(rootElement,parentNode);
return new PocoElement(rootElement, parentNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public class RootElement {
private Element XmlElement;
private long version;

public RootElement(){}
public RootElement() {
}

public RootElement(Element XmlElement){
public RootElement(Element XmlElement) {
this.XmlElement = XmlElement;
}

public RootElement(Element XmlElement, long version){
public RootElement(Element XmlElement, long version) {
this(XmlElement);
this.version = version;
}
Expand All @@ -50,8 +51,8 @@ public void setVersion(long version) {
this.version = version;
}

public synchronized void updateVersion(Element rootXmlElement){
public synchronized void updateVersion(Element rootXmlElement) {
this.XmlElement = rootXmlElement;
this.version+=1;
this.version += 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.cloud.sonic.driver.poco.service;

import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.Logger;
import org.cloud.sonic.driver.common.tool.SonicRespException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.alibaba.fastjson.JSONObject;

public class PocoTool {
public static boolean checkPocoRpcResultID(String pocoRpcResult,String sendID){
public static boolean checkPocoRpcResultID(String pocoRpcResult, String sendID) {
JSONObject object = JSONObject.parseObject(pocoRpcResult);
return sendID.equals(object.getString("id"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.cloud.sonic.driver.common.tool.RespHandler;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.ios.enums.IOSSelector;
import org.cloud.sonic.driver.ios.service.WdaClient;
import org.cloud.sonic.driver.ios.service.impl.WdaClientImpl;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -56,7 +54,7 @@ public void testGetWindowSize() {
public void testSendKeys() {
Boolean hasThrow = false;
try {
uiaClient.sendKeys("test",false);
uiaClient.sendKeys("test", false);
} catch (Throwable e) {
hasThrow = true;
Assert.assertEquals(SonicRespException.class, e.getClass());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/cloud/sonic/driver/ios/IOSDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.cloud.sonic.driver.common.enums.PasteboardType;
import org.cloud.sonic.driver.common.models.ElementRect;
import org.cloud.sonic.driver.common.models.WindowSize;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.cloud.sonic.driver.ios.enums.*;
import org.cloud.sonic.driver.ios.models.*;
import org.cloud.sonic.driver.ios.models.TouchActions;
import org.cloud.sonic.driver.ios.service.IOSElement;
import org.cloud.sonic.driver.common.tool.SonicRespException;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down
Loading

0 comments on commit 999baa6

Please sign in to comment.