forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Preserve correct CanvasKit Variant during test initialization (f…
…lutter#43854) At some point, we started setting `useColorEmoji` to true in our tests, but we were doing it in a way that resets all other configurations to their defaults. This caused the `canvasKitVariant` config to be lost and always set to the default `auto`. This PR fixes the issue and adds tests to: 1. Make sure that the CanvasKit suite always runs with a specific variant (not `auto`). 2. Make sure the given CanvasKit variant makes it all the way through to the tests. The test harness uses a backdoor (a global JS property on `window`) to communicate which canvaskit variant it's using. The test then compares that with `configuration.canvasKitVariant` to make sure they match. If they don't match, then the configuration was lost somewhere on the way. Fixes flutter/flutter#130993
- Loading branch information
Showing
8 changed files
with
102 additions
and
9 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
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
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
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
44 changes: 44 additions & 0 deletions
44
lib/web_ui/test/canvaskit/configuration_canvaskit_variant_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,44 @@ | ||
// 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. | ||
|
||
import 'dart:js_interop'; | ||
|
||
import 'package:test/bootstrap/browser.dart'; | ||
import 'package:test/test.dart'; | ||
import 'package:ui/src/engine.dart'; | ||
|
||
import 'common.dart'; | ||
|
||
@JS('_flutter_canvaskit_variant_for_test_only') | ||
external String? get _flutterCanvaskitVariantForTestOnly; | ||
|
||
void main() { | ||
internalBootstrapBrowserTest(() => testMain); | ||
} | ||
|
||
void testMain() { | ||
setUpCanvasKitTest(); | ||
|
||
// This is to make sure we don't accidentally run the CanvasKit test suite in | ||
// auto mode. The CanvasKit variant should always be deterministic. | ||
test('CanvasKit tests always run with a specific variant', () { | ||
expect( | ||
configuration.canvasKitVariant, | ||
anyOf(CanvasKitVariant.chromium, CanvasKitVariant.full), | ||
); | ||
expect( | ||
_flutterCanvaskitVariantForTestOnly, | ||
anyOf('chromium', 'full'), | ||
); | ||
}); | ||
|
||
// This is to make sure that the variant specified by the test harness is | ||
// correctly preserved during tests in the global `configuration` object. | ||
test('CanvasKitVariant configuration is preserved in tests', () { | ||
expect( | ||
configuration.canvasKitVariant, | ||
CanvasKitVariant.values.byName(_flutterCanvaskitVariantForTestOnly!), | ||
); | ||
}); | ||
} |
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
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
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