forked from flutter/packages
-
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.
Add integration test for Android (using Espresso)
- Loading branch information
1 parent
00f66e6
commit 6297663
Showing
6 changed files
with
127 additions
and
0 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
72 changes: 72 additions & 0 deletions
72
...oid/app/src/androidTest/java/io/flutter/plugins/videoplayerexample/VideoPlayerUITest.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,72 @@ | ||
// Copyright 2013 The Flutter 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.videoplayerexample; | ||
|
||
import static androidx.test.espresso.flutter.EspressoFlutter.onFlutterWidget; | ||
import static androidx.test.espresso.flutter.EspressoFlutter.WidgetInteraction; | ||
import static androidx.test.espresso.flutter.action.FlutterActions.click; | ||
import static androidx.test.espresso.flutter.assertion.FlutterAssertions.matches; | ||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.isExisting; | ||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withText; | ||
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withValueKey; | ||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class VideoPlayerUITest { | ||
|
||
@Rule | ||
public ActivityScenarioRule<DriverExtensionActivity> activityRule = | ||
new ActivityScenarioRule<>(DriverExtensionActivity.class); | ||
|
||
@Test | ||
public void playVideo() { | ||
WidgetInteraction remoteTab = onFlutterWidget(withText("Remote")); | ||
remoteTab.check(matches(isExisting())); | ||
|
||
for (String tabName : new String[] {"Platform view", "Texture view"}) { | ||
WidgetInteraction viewTypeTab = onFlutterWidget(withText(tabName)); | ||
viewTypeTab.check(matches(isExisting())); | ||
viewTypeTab.perform(click()); | ||
|
||
WidgetInteraction playButton = onFlutterWidget(withValueKey("Play")); | ||
playButton.check(matches(isExisting())); | ||
playButton.perform(click()); | ||
|
||
WidgetInteraction playbackSpeed1x = onFlutterWidget(withText("1.0x")); | ||
playbackSpeed1x.check(matches(isExisting())); | ||
playbackSpeed1x.perform(click()); | ||
|
||
WidgetInteraction playbackSpeed5xButton = onFlutterWidget(withText("5.0x")); | ||
playbackSpeed5xButton.check(matches(isExisting())); | ||
playbackSpeed5xButton.perform(click()); | ||
|
||
WidgetInteraction playbackSpeed5x = onFlutterWidget(withText("5.0x")); | ||
playbackSpeed5x.check(matches(isExisting())); | ||
} | ||
|
||
for (String[] tabData : | ||
new String[][] {{"Asset", "With assets mp4"}, {"Remote", "With remote mp4"}}) { | ||
String tabName = tabData[0]; | ||
String videoDescription = tabData[1]; | ||
WidgetInteraction tab = onFlutterWidget(withText(tabName)); | ||
WidgetInteraction tabDescription = onFlutterWidget(withText(videoDescription)); | ||
tab.check(matches(isExisting())); | ||
|
||
// TODO(FirentisTFW): Assert that testDescription is not visible before we tap on tab. | ||
// This should be done once the Espresso API allows us to perform such an assertion. See | ||
// https://github.com/flutter/flutter/issues/160599 | ||
|
||
tab.perform(click()); | ||
|
||
tab.check(matches(isExisting())); | ||
tabDescription.check(matches(isExisting())); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/video_player/video_player_android/example/android/app/src/debug/AndroidManifest.xml
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,20 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- The INTERNET permission is required for development. Specifically, | ||
the Flutter tool needs it to communicate with the running application | ||
to allow setting breakpoints, to provide hot reload, etc. | ||
--> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application android:usesCleartextTraffic="true"> | ||
<activity | ||
android:name="io.flutter.plugins.videoplayerexample.DriverExtensionActivity" | ||
android:launchMode="singleTop" | ||
android:theme="@style/LaunchTheme" | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
android:hardwareAccelerated="true" | ||
android:windowSoftInputMode="adjustResize"> | ||
<meta-data | ||
android:name="io.flutter.Entrypoint" | ||
android:value="integrationTestMain" /> | ||
</activity> | ||
</application> | ||
</manifest> |
10 changes: 10 additions & 0 deletions
10
...roid/app/src/main/java/io/flutter/plugins/videoplayerexample/DriverExtensionActivity.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,10 @@ | ||
// Copyright 2013 The Flutter 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.videoplayerexample; | ||
|
||
import io.flutter.embedding.android.FlutterActivity; | ||
|
||
/** Test Activity that sets the name of the Dart method entrypoint in the manifest. */ | ||
public class DriverExtensionActivity extends FlutterActivity {} |
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
19 changes: 19 additions & 0 deletions
19
...video_player/video_player_android/example/integration_test/video_player_android_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,19 @@ | ||
import 'package:flutter_driver/driver_extension.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:video_player_example/main.dart' as app; | ||
|
||
@pragma('vm:entry-point') | ||
void integrationTestMain() { | ||
enableFlutterDriverExtension(); | ||
|
||
app.main(); | ||
} | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
// Since this test is lacking integration tests, this test ensures the example | ||
// app can be launched on an emulator/device. | ||
testWidgets('Launch Test', (WidgetTester tester) async {}); | ||
} |