Skip to content

Commit

Permalink
Revert "[e2e] Replaces the check for ActivityTestRule (flutter#2633)" (
Browse files Browse the repository at this point in the history
…flutter#2657)

This reverts commit a811e63.
  • Loading branch information
Chris Yang authored and jorgefspereira committed Oct 10, 2020
1 parent f53a247 commit d69312e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 40 deletions.
4 changes: 0 additions & 4 deletions packages/e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## 0.4.1

* Adds support for Android E2E tests that utilize other @Rule's, like GrantPermissionRule.

## 0.4.0

* **Breaking change** Driver request_data call's response has changed to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@

package dev.flutter.plugins.e2e;

import android.app.Activity;
import android.util.Log;
import androidx.test.rule.ActivityTestRule;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;

public class FlutterTestRunner extends Runner {

private static final String TAG = "FlutterTestRunner";

final Class testClass;
TestRule rule = null;
ActivityTestRule<Activity> rule = null;

public FlutterTestRunner(Class<?> testClass) {
super();
Expand All @@ -33,10 +32,7 @@ public FlutterTestRunner(Class<?> testClass) {
if (field.isAnnotationPresent(Rule.class)) {
try {
Object instance = testClass.newInstance();
if (field.get(instance) instanceof ActivityTestRule) {
rule = (TestRule) field.get(instance);
break;
}
rule = (ActivityTestRule<Activity>) field.get(instance);
} catch (InstantiationException | IllegalAccessException e) {
// This might occur if the developer did not make the rule public.
// We could call field.setAccessible(true) but it seems better to throw.
Expand All @@ -57,9 +53,7 @@ public void run(RunNotifier notifier) {
throw new RuntimeException("Unable to run tests due to missing activity rule");
}
try {
if (rule instanceof ActivityTestRule) {
((ActivityTestRule) rule).launchActivity(null);
}
rule.launchActivity(null);
} catch (RuntimeException e) {
Log.v(TAG, "launchActivity failed, possibly because the activity was already running. " + e);
Log.v(
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/e2e/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: e2e
description: Runs tests that use the flutter_test API as integration tests.
version: 0.4.1
version: 0.4.0
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e

environment:
Expand Down

0 comments on commit d69312e

Please sign in to comment.