flutter_flutter/packages/flutter/test/services/font_loader_test.dart
Greg Spencer 58287aceef
Convert services tests to NNBD (#62694)
This converts the packages/flutter/test/services directory to NNBD, now that the services package is converted.

I changed the signature of checkMessageHandler and checkMockMessageHandler on BinaryMessenger to take a nullable handler, since the tests wanted to check to make sure a handler wasn't set, and that functionality no longer works if the handler is non-nullable.
2020-10-08 13:46:44 -07:00

39 lines
1.0 KiB
Dart

// Copyright 2014 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:typed_data';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
class TestFontLoader extends FontLoader {
TestFontLoader(String family) : super(family);
@override
Future<void> loadFont(Uint8List list, String family) async {
fontAssets.add(list);
}
List<Uint8List> fontAssets = <Uint8List>[];
}
void main() {
test('Font loader test', () async {
final TestFontLoader tfl = TestFontLoader('TestFamily');
final List<Uint8List> expectedAssets = <Uint8List>[
Uint8List.fromList(<int>[100]),
Uint8List.fromList(<int>[10, 20, 30]),
Uint8List.fromList(<int>[200]),
];
for (final Uint8List asset in expectedAssets) {
tfl.addFont(Future<ByteData>.value(ByteData.view(asset.buffer)));
}
await tfl.load();
expect(tfl.fontAssets, unorderedEquals(expectedAssets));
});
}