Skip to content

Commit d4401d9

Browse files
authored
Merge pull request #17 from srautiai/master
Added support for the testdroid api release 2.38
2 parents 9b19bdd + 78bacfe commit d4401d9

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Below is listed all the supported configurations parameters:
5050

5151
cloudUrl = 'https://cloud.testdroid.com' //optional - default live
5252
projectName "Project 1" //optional - default: create a new project
53-
mode "FULL_RUN" //FULL_RUN / APP_CRAWLER / UI_AUTOMATOR
53+
mode "FULL_RUN" //FULL_RUN / APP_CRAWLER / UI_AUTOMATOR - deprecated, mode is set based on project type
5454
testRunName "Custom test run name" //optional - default: build variant name
5555

5656
deviceLanguageCode "en-US" //optional - locale <ISO 63>_<ISO 3166> default: en-US

build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ dependencies {
1717
gradleApi gradleApi()
1818
groovy localGroovy()
1919

20-
compile 'com.android.tools.build:builder-test-api:1.1.0'
21-
compile 'com.testdroid:testdroid-api:2.9'
20+
compile 'com.android.tools.build:builder-test-api:2.3.0'
21+
compile 'com.testdroid:testdroid-api:2.38'
2222
testCompile 'junit:junit:3.8.1'
2323
testCompile 'com.android.tools.build:gradle:1.1.0'
2424

2525
}
2626

2727
group = 'com.testdroid'
2828
archivesBaseName = 'gradle'
29-
version = '1.4.0'
30-
sourceCompatibility = 1.5
29+
version = '1.5.0'
3130

