Skip to content

Commit

Permalink
Revert "Use bundled Roboto in all tests (flutter#16218)"
Browse files Browse the repository at this point in the history
This reverts commit 01a7086.
  • Loading branch information
NoamDev authored Feb 27, 2020
1 parent 661dbd3 commit 7df7401
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/web_ui/dev/goldens_lock.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
repository: https://github.com/flutter/goldens.git
revision: 43254f4abddc2542ece540f222545970caf12908
revision: 3db2bb2329e7277c34389a92507eacaab774c8e8
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/dom_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ flt-glass-pane * {
setElementStyle(bodyElement, 'touch-action', 'none');

// These are intentionally outrageous font parameters to make sure that the
// apps fully specify their text styles.
// apps fully specifies their text styles.
setElementStyle(bodyElement, 'font', defaultCssFont);
setElementStyle(bodyElement, 'color', 'red');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import 'package:test/test.dart';

import 'package:web_engine_tester/golden_tester.dart';

import 'scuba.dart';

void main() async {
const double screenWidth = 600.0;
const double screenHeight = 800.0;
Expand Down Expand Up @@ -41,10 +39,11 @@ void main() async {

setUp(() async {
debugEmulateFlutterTesterEnvironment = true;
await webOnlyInitializePlatform();
webOnlyFontCollection.debugRegisterTestFonts();
await webOnlyFontCollection.ensureFontsLoaded();
});

setUpStableTestFonts();

test('Paints image', () async {
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
Expand Down
8 changes: 5 additions & 3 deletions lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import 'package:test/test.dart';

import 'package:web_engine_tester/golden_tester.dart';

import 'scuba.dart';

void main() async {
final Rect region = Rect.fromLTWH(0, 0, 500, 100);

Expand All @@ -24,7 +22,11 @@ void main() async {
html.document.querySelector('flt-scene-host').append(testScene);
}

setUpStableTestFonts();
setUp(() async {
await webOnlyInitializePlatform();
webOnlyFontCollection.debugRegisterTestFonts();
await webOnlyFontCollection.ensureFontsLoaded();
});

tearDown(() {
html.document.querySelector('flt-scene').remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ void main() async {
viewportSize: const Size(600, 600),
);

setUpStableTestFonts();

void paintTest(EngineCanvas canvas, PaintTest painter) {
final RecordingCanvas recordingCanvas =
RecordingCanvas(const Rect.fromLTWH(0, 0, 600, 600));
Expand Down Expand Up @@ -118,7 +116,7 @@ void drawQuickBrownFox(RecordingCanvas canvas) {
textStyle: TextStyle(
color: const Color(0xFF000000),
decoration: TextDecoration.none,
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
background: Paint()..color = const Color.fromRGBO(50, 255, 50, 1.0),
),
Expand Down
12 changes: 1 addition & 11 deletions lib/web_ui/test/golden_tests/engine/scuba.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void testEachCanvas(String description, CanvasTest body,

final ui.TextStyle _defaultTextStyle = ui.TextStyle(
color: const ui.Color(0xFF000000),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 14,
);

Expand All @@ -149,13 +149,3 @@ ui.Paragraph paragraph(
builder.pop();
return builder.build()..layout(ui.ParagraphConstraints(width: maxWidth));
}

/// Configures the test to use bundled Roboto and Ahem fonts to avoid golden
/// screenshot differences due to differences in the preinstalled system fonts.
void setUpStableTestFonts() {
setUp(() async {
await ui.webOnlyInitializePlatform();
ui.webOnlyFontCollection.debugRegisterTestFonts();
await ui.webOnlyFontCollection.ensureFontsLoaded();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ void main() async {

final TextStyle warningStyle = TextStyle(
color: const Color(0xFFFF0000),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 10,
);

setUpStableTestFonts();

Paragraph warning(String text) {
return paragraph(text, textStyle: warningStyle);
}
Expand Down
19 changes: 8 additions & 11 deletions lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:test/test.dart';
import 'package:ui/ui.dart';
import 'package:ui/src/engine.dart';

Expand All @@ -13,8 +12,6 @@ void main() async {
viewportSize: const Size(800, 800),
);

setUpStableTestFonts();

void drawLetterAndWordSpacing(EngineCanvas canvas) {
Offset offset = Offset.zero;

Expand All @@ -24,7 +21,7 @@ void main() async {
textStyle: TextStyle(
color: const Color(0xFF000000),
decoration: TextDecoration.none,
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
letterSpacing: spacing)),
offset,
Expand All @@ -35,7 +32,7 @@ void main() async {
final TextStyle textStyle = TextStyle(
color: const Color(0xFF00FF00),
decoration: TextDecoration.none,
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
wordSpacing: spacing);
canvas.drawParagraph(
Expand Down Expand Up @@ -69,7 +66,7 @@ void main() async {
decoration: TextDecoration.underline,
decorationStyle: decorationStyle,
decorationColor: const Color.fromRGBO(50, 50, 50, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
);
canvas.drawParagraph(
Expand Down Expand Up @@ -108,7 +105,7 @@ void main() async {
decoration: decoration,
decorationStyle: TextDecorationStyle.solid,
decorationColor: const Color.fromRGBO(255, 160, 0, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 20,
);
canvas.drawParagraph(
Expand Down Expand Up @@ -138,7 +135,7 @@ void main() async {
textStyle: TextStyle(
color: const Color.fromRGBO(0, 0, 0, 1.0),
background: Paint()..color = const Color.fromRGBO(255, 50, 50, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
),
),
Expand All @@ -153,7 +150,7 @@ void main() async {
textStyle: TextStyle(
color: const Color.fromRGBO(0, 0, 0, 1.0),
background: Paint()..color = const Color.fromRGBO(50, 50, 255, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
),
),
Expand All @@ -170,7 +167,7 @@ void main() async {
textStyle: TextStyle(
color: const Color.fromRGBO(0, 0, 0, 1.0),
background: Paint()..color = const Color.fromRGBO(255, 50, 50, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
shadows: <Shadow>[
Shadow(
Expand All @@ -192,7 +189,7 @@ void main() async {
textStyle: TextStyle(
color: const Color.fromRGBO(0, 0, 0, 1.0),
background: Paint()..color = const Color.fromRGBO(50, 50, 255, 1.0),
fontFamily: 'Roboto',
fontFamily: 'Arial',
fontSize: 30,
shadows: <Shadow>[
Shadow(
Expand Down

0 comments on commit 7df7401

Please sign in to comment.