File tree Expand file tree Collapse file tree 5 files changed +60
-3
lines changed Expand file tree Collapse file tree 5 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -618,9 +618,13 @@ class TestCommand extends Command<bool> with ArgUtils {
618
618
'--enable-asserts' ,
619
619
'--enable-experiment=non-nullable' ,
620
620
'--no-sound-null-safety' ,
621
- if (input.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true' ,
622
- if (! input.forCanvasKit) '-DFLUTTER_WEB_AUTO_DETECT=false' ,
623
- if (! input.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=false' ,
621
+
622
+ // We do not want to auto-select a renderer in tests. As of today, tests
623
+ // are designed to run in one specific mode. So instead, we specify the
624
+ // renderer explicitly.
625
+ '-DFLUTTER_WEB_AUTO_DETECT=false' ,
626
+ '-DFLUTTER_WEB_USE_SKIA=${input .forCanvasKit }' ,
627
+
624
628
'-O2' ,
625
629
'-o' ,
626
630
targetFileName, // target path.
Original file line number Diff line number Diff line change @@ -147,6 +147,17 @@ part 'engine/vector_math.dart';
147
147
part 'engine/web_experiments.dart' ;
148
148
part 'engine/window.dart' ;
149
149
150
+ // The mode the app is running in.
151
+ // Keep these in sync with the same constants on the framework-side under foundation/constants.dart.
152
+ const bool kReleaseMode = bool .fromEnvironment ('dart.vm.product' , defaultValue: false );
153
+ const bool kProfileMode = bool .fromEnvironment ('dart.vm.profile' , defaultValue: false );
154
+ const bool kDebugMode = ! kReleaseMode && ! kProfileMode;
155
+ String get buildMode => kReleaseMode
156
+ ? 'release'
157
+ : kProfileMode
158
+ ? 'profile'
159
+ : 'debug' ;
160
+
150
161
/// A benchmark metric that includes frame-related computations prior to
151
162
/// submitting layer and picture operations to the underlying renderer, such as
152
163
/// HTML and CanvasKit. During this phase we compute transforms, clips, and
Original file line number Diff line number Diff line change @@ -330,6 +330,14 @@ flt-glass-pane * {
330
330
}
331
331
332
332
final html.BodyElement bodyElement = html.document.body! ;
333
+
334
+ setElementAttribute (
335
+ bodyElement,
336
+ 'flt-renderer' ,
337
+ '${useCanvasKit ? 'canvaskit' : 'html' } (${_autoDetect ? 'auto-selected' : 'requested explicitly' })' ,
338
+ );
339
+ setElementAttribute (bodyElement, 'flt-build-mode' , buildMode);
340
+
333
341
setElementStyle (bodyElement, 'position' , 'fixed' );
334
342
setElementStyle (bodyElement, 'top' , '0' );
335
343
setElementStyle (bodyElement, 'right' , '0' );
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 The Flutter Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ // @dart = 2.12
6
+ import 'dart:html' as html;
7
+
8
+ import 'package:test/bootstrap/browser.dart' ;
9
+ import 'package:test/test.dart' ;
10
+ import 'package:ui/src/engine.dart' ;
11
+
12
+ import 'common.dart' ;
13
+
14
+ void main () {
15
+ internalBootstrapBrowserTest (() => testMain);
16
+ }
17
+
18
+ void testMain () {
19
+ group ('CanvasKit' , () {
20
+ setUpCanvasKitTest ();
21
+
22
+ test ('populates flt-renderer and flt-build-mode' , () {
23
+ DomRenderer ();
24
+ expect (html.document.body! .attributes['flt-renderer' ], 'canvaskit (requested explicitly)' );
25
+ expect (html.document.body! .attributes['flt-build-mode' ], 'debug' );
26
+ });
27
+ // TODO: https://github.com/flutter/flutter/issues/60040
28
+ }, skip: isIosSafari);
29
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ void main() {
14
14
}
15
15
16
16
void testMain () {
17
+ test ('populates flt-renderer and flt-build-mode' , () {
18
+ DomRenderer ();
19
+ expect (html.document.body.attributes['flt-renderer' ], 'html (requested explicitly)' );
20
+ expect (html.document.body.attributes['flt-build-mode' ], 'debug' );
21
+ });
17
22
test ('creating elements works' , () {
18
23
final DomRenderer renderer = DomRenderer ();
19
24
final html.Element element = renderer.createElement ('div' );
You can’t perform that action at this time.
0 commit comments