3231
// custom tasks for creating source/javadoc jars
3332
task sourcesJar(type: Jar, dependsOn:classes) {

src/main/groovy/com/testdroid/TestDroidExtension.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TestDroidExtension {
2727
String apiKey
2828
String projectName
2929
String cloudUrl
30+
@Deprecated
3031
String mode
3132
String deviceGroup
3233
String deviceLanguageCode

src/main/groovy/com/testdroid/TestDroidServer.java

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ public String getName() {
4747
return "testdroid";
4848
}
4949

50-
private APIProject searchProject(String projectName, APIProject.Type type, APIListResource<APIProject> projectList) throws APIException {
50+
private APIProject searchProject(String projectName, APIListResource<APIProject> projectList) throws APIException {
5151
if (projectList == null || projectList.getTotal() == 0 || projectList.getEntity() == null ||
5252
projectList.getEntity().getData() == null) {
53-
5453
return null;
5554
}
5655

@@ -118,14 +117,13 @@ public void uploadApks(@NonNull String variantName, @NonNull File testApk, @Null
118117
try {
119118
if (extension.getProjectName() == null) {
120119
logger.warn("TESTDROID: Project name is not set - creating a new one");
121-
APIProject.Type type = getProjectType(extension.getMode());
122-
project = user.createProject(type);
120+
project = user.createProject(APIProject.Type.ANDROID);
123121
logger.info("TESTDROID: Created project:" + project.getName());
124122
} else {
125123
APIListResource<APIProject> projectList;
126124
projectList = user.getProjectsResource();
127125

128-
project = searchProject(extension.getProjectName(), getProjectType(extension.getMode()), projectList);
126+
project = searchProject(extension.getProjectName(), projectList);
129127
if (project == null) {
130128
logger.warn("TESTDROID: Can't find project " + extension.getProjectName());
131129
return;
@@ -159,7 +157,7 @@ && new File(extension.getFullRunConfig().getInstrumentationAPKPath()).exists())
159157
instrumentationAPK = new File(extension.getFullRunConfig().getInstrumentationAPKPath());
160158
logger.info("TESTDROID: Using custom path for instrumentation APK: %s", extension.getFullRunConfig().getInstrumentationAPKPath());
161159
}
162-
uploadBinaries(project, getProjectType(extension.getMode()), instrumentationAPK, testedApk);
160+
uploadBinaries(project, instrumentationAPK, testedApk);
163161

164162
project.run(extension.getTestRunName() == null ? variantName : extension.getTestRunName());
165163

@@ -211,51 +209,40 @@ private HttpHost buildProxyHost() {
211209
return new HttpHost(proxyHost, port);
212210
}
213211

214-
private void uploadBinaries(APIProject project, APIProject.Type projectType, File testApk, File testedApk) throws APIException {
212+
private void uploadBinaries(APIProject project, File testApk, File testedApk) throws APIException {
215213

216214
if (project.getType().equals(APIProject.Type.UIAUTOMATOR)) {
217215

218-
UIAutomatorFiles uiAutomatorFiles = project.getFiles(UIAutomatorFiles.class);
219216
if (extension.getUiAutomatorTestConfig() == null || extension.getUiAutomatorTestConfig().getUiAutomatorJarPath() == null) {
220217
throw new APIException("TESTDROID: Configure uiautomator settings");
221218
}
222219
File jarFile = new File(extension.getUiAutomatorTestConfig().getUiAutomatorJarPath());
223220
if (!jarFile.exists()) {
224221
throw new APIException("TESTDROID: Invalid uiAutomator jar file:" + jarFile.getAbsolutePath());
225222
}
226-
uiAutomatorFiles.uploadTest(new File(extension.getUiAutomatorTestConfig().getUiAutomatorJarPath()));
223+
project.uploadTest(new File(extension.getUiAutomatorTestConfig().getUiAutomatorJarPath()), "application/octet-stream");
227224
logger.info("TESTDROID: uiautomator file uploaded");
228-
uiAutomatorFiles.uploadApp(testedApk);
225+
project.uploadApplication(testedApk, "application/octet-stream");
229226
logger.info("TESTDROID: Android application uploaded");
230227
} else {
231-
AndroidFiles androidFiles = project.getFiles(AndroidFiles.class);
232228

233229
if (testedApk != null && testedApk.exists()) {
234-
androidFiles.uploadApp(testedApk);
230+
project.uploadApplication(testedApk, "application/octet-stream");
235231
logger.info("TESTDROID: Android application uploaded");
236232
} else {
237233
logger.warn("TESTDROID: Target application has not been added - uploading only test apk ");
238234
}
239235

240-
if (testApk != null && APIProject.Type.ANDROID == projectType) {
241-
androidFiles.uploadTest(testApk);
236+
if (testApk != null && APIProject.Type.ANDROID == project.getType()) {
237+
project.uploadTest(testApk, "application/octet-stream");
242238
logger.info("TESTDROID: Android test uploaded");
243239
return;
244240
}
245241
}
246242

247243
}
248244

249-
private APIProject.Type getProjectType(String testrunMode) throws APIException {
250-
if (APITestRunConfig.Mode.FULL_RUN.name().equals(testrunMode) || APITestRunConfig.Mode.APP_CRAWLER.name().equals(testrunMode)) {
251-
return APIProject.Type.ANDROID;
252-
} else if (APITestRunConfig.Mode.UIAUTOMATOR.name().equals(testrunMode)) {
253-
return APIProject.Type.UIAUTOMATOR;
254-
} else {
255-
throw new APIException("TESTDROID: Not supported test run mode:" + testrunMode + " Enum" + APITestRunConfig.Mode.FULL_RUN.name());
256-
}
257245

258-
}
259246

260247
private APITestRunConfig updateAPITestRunConfigValues(APIProject project, TestDroidExtension extension, Long deviceGroupId) throws APIException {
261248

@@ -264,8 +251,10 @@ private APITestRunConfig updateAPITestRunConfigValues(APIProject project, TestDr
264251
config.setHookURL(extension.getHookUrl());
265252
config.setDeviceLanguageCode(extension.getDeviceLanguageCode());
266253
config.setScheduler(extension.getScheduler() != null ? APITestRunConfig.Scheduler.valueOf(extension.getScheduler()) : null);
254+
if (extension.getMode() != null) {
255+
logger.warn("TESTDROID: mode variable is not used anymore");
256+
}
267257

268-
config.setMode(APITestRunConfig.Mode.valueOf(extension.getMode()));
269258
//App crawler settings
270259
config.setApplicationUsername(extension.getAppCrawlerConfig().getApplicationUserName());
271260
config.setApplicationPassword(extension.getAppCrawlerConfig().getApplicationPassword());
@@ -307,9 +296,8 @@ public boolean isConfigured() {
307296
if (extension.getProjectName() == null) {
308297
logger.warn("TESTDROID: project name has not been set, creating a new project");
309298
}
310-
if (extension.getMode() == null || APITestRunConfig.Mode.valueOf(extension.getMode()) == null) {
311-
logger.warn("TESTDROID: Test run mode has not been set(default: FULL_RUN)");
312-
extension.setMode(APITestRunConfig.Mode.FULL_RUN.name());
299+
if (extension.getMode() != null) {
300+
logger.warn("TESTDROID: mode variable is not used anymore");
313301
}
314302
if (extension.getDeviceGroup() == null) {
315303
logger.warn("TESTDROID: Device group has not been set");

0 commit comments

Comments
 (0)