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

Commit 6b86f04

Browse files
committed
Update README, changelog, remove test
1 parent f2e0e56 commit 6b86f04

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

packages/espresso/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## 0.0.1
22

3-
* TODO: Describe initial release.
3+
* Initial open-source release of Espresso bindings for Flutter.

packages/espresso/README.md

+63-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,70 @@
22

33
A new flutter plugin project.
44

5-
## Getting Started
5+
This package provides bindings for Espresso tests of Flutter apps.
66

7+
## Installation
78

9+
See the example app for test layout.
810

911
Add ```android:usesCleartextTraffic="true"``` to your ```<application>``` in your AndroidManifest.xml.
12+
13+
## Sample usage:
14+
15+
```
16+
@RunWith(AndroidJUnit4.class)
17+
public final class SharedPreferencesIntegrationTest {
18+
19+
@Rule
20+
public ActivityTestRule<MainActivity> myActivityTestRule =
21+
new ActivityTestRule<>(MainActivity.class, true, false);
22+
23+
@Before
24+
public void setUp() {
25+
ActivityScenario.launch(MainActivity.class);
26+
}
27+
28+
@Test
29+
public void tapToCheckPersistentData() throws Exception {
30+
onFlutterWidget(FlutterMatchers.withTooltip("Clear")).perform(FlutterActions.click());
31+
onFlutterWidget(FlutterMatchers.withTooltip("Increment")).perform(FlutterActions.click());
32+
onFlutterWidget(FlutterMatchers.withValueKey("ResultText")).check(
33+
FlutterAssertions.matches(FlutterMatchers.withText(
34+
"Button tapped 1 time.\n\nThis should persist across restarts."
35+
)));
36+
// kill the app
37+
pressBackUnconditionally();
38+
// reopen the application
39+
myActivityTestRule.launchActivity(null);
40+
onFlutterWidget(FlutterMatchers.withValueKey("ResultText")).check(
41+
FlutterAssertions.matches(
42+
FlutterMatchers.withText(
43+
"Button tapped 1 time.\n\nThis should persist across restarts.")));
44+
}
45+
}
46+
```
47+
48+
The following command line command runs the test locally:
49+
50+
```
51+
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/shared_preferences.dart
52+
```
53+
54+
Tests can also be uploaded to Firebase Test Lab:
55+
56+
```
57+
./gradlew app:assembleAndroidTest
58+
./gradlew app:assembleDebug -Ptarget=<path_to_test>.dart
59+
gcloud auth activate-service-account --key-file=<PATH_TO_KEY_FILE>
60+
gcloud --quiet config set project <PROJECT_NAME>
61+
gcloud firebase test android run --type instrumentation \
62+
--app build/app/outputs/apk/debug/app-debug.apk \
63+
--test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk\
64+
--timeout 2m \
65+
--results-bucket=<RESULTS_BUCKET> \
66+
--results-dir=<RESULTS_DIRECTORY>
67+
```
68+
69+
This guarantees that UrlLauncherPlatform.instance cannot be set to an object that `implements`
70+
UrlLauncherPlatform (it can only be set to an object that `extends` UrlLauncherPlatform).
71+

packages/espresso/test/espresso_test.dart

-23
This file was deleted.

0 commit comments

Comments
 (0)