Skip to content

Commit

Permalink
Remove whitespace replacement from Android runner
Browse files Browse the repository at this point in the history
  • Loading branch information
piotruela committed Dec 6, 2024
1 parent 990da8b commit bb9b4e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class PatrolJUnitRunner extends AndroidJUnitRunner {
public PatrolAppServiceClient patrolAppServiceClient;
private Map<String, Boolean> dartTestCaseSkipMap = new HashMap<>();

private String spaceReplacement = "__";

@Override
protected boolean shouldWaitForActivitiesToComplete() {
return false;
Expand Down Expand Up @@ -117,9 +115,8 @@ public Object[] listDartTests() {
List<DartGroupEntry> dartTestCases = ContractsExtensionsKt.listTestsFlat(dartTestGroup, "");
List<String> dartTestCaseNamesList = new ArrayList<>();
for (DartGroupEntry dartTestCase : dartTestCases) {
final String testName = sanitizeTestCaseName(dartTestCase.getName());
dartTestCaseSkipMap.put(testName, dartTestCase.getSkip());
dartTestCaseNamesList.add(testName);
dartTestCaseSkipMap.put(dartTestCase.getName(), dartTestCase.getSkip());
dartTestCaseNamesList.add(dartTestCase.getName());
}
Object[] dartTestCaseNames = dartTestCaseNamesList.toArray();
Logger.INSTANCE.i(TAG + "Got Dart tests: " + Arrays.toString(dartTestCaseNames));
Expand All @@ -145,7 +142,7 @@ public RunDartTestResponse runDartTest(String name) {

try {
Logger.INSTANCE.i(TAG + "Requested execution");
RunDartTestResponse response = patrolAppServiceClient.runDartTest(originalTestCaseName(name));
RunDartTestResponse response = patrolAppServiceClient.runDartTest(name);
if (response.getResult() == Contracts.RunDartTestResponseResult.failure) {
throw new AssertionError("Dart test failed: " + name + "\n" + response.getDetails());
}
Expand All @@ -156,19 +153,4 @@ public RunDartTestResponse runDartTest(String name) {
throw new RuntimeException(e);
}
}

/**
* We need to remove whitespaces from test case name in order to make in compatible with Orchestrator 1.5.0.
* New requirement can be observed (<a href="https://github.com/android/android-test/commit/8383d784e51dd67972f79f7738e19e7e99706d23">here</a>).
* */
private String sanitizeTestCaseName(String name) {
return name.replace(" ", spaceReplacement);
}

/**
* When calling test on dart side, we need to bring back original test case name.
* */
private String originalTestCaseName(String name) {
return name.replace(spaceReplacement, " ");
}
}
2 changes: 1 addition & 1 deletion packages/patrol/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ flutter {
}

dependencies {
androidTestUtil 'androidx.test:orchestrator:1.4.2'
androidTestUtil 'androidx.test:orchestrator:1.5.1'
}

0 comments on commit bb9b4e1

Please sign in to comment.