Skip to content

Commit a3847cf

Browse files
Chris YangEgor
authored andcommitted
Revert "[e2e] Replaces the check for ActivityTestRule (flutter#2633)" (flutter#2657)
This reverts commit a811e63.
1 parent 71a9d55 commit a3847cf

File tree

4 files changed

+5
-40
lines changed

4 files changed

+5
-40
lines changed

packages/e2e/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
## 0.4.1
2-
3-
* Adds support for Android E2E tests that utilize other @Rule's, like GrantPermissionRule.
4-
51
## 0.4.0
62

73
* **Breaking change** Driver request_data call's response has changed to

packages/e2e/android/src/main/java/dev/flutter/plugins/e2e/FlutterTestRunner.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44

55
package dev.flutter.plugins.e2e;
66

7+
import android.app.Activity;
78
import android.util.Log;
89
import androidx.test.rule.ActivityTestRule;
910
import java.lang.reflect.Field;
1011
import java.util.Map;
1112
import java.util.concurrent.ExecutionException;
1213
import org.junit.Rule;
13-
import org.junit.rules.TestRule;
1414
import org.junit.runner.Description;
1515
import org.junit.runner.Runner;
1616
import org.junit.runner.notification.Failure;
1717
import org.junit.runner.notification.RunNotifier;
1818

1919
public class FlutterTestRunner extends Runner {
20-
2120
private static final String TAG = "FlutterTestRunner";
2221

2322
final Class testClass;
24-
TestRule rule = null;
23+
ActivityTestRule<Activity> rule = null;
2524

2625
public FlutterTestRunner(Class<?> testClass) {
2726
super();
@@ -33,10 +32,7 @@ public FlutterTestRunner(Class<?> testClass) {
3332
if (field.isAnnotationPresent(Rule.class)) {
3433
try {
3534
Object instance = testClass.newInstance();
36-
if (field.get(instance) instanceof ActivityTestRule) {
37-
rule = (TestRule) field.get(instance);
38-
break;
39-
}
35+
rule = (ActivityTestRule<Activity>) field.get(instance);
4036
} catch (InstantiationException | IllegalAccessException e) {
4137
// This might occur if the developer did not make the rule public.
4238
// We could call field.setAccessible(true) but it seems better to throw.
@@ -57,9 +53,7 @@ public void run(RunNotifier notifier) {
5753
throw new RuntimeException("Unable to run tests due to missing activity rule");
5854
}
5955
try {
60-
if (rule instanceof ActivityTestRule) {
61-
((ActivityTestRule) rule).launchActivity(null);
62-
}
56+
rule.launchActivity(null);
6357
} catch (RuntimeException e) {
6458
Log.v(TAG, "launchActivity failed, possibly because the activity was already running. " + e);
6559
Log.v(

packages/e2e/example/android/app/src/androidTest/java/com/example/e2e_example/MainActivityWithPermissionTest.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/e2e/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: e2e
22
description: Runs tests that use the flutter_test API as integration tests.
3-
version: 0.4.1
3+
version: 0.4.0
44
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e
55

66
environment:

0 commit comments

Comments
 (0)