Files
sdk/tests/lib_2/html/fontface_loaded_test.dart
T
Bob Nystrom f6ca2c1d8f Remove the Dart 1 tests.
This deletes:

tests/co19
tests/corelib
tests/html
tests/isolate
tests/language
tests/lib

It does not delete tests/standalone because apparently there are tests
in there that are not in standalone_2. (I assume they were added after
the test migration. I don't know why they were added there.)

I have tried to remove references to the old tests from various scripts
and tools but may have missed some. (As you can imagine, grepping for
"lib" does not have the best signal-to-noise ratio.)

"It was a pleasure to burn. It was a special pleasure to see things
eaten, to see things blackened and changed. With the brass nozzle in his
fists, with this great python spitting its venomous kerosene upon the
world, the blood pounded in his head, and his hands were the hands of
some amazing conductor playing all the symphonies of blazing and burning
to bring down the tatters and charcoal ruins of history."

- Ray Bradbury, Fahrenheit 451

Change-Id: If3db4a50e7a5ee25aff8058b1483e2ce8e68424e
Reviewed-on: https://dart-review.googlesource.com/c/75420
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Terry Lucas <terry@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-10-11 23:45:18 +00:00

65 lines
1.8 KiB
Dart

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/lib_2/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', () async {
var atLeastOneFont = false;
var loaded = <Future<FontFace>>[];
document.fonts.forEach((FontFace fontFace, _, __) async {
atLeastOneFont = true;
var f1 = fontFace.loaded;
var f2 = fontFace.loaded;
loaded.add(fontFace.load());
loaded.add(f1);
loaded.add(f2);
});
expect(atLeastOneFont, isTrue);
return Future.wait(loaded).then(expectAsync((_) async {
document.fonts.forEach((fontFace, _, __) {
expect(fontFace.status, 'loaded');
});
expect(loaded.length, 3);
for (var loadedEntry in loaded) {
var fontFace = await loadedEntry;
expect(fontFace.status, 'loaded');
var fontFamily = fontFace.family;
if (fontFamily.startsWith('"')) {
// FF wraps family in quotes - remove the quotes.
fontFamily = fontFamily.substring(1, fontFamily.length - 1);
}
expect(fontFamily, 'Ahem');
}
}));
});
}