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