mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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.
39 lines
1.0 KiB
Dart
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));
|
|
});
|
|
}
|