Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
7 changes: 7 additions & 0 deletions packages/e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.2.1

* Support the v2 Android embedder.
* Print a warning if the plugin is not registered.
* Updated method channel name.
* Set a Flutter minimum SDK version.

## 0.2.0+1

* Updated README.
Expand Down
25 changes: 25 additions & 0 deletions packages/e2e/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,28 @@ android {
api 'androidx.test.espresso:espresso-core:3.2.0'
}
}

// TODO(amirh): Remove this hack once androidx.lifecycle is included on stable. https://github.com/flutter/flutter/issues/42348
afterEvaluate {
def containsEmbeddingDependencies = false
for (def configuration : configurations.all) {
for (def dependency : configuration.dependencies) {
if (dependency.group == 'io.flutter' &&
dependency.name.startsWith('flutter_embedding') &&
dependency.isTransitive())
{
containsEmbeddingDependencies = true
break
}
}
}
if (!containsEmbeddingDependencies) {
android {
dependencies {
def lifecycle_version = "2.1.0"
api "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
api "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

package dev.flutter.plugins.e2e;

import android.content.Context;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
Expand All @@ -13,16 +16,34 @@
import java.util.concurrent.CompletableFuture;

/** E2EPlugin */
public class E2EPlugin implements MethodCallHandler {
public class E2EPlugin implements MethodCallHandler, FlutterPlugin {
private MethodChannel methodChannel;

public static CompletableFuture<Map<String, String>> testResults = new CompletableFuture<>();

private static final String CHANNEL = "plugins.flutter.dev/e2e";
private static final String CHANNEL = "plugins.flutter.io/e2e";

/** Plugin registration. */
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL);
channel.setMethodCallHandler(new E2EPlugin());
final E2EPlugin instance = new E2EPlugin();
instance.onAttachedToEngine(registrar.context(), registrar.messenger());
}

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
onAttachedToEngine(
binding.getApplicationContext(), binding.getFlutterEngine().getDartExecutor());
}

private void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger) {
methodChannel = new MethodChannel(messenger, "plugins.flutter.io/e2e");
methodChannel.setMethodCallHandler(this);
}

@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {
methodChannel.setMethodCallHandler(null);
methodChannel = null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.e2e_example;

import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.e2e.FlutterRunner;
import org.junit.Rule;
import org.junit.runner.RunWith;

@RunWith(FlutterRunner.class)
public class EmbedderV1ActivityTest {
@Rule
public ActivityTestRule<EmbedderV1Activity> rule =
new ActivityTestRule<>(EmbedderV1Activity.class);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.e2e_example;

import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.instrumentationadapter.FlutterRunner;
import dev.flutter.plugins.e2e.FlutterRunner;
import org.junit.Rule;
import org.junit.runner.RunWith;

Expand Down
14 changes: 6 additions & 8 deletions packages/e2e/example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
android:name="io.flutter.app.FlutterApplication"
android:label="e2e_example"
android:icon="@mipmap/ic_launcher">
<activity android:name=".EmbedderV1Activity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.example.e2e_example;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class EmbedderV1Activity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.example.e2e_example;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import dev.flutter.plugins.e2e.E2EPlugin;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
public void configureFlutterEngine(FlutterEngine flutterEngine) {
flutterEngine.getPlugins().add(new E2EPlugin());
}
}
1 change: 0 additions & 1 deletion packages/e2e/example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ org.gradle.jvmargs=-Xmx1536M

android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
1 change: 1 addition & 0 deletions packages/e2e/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ publish_to: 'none'

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.6.7 <2.0.0"

dependencies:
flutter:
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/lib/e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
await _channel.invokeMethod<void>(
'allTestsFinished', <String, dynamic>{'results': _results});
} on MissingPluginException {
// Tests were run on the host rather than a device.
print('Warning: E2E test plugin was not detected.');
}
if (!_allTestsPassed.isCompleted) _allTestsPassed.complete(true);
});
Expand All @@ -34,8 +34,7 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
return WidgetsBinding.instance;
}

static const MethodChannel _channel =
MethodChannel('plugins.flutter.dev/e2e');
static const MethodChannel _channel = MethodChannel('plugins.flutter.io/e2e');

static Map<String, String> _results = <String, String>{};

Expand Down
3 changes: 2 additions & 1 deletion packages/e2e/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: e2e
description: Runs tests that use the flutter_test API as integration tests.
version: 0.2.0+1
version: 0.2.1
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.6.7 <2.0.0"

dependencies:
flutter:
Expand Down