README.md 3.6 KB
Newer Older
D
Dan Field 已提交
1 2
# Scenario App

3 4
This folder contains e2e integration tests for the engine in conjunction with a
fake dart:ui framework running in JIT or AOT.
D
Dan Field 已提交
5 6 7 8 9 10

It intentionally has no dependencies on the Flutter framework or tooling, such
that it should be buildable as a presubmit or postsubmit to the engine even in
the face of changes to Dart or dart:ui that require upstream changes in the
Flutter tooling.

11 12 13 14 15 16 17 18 19 20 21
## Adding a New Scenario

Create a new subclass of [Scenario](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/lib/src/scenario.dart#L9)
and add it to the map in [main.dart](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/lib/main.dart#L17).
For an example, see [animated_color_square.dart](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/lib/src/animated_color_square.dart#L15),
which draws a continuously animating colored square that bounces off the sides
of the viewport.

Then set the scenario from the Android or iOS app by calling "set_scenario" on
platform channel.

22 23 24
## Running for iOS

```sh
25
./build_and_run_ios_tests.sh
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
```

### iOS Platform View Tests

For PlatformView tests on iOS, you'll also have to edit the dictionaries in
[AppDelegate.m](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m#L29) and [PlatformViewGoldenTestManager.m](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m#L24) so that the correct golden image can be found.  Also, you'll have to add a [GoldenPlatformViewTests](https://github.com/flutter/engine/blob/5d9509ae056b04c30295df27f201f31af9777842/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.h#L18) in [PlatformViewUITests.m](https://github.com/flutter/engine/blob/af2ffc02b72af2a89242ca3c89e18269b1584ce5/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m).

### Generating Golden Images on iOS

Screenshots are saved as
[XCTAttachment](https://developer.apple.com/documentation/xctest/activities_and_attachments/adding_attachments_to_tests_and_activities?language=objc)'s.
If you look at the output from running the tests you'll find a path in the form:
`/Users/$USER/Library/Developer/Xcode/DerivedData/Scenarios-$HASH`.
Inside that directory you'll find
`./Build/Products/Debug-iphonesimulator/ScenariosUITests-Runner.app/PlugIns/ScenariosUITests.xctest/` which is where all the images that were
compared against golden reside.

43
## Running for Android
D
Dan Field 已提交
44

45
The test is run on a x86 emulator. To run the test locally, you must create an emulator running API level 28, using an x86_64 ABI, and set the following screen settings in the avd's `config.ini` file:
46 47 48

```
hw.lcd.density = 480
49
hw.lcd.height = 1680
50
hw.lcd.width = 1080
51
lcd.depth = 16
52 53 54 55 56 57
```

This file is typically located in your `$HOME/.android/avd/<avd>` folder.

Once the emulator is up, you can run the test by running:

D
Dan Field 已提交
58
```bash
59
./build_and_run_android_tests.sh
D
Dan Field 已提交
60 61
```

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
### Generating Golden Images on Android

In the `android` directory, run:

```bash
./gradlew app:recordDebugAndroidTestScreenshotTest
```

The screenshots are recorded into `android/reports/screenshots`.

### Verifying Golden Images on Android

In the `android` directory, run:

```bash
./gradlew app:verifyDebugAndroidTestScreenshotTest
```

80 81 82 83
## Changing dart:ui code

If you change the dart:ui interface, remember to point the sky_engine and
sky_services clauses to your local engine's output path before compiling.