diff --git a/lib/web_ui/test/text/font_collection_test.dart b/lib/web_ui/test/text/font_collection_test.dart index 6581e4aae4be6..d10fd8286c440 100644 --- a/lib/web_ui/test/text/font_collection_test.dart +++ b/lib/web_ui/test/text/font_collection_test.dart @@ -21,122 +21,192 @@ void main() { html.document.fonts.clear(); }); - test('Register Asset with no special characters', () async { - final String _testFontFamily = "Ahem"; - final List fontFamilyList = List(); - - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + group('regular special characters', () { + test('Register Asset with no special characters', () async { + final String _testFontFamily = "Ahem"; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, 'Ahem'); }); - expect(fontFamilyList.length, equals(1)); - expect(fontFamilyList.first, 'Ahem'); - }); + test('Register Asset with white space in the family name', () async { + final String _testFontFamily = "Ahem ahem ahem"; + final List fontFamilyList = List(); - test('Register Asset with white space in the family name', () async { - final String _testFontFamily = "Ahem ahem ahem"; - final List fontFamilyList = List(); + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, 'Ahem ahem ahem'); }); - expect(fontFamilyList.length, equals(1)); - expect(fontFamilyList.first, 'Ahem ahem ahem'); - }); + test('Register Asset with capital case letters', () async { + final String _testFontFamily = "AhEm"; + final List fontFamilyList = List(); - test('Register Asset with capital case letters', () async { - final String _testFontFamily = "AhEm"; - final List fontFamilyList = List(); + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, 'AhEm'); }); - - expect(fontFamilyList.length, equals(1)); - expect(fontFamilyList.first, 'AhEm'); }); - test('Register Asset twice with special character slash', () async { - final String _testFontFamily = '/Ahem'; - final List fontFamilyList = List(); + group('special chracters Chrome, Safari 13, Edge', () { + test('Register Asset twice with special character slash', () async { + final String _testFontFamily = '/Ahem'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(2)); + expect(fontFamilyList, contains('\'/Ahem\'')); + expect(fontFamilyList, contains('/Ahem')); + }); - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + test('Register Asset twice with exclamation mark', () async { + final String _testFontFamily = 'Ahem!!ahem'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(2)); + expect(fontFamilyList, contains('\'Ahem!!ahem\'')); + expect(fontFamilyList, contains('Ahem!!ahem')); }); - expect(fontFamilyList.length, equals(2)); - expect(fontFamilyList, contains('\'/Ahem\'')); - expect(fontFamilyList, contains('/Ahem')); - }, skip: (browserEngine == BrowserEngine.firefox)); + test('Register Asset twice with comma', () async { + final String _testFontFamily = 'Ahem ,ahem'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(2)); + expect(fontFamilyList, contains('\'Ahem ,ahem\'')); + expect(fontFamilyList, contains('Ahem ,ahem')); + }); - test('Register Asset twice with exclamation mark', () async { - final String _testFontFamily = 'Ahem!!ahem'; - final List fontFamilyList = List(); + test('Register Asset twice with a digit at the start of a token', + () async { + final String testFontFamily = 'Ahem 1998'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(2)); + expect(fontFamilyList, contains('Ahem 1998')); + expect(fontFamilyList, contains('\'Ahem 1998\'')); + }); + }, skip: (browserEngine == BrowserEngine.firefox)); - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + group('special characters Firefox', () { + test('Register Asset with special character slash', () async { + final String _testFontFamily = '/Ahem'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, '\"/Ahem\"'); }); - expect(fontFamilyList.length, equals(2)); - expect(fontFamilyList, contains('\'Ahem!!ahem\'')); - expect(fontFamilyList, contains('Ahem!!ahem')); - }, skip: (browserEngine == BrowserEngine.firefox)); + test('Register Asset with exclamation mark', () async { + final String _testFontFamily = 'Ahem!!ahem'; + final List fontFamilyList = List(); - test('Register Asset twice with coma', () async { - final String _testFontFamily = 'Ahem ,ahem'; - final List fontFamilyList = List(); + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); - fontManager.registerAsset( - _testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, '\"Ahem!!ahem\"'); }); - expect(fontFamilyList.length, equals(2)); - expect(fontFamilyList, contains('\'Ahem ,ahem\'')); - expect(fontFamilyList, contains('Ahem ,ahem')); - }, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638 - skip: (browserEngine == BrowserEngine.firefox)); - - test('Register Asset twice with a digit at the start of a token', () async { - final String testFontFamily = 'Ahem 1998'; - final List fontFamilyList = List(); - - fontManager.registerAsset( - testFontFamily, 'url($_testFontUrl)', const {}); - await fontManager.ensureFontsLoaded(); - html.document.fonts - .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { - fontFamilyList.add(f.family); + test('Register Asset with comma', () async { + final String _testFontFamily = 'Ahem ,ahem'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + _testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, '\"Ahem ,ahem\"'); }); - expect(fontFamilyList.length, equals(2)); - expect(fontFamilyList, contains('Ahem 1998')); - expect(fontFamilyList, contains('\'Ahem 1998\'')); + test('Register Asset with a digit at the start of a token', + () async { + final String testFontFamily = 'Ahem 1998'; + final List fontFamilyList = List(); + + fontManager.registerAsset( + testFontFamily, 'url($_testFontUrl)', const {}); + await fontManager.ensureFontsLoaded(); + html.document.fonts + .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { + fontFamilyList.add(f.family); + }); + + expect(fontFamilyList.length, equals(1)); + expect(fontFamilyList.first, '\"Ahem 1998\"'); + }); }); - }, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638 - skip: (browserEngine == BrowserEngine.firefox)); + }, skip: (browserEngine != BrowserEngine.firefox)); }