forked from dart-lang/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontface_loaded_test.dart
53 lines (47 loc) · 1.31 KB
/
fontface_loaded_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library fontface_loaded_test;
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
import 'dart:async';
import 'dart:isolate';
import 'dart:html';
class NullTreeSanitizer implements NodeTreeSanitizer {
void sanitizeTree(Node node) {}
}
main() {
useHtmlConfiguration();
var style = new Element.html(
'''
<style>
@font-face {
font-family: 'Ahem';
src: url(/root_dart/tests/html/Ahem.ttf);
font-style: italic;
font-weight: 300;
unicode-range: U+0-3FF;
font-variant: small-caps;
-webkit-font-feature-settings: "dlig" 1;
/* font-stretch property is not supported */
}
</style>
''',
treeSanitizer: new NullTreeSanitizer());
document.head.append(style);
test('document fonts - temporary', () {
var atLeastOneFont = false;
var loaded = [];
document.fonts.forEach((FontFace fontFace, _, __) {
atLeastOneFont = true;
Future f1 = fontFace.loaded;
Future f2 = fontFace.loaded;
loaded.add(fontFace.load());
loaded.add(f1);
loaded.add(f2);
});
expect(atLeastOneFont, isTrue);
return Future.wait(loaded).then(expectAsync((_) {
document.fonts.forEach((fontFace, _, __) {
expect(fontFace.status, 'loaded');
});
}));
});
}