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

Make it easy to write embedder unit tests by creating a fixture and config builder. #8276

Merged
merged 1 commit into from
Mar 25, 2019

Conversation

chinmaygarde
Copy link
Member

All embedder unit-tests have to setup the Flutter project arguments from scratch
before launching the engine. The boilerplate and having to deal with the low
level C API during each engine launch is a hinderance to writing tests.

This patch introduces an EmbedderTest fixture that sets up all the embedder side snapshots before allowing the unit test to create a FlutterConfigBuilder` that
the test can use to incrementally build and edit the Flutter project
configuration. From the given state state of a configuration, multiple engines
can be launched with their lifecylces managed by appropriate RAII wrappers.

This allows the a fully configured Flutter engine to be launched using 4 lines
of code in a fixture.

EmbedderConfigBuilder builder;
builder.SetSoftwareRendererConfig();
builder.SetAssetsPathFromFixture(this);
builder.SetSnapshotsFromFixture(this);
auto engine = builder.LaunchEngine();

…onfig builder.

All embedder unit-test have to setup the Flutter project arguments from scratch
before launching the engine. The boilerplate and having to deal with the low
level C API each engine launch is a hinderance to writing tests.

This patch introduces EmbedderTest fixture that sets up all the embedder side
snapshots before allowing the unit test to create a FlutterConfigBuilder that
the test can use to incrementally build and edit the Flutter project
configuration. From the given state state of a configuration, multiple engines
can be launched with their lifecylces managed by appropriate RAII wrappers.

This allows the a fully configured Flutter engine to be launched using 4 lines
of code in a fixture.

```
EmbedderConfigBuilder builder;
builder.SetSoftwareRendererConfig();
builder.SetAssetsPathFromFixture(this);
builder.SetSnapshotsFromFixture(this);
auto engine = builder.LaunchEngine();
```
@chinmaygarde
Copy link
Member Author

I'll convert the existing tests to use the fixture in a subsequent patch.

@chinmaygarde chinmaygarde merged commit d6ead18 into flutter:master Mar 25, 2019
@chinmaygarde chinmaygarde deleted the easy_embedder_test branch March 25, 2019 18:58
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 25, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 25, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Mar 25, 2019
flutter/engine@3a445ce...dd6be2f

git log 3a445ce..dd6be2f --no-merges --oneline
dd6be2f Roll src/third_party/skia 42197c0bc68e..15dc59e65cfa (19 commits) (flutter/engine#8294)
d6ead18 Make it easy to write embedder unit tests by creating a fixture and config builder. (flutter/engine#8276)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff (liyuqian@google.com), and stop
the roller if necessary.
RBogie pushed a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
…onfig builder. (flutter#8276)

All embedder unit-tests have to setup the Flutter project arguments from scratch
before launching the engine. The boilerplate and having to deal with the low
level C API during each engine launch is a hinderance to writing tests.

This patch introduces an EmbedderTest fixture that sets up all the embedder side snapshots before allowing the unit test to create a FlutterConfigBuilder` that
the test can use to incrementally build and edit the Flutter project
configuration. From the given state state of a configuration, multiple engines
can be launched with their lifecylces managed by appropriate RAII wrappers.

This allows the a fully configured Flutter engine to be launched using 4 lines
of code in a fixture.

```
EmbedderConfigBuilder builder;
builder.SetSoftwareRendererConfig();
builder.SetAssetsPathFromFixture(this);
builder.SetSnapshotsFromFixture(this);
auto engine = builder.LaunchEngine();
```
RBogie added a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
RBogie added a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants