Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 97fa266

Browse files
Adds test harnesses for integration tests on Android (#4200)
1 parent c8b1d96 commit 97fa266

File tree

27 files changed

+262
-17
lines changed

27 files changed

+262
-17
lines changed

packages/google_maps_flutter/google_maps_flutter/example/android/app/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ android {
3535
applicationId "io.flutter.plugins.googlemapsexample"
3636
minSdkVersion 20
3737
targetSdkVersion 28
38+
multiDexEnabled true
3839
versionCode flutterVersionCode.toInteger()
3940
versionName flutterVersionName
4041
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -60,11 +61,9 @@ android {
6061

6162
dependencies {
6263
testImplementation 'junit:junit:4.12'
63-
androidTestImplementation 'androidx.test:runner:1.1.1'
64-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
65-
testImplementation 'androidx.test:core:1.2.0'
66-
testImplementation "org.robolectric:robolectric:4.3.1"
67-
testImplementation 'org.mockito:mockito-core:3.2.4'
64+
androidTestImplementation 'androidx.test:runner:1.2.0'
65+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
66+
api 'androidx.test:core:1.2.0'
6867
testImplementation 'com.google.android.gms:play-services-maps:17.0.0'
6968
}
7069
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.googlemapsexample;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
import androidx.test.core.app.ActivityScenario;
10+
import io.flutter.plugins.googlemaps.GoogleMapsPlugin;
11+
import org.junit.Test;
12+
13+
public class GoogleMapsTest {
14+
@Test
15+
public void googleMapsPluginIsAdded() {
16+
final ActivityScenario<GoogleMapsTestActivity> scenario =
17+
ActivityScenario.launch(GoogleMapsTestActivity.class);
18+
scenario.onActivity(
19+
activity -> {
20+
assertTrue(activity.engine.getPlugins().has(GoogleMapsPlugin.class));
21+
});
22+
}
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.googlemapsexample">
3+
<!-- Flutter needs internet permission to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<application android:usesCleartextTraffic="true">
8+
<activity
9+
android:name=".GoogleMapsTestActivity"
10+
android:launchMode="singleTop"
11+
android:theme="@style/LaunchTheme"
12+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
13+
android:hardwareAccelerated="true"
14+
android:windowSoftInputMode="adjustResize">
15+
</activity>
16+
</application>
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.googlemapsexample;
6+
7+
import androidx.annotation.NonNull;
8+
import io.flutter.embedding.android.FlutterActivity;
9+
import io.flutter.embedding.engine.FlutterEngine;
10+
11+
// Makes the FlutterEngine accessible for testing.
12+
public class GoogleMapsTestActivity extends FlutterActivity {
13+
public FlutterEngine engine;
14+
15+
@Override
16+
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
17+
super.configureFlutterEngine(flutterEngine);
18+
engine = flutterEngine;
19+
}
20+
}

packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
flutter_plugin_android_lifecycle: ^2.0.1
2222

2323
dev_dependencies:
24+
espresso: ^0.1.0+2
2425
flutter_driver:
2526
sdk: flutter
2627
integration_test:

packages/google_sign_in/google_sign_in/example/android/app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ android {
3535
applicationId "io.flutter.plugins.googlesigninexample"
3636
minSdkVersion 16
3737
targetSdkVersion 28
38+
multiDexEnabled true
3839
versionCode flutterVersionCode.toInteger()
3940
versionName flutterVersionName
4041
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -60,5 +61,7 @@ flutter {
6061
dependencies {
6162
implementation 'com.google.android.gms:play-services-auth:16.0.1'
6263
testImplementation'junit:junit:4.12'
63-
testImplementation 'org.mockito:mockito-core:2.17.0'
64+
androidTestImplementation 'androidx.test:runner:1.2.0'
65+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
66+
api 'androidx.test:core:1.2.0'
6467
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.googlesigninexample;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
import androidx.test.core.app.ActivityScenario;
10+
import io.flutter.plugins.googlesignin.GoogleSignInPlugin;
11+
import org.junit.Test;
12+
13+
public class GoogleSignInTest {
14+
@Test
15+
public void googleSignInPluginIsAdded() {
16+
final ActivityScenario<GoogleSignInTestActivity> scenario =
17+
ActivityScenario.launch(GoogleSignInTestActivity.class);
18+
scenario.onActivity(
19+
activity -> {
20+
assertTrue(activity.engine.getPlugins().has(GoogleSignInPlugin.class));
21+
});
22+
}
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.googlesigninexample">
3+
<!-- Flutter needs internet permission to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<application android:usesCleartextTraffic="true">
8+
<activity
9+
android:name=".GoogleSignInTestActivity"
10+
android:launchMode="singleTop"
11+
android:theme="@android:style/Theme.Black.NoTitleBar"
12+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
13+
android:hardwareAccelerated="true"
14+
android:windowSoftInputMode="adjustResize">
15+
</activity>
16+
</application>
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.googlesigninexample;
6+
7+
import androidx.annotation.NonNull;
8+
import io.flutter.embedding.android.FlutterActivity;
9+
import io.flutter.embedding.engine.FlutterEngine;
10+
11+
// Makes the FlutterEngine accessible for testing.
12+
public class GoogleSignInTestActivity extends FlutterActivity {
13+
public FlutterEngine engine;
14+
15+
@Override
16+
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
17+
super.configureFlutterEngine(flutterEngine);
18+
engine = flutterEngine;
19+
}
20+
}

packages/google_sign_in/google_sign_in/example/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google_sign_in/google_sign_in/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
http: ^0.13.0
2020

2121
dev_dependencies:
22+
espresso: ^0.1.0+2
2223
pedantic: ^1.10.0
2324
integration_test:
2425
sdk: flutter

packages/image_picker/image_picker/example/android/app/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ android {
3636
applicationId "io.flutter.plugins.imagepicker.example"
3737
minSdkVersion 16
3838
targetSdkVersion 28
39+
multiDexEnabled true
3940
versionCode flutterVersionCode.toInteger()
4041
versionName flutterVersionName
4142
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -60,9 +61,7 @@ flutter {
6061

6162
dependencies {
6263
testImplementation 'junit:junit:4.12'
63-
testImplementation 'org.mockito:mockito-core:3.10.0'
64-
androidTestImplementation 'androidx.test:runner:1.1.1'
65-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
66-
testImplementation 'androidx.test:core:1.2.0'
67-
testImplementation "org.robolectric:robolectric:4.3.1"
64+
androidTestImplementation 'androidx.test:runner:1.2.0'
65+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
66+
api 'androidx.test:core:1.2.0'
6867
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.imagepickerexample;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
import androidx.test.core.app.ActivityScenario;
10+
import io.flutter.plugins.imagepicker.ImagePickerPlugin;
11+
import org.junit.Test;
12+
13+
public class ImagePickerTest {
14+
@Test
15+
public void imagePickerPluginIsAdded() {
16+
final ActivityScenario<ImagePickerTestActivity> scenario =
17+
ActivityScenario.launch(ImagePickerTestActivity.class);
18+
scenario.onActivity(
19+
activity -> {
20+
assertTrue(activity.engine.getPlugins().has(ImagePickerPlugin.class));
21+
});
22+
}
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.imagepickerexample">
3+
<!-- Flutter needs internet permission to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<application android:usesCleartextTraffic="true">
8+
<activity
9+
android:name=".ImagePickerTestActivity"
10+
android:launchMode="singleTop"
11+
android:theme="@android:style/Theme.Black.NoTitleBar"
12+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
13+
android:hardwareAccelerated="true"
14+
android:windowSoftInputMode="adjustResize">
15+
</activity>
16+
</application>
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.imagepickerexample;
6+
7+
import androidx.annotation.NonNull;
8+
import io.flutter.embedding.android.FlutterActivity;
9+
import io.flutter.embedding.engine.FlutterEngine;
10+
11+
// Makes the FlutterEngine accessible for testing.
12+
public class ImagePickerTestActivity extends FlutterActivity {
13+
public FlutterEngine engine;
14+
15+
@Override
16+
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
17+
super.configureFlutterEngine(flutterEngine);
18+
engine = flutterEngine;
19+
}
20+
}

packages/image_picker/image_picker/example/integration_test/old_image_picker_test.dart renamed to packages/image_picker/image_picker/example/integration_test/image_picker_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter_test/flutter_test.dart';
56
import 'package:integration_test/integration_test.dart';
67

78
void main() {
89
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
11+
testWidgets('placeholder test', (WidgetTester tester) async {});
912
}

packages/image_picker/image_picker/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
path: ../
2121

2222
dev_dependencies:
23+
espresso: ^0.1.0+2
2324
flutter_driver:
2425
sdk: flutter
2526
integration_test:

packages/quick_actions/quick_actions/example/android/app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ flutter {
5353

5454
dependencies {
5555
testImplementation 'junit:junit:4.12'
56-
androidTestImplementation 'androidx.test:runner:1.1.1'
57-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
56+
androidTestImplementation 'androidx.test:runner:1.2.0'
57+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
58+
api 'androidx.test:core:1.2.0'
5859
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.quickactionsexample;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
import androidx.test.core.app.ActivityScenario;
10+
import io.flutter.plugins.quickactions.QuickActionsPlugin;
11+
import org.junit.Test;
12+
13+
public class QuickActionsTest {
14+
@Test
15+
public void imagePickerPluginIsAdded() {
16+
final ActivityScenario<QuickActionsTestActivity> scenario =
17+
ActivityScenario.launch(QuickActionsTestActivity.class);
18+
scenario.onActivity(
19+
activity -> {
20+
assertTrue(activity.engine.getPlugins().has(QuickActionsPlugin.class));
21+
});
22+
}
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.quickactionsexample">
3+
<!-- Flutter needs internet permission to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<application android:usesCleartextTraffic="true">
8+
<activity
9+
android:name=".QuickActionsTestActivity"
10+
android:launchMode="singleTop"
11+
android:theme="@style/LaunchTheme"
12+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
13+
android:hardwareAccelerated="true"
14+
android:windowSoftInputMode="adjustResize">
15+
</activity>
16+
</application>
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.quickactionsexample;
6+
7+
import androidx.annotation.NonNull;
8+
import io.flutter.embedding.android.FlutterActivity;
9+
import io.flutter.embedding.engine.FlutterEngine;
10+
11+
// Makes the FlutterEngine accessible for testing.
12+
public class QuickActionsTestActivity extends FlutterActivity {
13+
public FlutterEngine engine;
14+
15+
@Override
16+
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
17+
super.configureFlutterEngine(flutterEngine);
18+
engine = flutterEngine;
19+
}
20+
}

packages/quick_actions/quick_actions/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies:
1818
path: ../
1919

2020
dev_dependencies:
21+
espresso: ^0.1.0+2
2122
flutter_driver:
2223
sdk: flutter
2324
integration_test:

script/configs/exclude_integration_android.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Currently missing harness files: https://github.com/flutter/flutter/issues/86749)
22
- camera/camera
3-
- google_sign_in/google_sign_in
43
- in_app_purchase/in_app_purchase
54
- in_app_purchase_android
6-
- quick_actions
75
- shared_preferences/shared_preferences
86
- url_launcher/url_launcher
97
- video_player/video_player
@@ -17,5 +15,4 @@
1715
- wifi_info_flutter/wifi_info_flutter
1816

1917
# No integration tests to run:
20-
- image_picker/image_picker
2118
- espresso

0 commit comments

Comments
 (0)