Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.microsoft.hydralab.agent;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
Expand All @@ -23,6 +24,7 @@
@EnableJpaRepositories(basePackages = {"com.microsoft.hydralab.common.repository","com.microsoft.hydralab.agent.repository"})
@EntityScan(basePackages = {"com.microsoft.hydralab.common.entity.agent", "com.microsoft.hydralab.common.entity.common"})
@PropertySource(value = {"classpath:version.properties"}, encoding = "utf-8")
@Slf4j
public class AgentApplication {

public static void main(String[] args) {
Expand All @@ -31,20 +33,19 @@ public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(AgentApplication.class)
.headless(headless)
.run(args);
System.out.printf("*************************\nDevice Agent Startup success in %s\n*************************\n",
System.currentTimeMillis() - time);
log.info("*************************\nDevice Agent Startup success in %s\n*************************\n {}", System.currentTimeMillis() - time);
}

private static boolean decideHeadlessFromArguments(String[] args) {
System.out.printf("main function param: args value > %s \n", Arrays.asList(args).toString());
log.info("main function param: args value > %s \n {}", Arrays.asList(args).toString());
boolean headless = false;
for (String arg : args) {
if (!arg.contains("spring.profiles.active=docker")) {
continue;
}
System.setProperty("java.awt.headless", "true");
headless = true;
System.out.println("We are in the Docker environment, we will switch to headless mode, and the Windows App UI testing may have restricted support.");
log.info("We are in the Docker environment, we will switch to headless mode, and the Windows App UI testing may have restricted support.");
break;
}
return headless;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public Result add(@CurrentSecurityContext SysUser requestor,
//Upload app file
appBlobFile = attachmentService.addAttachment(testFileSet.getId(), EntityFileRelation.EntityType.APP_FILE_SET, appBlobFile, tempAppFile, logger);
JSONObject appFileParser = appBlobFile.getFileParser();
testFileSet.setAppName(appFileParser.getString(ParserKey.AppName));
testFileSet.setPackageName(appFileParser.getString(ParserKey.PkgName));
testFileSet.setVersion(appFileParser.getString(ParserKey.Version));
testFileSet.setAppName(appFileParser.getString(ParserKey.APP_NAME));
testFileSet.setPackageName(appFileParser.getString(ParserKey.PKG_NAME));
testFileSet.setVersion(appFileParser.getString(ParserKey.VERSION));
testFileSet.getAttachments().add(appBlobFile);

//Save test app file to server if exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public interface LoadType {
}

public interface ParserKey {
String AppName = "appName";
String PkgName = "pkgName";
String Version = "version";
String MinSdkVersion = "minSdkVersion";
String TargetSdkVersion = "targetSdkVersion";
String APP_NAME = "appName";
String PKG_NAME = "pkgName";
String VERSION = "version";
String MIN_SDK_VERSION = "minSdkVersion";
String TARGET_SDK_VERSION = "targetSdkVersion";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ private static JSONObject analysisApkFile(File file) {
JSONObject res = new JSONObject();
try (ApkFile apkFile = new ApkFile(file)) {
ApkMeta apkMeta = apkFile.getApkMeta();
res.put(ParserKey.AppName, apkMeta.getName());
res.put(ParserKey.PkgName, apkMeta.getPackageName());
res.put(ParserKey.Version, apkMeta.getVersionName());
res.put(ParserKey.MinSdkVersion, apkMeta.getMinSdkVersion());
res.put(ParserKey.TargetSdkVersion, apkMeta.getTargetSdkVersion());
res.put(ParserKey.APP_NAME, apkMeta.getName());
res.put(ParserKey.PKG_NAME, apkMeta.getPackageName());
res.put(ParserKey.VERSION, apkMeta.getVersionName());
res.put(ParserKey.MIN_SDK_VERSION, apkMeta.getMinSdkVersion());
res.put(ParserKey.TARGET_SDK_VERSION, apkMeta.getTargetSdkVersion());
} catch (IOException e) {
e.printStackTrace();
} catch (BufferUnderflowException e) {
Expand Down Expand Up @@ -116,9 +116,9 @@ private static JSONObject analysisIpaFile(File ipa) {
file.delete();
file.getParentFile().delete();

res.put(ParserKey.AppName, name);
res.put(ParserKey.PkgName, pkgName);
res.put(ParserKey.Version, version);
res.put(ParserKey.APP_NAME, name);
res.put(ParserKey.PKG_NAME, pkgName);
res.put(ParserKey.VERSION, version);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import net.dongliu.apk.parser.ApkFile;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
Expand All @@ -23,7 +21,7 @@ public void analysisApkFile() throws IOException {
JSONObject res = PkgUtil.analysisFile(recordFile, EntityFileRelation.EntityType.APP_FILE_SET);

logger.info(res.toString(SerializerFeature.PrettyFormat));
Assertions.assertTrue("com.microsoft.hydralab.android.client".equals(res.getString(BlobFileInfo.ParserKey.PkgName)), "Analysis apk error!");
Assertions.assertTrue("com.microsoft.hydralab.android.client".equals(res.getString(BlobFileInfo.ParserKey.PKG_NAME)), "Analysis apk error!");

try (ApkFile apkFile = new ApkFile(recordFile)) {
List<String> usesPermissions = apkFile.getApkMeta().getUsesPermissions();
Expand All @@ -39,6 +37,6 @@ public void analysisIpaFile() {
JSONObject res = PkgUtil.analysisFile(recordFile, EntityFileRelation.EntityType.APP_FILE_SET);

logger.info(res.toString(SerializerFeature.PrettyFormat));
Assertions.assertTrue("com.microsoft.es.uitestsample".equals(res.getString(BlobFileInfo.ParserKey.PkgName)), "Analysis ipa error!");
Assertions.assertTrue("com.microsoft.es.uitestsample".equals(res.getString(BlobFileInfo.ParserKey.PKG_NAME)), "Analysis ipa error!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
package com.microsoft.hydralab.t2c.runner;

import com.microsoft.hydralab.t2c.runner.elements.BaseElementInfo;

import javax.annotation.Nullable;
import java.util.Map;
public class ActionInfo {
private Integer id;
private BaseElementInfo testElement;

private String actionType;
import javax.annotation.Nullable;

private String driverId;
public class ActionInfo {
private final Integer id;
private final BaseElementInfo testElement;
private final String actionType;
private final String driverId;
private Map<String, Object> arguments;
private boolean isOptional;

private final boolean isOptional;

public ActionInfo(Integer id, @Nullable BaseElementInfo testElement, String actionType, Map<String, Object> arguments,
String driverId, boolean isOptional) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package com.microsoft.hydralab.t2c.runner;

public class DriverInfo {
private String id;
private String platform;
private String launcherApp;
private String initURL;
private final String id;
private final String platform;
private final String launcherApp;
private final String initURL;

public DriverInfo(String id, String platform, String launcherApp, String initURL){
this.id = id;
Expand Down