forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[package_info] Support the v2 Android embedder (with e2e tests) (flut…
…ter#2160) * Migrate the package_info plugin to use the new embedder. * Upgraded to AndroidX. * Added a unit test. * Added Firebase Test Lab compatible e2e testing (including changes to Dockerfile and .cirrus.yml)
- Loading branch information
1 parent
3222a50
commit aa9fcae
Showing
20 changed files
with
271 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.enableJetifier=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
android.enableJetifier=true | ||
android.useAndroidX=true | ||
android.useAndroidX=true | ||
android.enableR8=true |
17 changes: 17 additions & 0 deletions
17
...pp/src/androidTest/java/io/flutter/plugins/packageinfoexample/EmbedderV1ActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 io.flutter.plugins.packageinfoexample; | ||
|
||
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); | ||
} |
15 changes: 15 additions & 0 deletions
15
...roid/app/src/androidTest/java/io/flutter/plugins/packageinfoexample/MainActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 io.flutter.plugins.packageinfoexample; | ||
|
||
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 MainActivityTest { | ||
@Rule public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...e/android/app/src/main/java/io/flutter/plugins/packageinfoexample/EmbedderV1Activity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2017 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 io.flutter.plugins.packageinfoexample; | ||
|
||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.enableJetifier=true | ||
android.enableR8=true | ||
android.useAndroidX=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ dependencies: | |
sdk: flutter | ||
package_info: | ||
path: ../ | ||
e2e: "^0.2.1" | ||
|
||
dev_dependencies: | ||
flutter_driver: | ||
|
31 changes: 0 additions & 31 deletions
31
packages/package_info/example/test_driver/package_info.dart
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/package_info/example/test_driver/package_info_e2e.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:e2e/e2e.dart'; | ||
import 'package:package_info/package_info.dart'; | ||
import 'package:package_info_example/main.dart'; | ||
|
||
void main() { | ||
E2EWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('fromPlatform', (WidgetTester tester) async { | ||
final PackageInfo info = await PackageInfo.fromPlatform(); | ||
// These tests are based on the example app. The tests should be updated if any related info changes. | ||
if (Platform.isAndroid) { | ||
expect(info.appName, 'package_info_example'); | ||
expect(info.buildNumber, '1'); | ||
expect(info.packageName, 'io.flutter.plugins.packageinfoexample'); | ||
expect(info.version, '1.0'); | ||
} else if (Platform.isIOS) { | ||
expect(info.appName, 'Package Info Example'); | ||
expect(info.buildNumber, '1'); | ||
expect(info.packageName, 'io.flutter.plugins.packageInfoExample'); | ||
expect(info.version, '1.0'); | ||
} else { | ||
throw (UnsupportedError('platform not supported')); | ||
} | ||
}); | ||
|
||
testWidgets('example', (WidgetTester tester) async { | ||
await tester.pumpWidget(MyApp()); | ||
await tester.pumpAndSettle(); | ||
if (Platform.isAndroid) { | ||
expect(find.text('package_info_example'), findsOneWidget); | ||
expect(find.text('1'), findsOneWidget); | ||
expect( | ||
find.text('io.flutter.plugins.packageinfoexample'), findsOneWidget); | ||
expect(find.text('1.0'), findsOneWidget); | ||
} else if (Platform.isIOS) { | ||
expect(find.text('Package Info Example'), findsOneWidget); | ||
expect(find.text('1'), findsOneWidget); | ||
expect( | ||
find.text('io.flutter.plugins.packageInfoExample'), findsOneWidget); | ||
expect(find.text('1.0'), findsOneWidget); | ||
} else { | ||
throw (UnsupportedError('platform not supported')); | ||
} | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/package_info/example/test_driver/package_info_e2e_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:flutter_driver/flutter_driver.dart'; | ||
|
||
Future<void> main() async { | ||
final FlutterDriver driver = await FlutterDriver.connect(); | ||
final String result = | ||
await driver.requestData(null, timeout: const Duration(minutes: 1)); | ||
driver.close(); | ||
exit(result == 'pass' ? 0 : 1); | ||
} |
10 changes: 0 additions & 10 deletions
10
packages/package_info/example/test_driver/package_info_test.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.