From 6e1320da6b84b1a12848705019ffb01b9489f9cf Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Tue, 4 Feb 2020 12:37:40 -0500 Subject: [PATCH] [canvaskit] Fix flaky test We accidentally were not waiting until all font files were loaded before trying to process them. Bug: skia:9858 Change-Id: I10decd5fbf0aa46e300d2ce5255f24f1ac1c12d4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268626 Reviewed-by: Nathaniel Nifong --- modules/canvaskit/tests/font.spec.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/canvaskit/tests/font.spec.js b/modules/canvaskit/tests/font.spec.js index 7c59513472..992bc97f0d 100644 --- a/modules/canvaskit/tests/font.spec.js +++ b/modules/canvaskit/tests/font.spec.js @@ -282,7 +282,8 @@ describe('CanvasKit\'s Font Behavior', function() { ttcFontBuffer = buffer; }); - Promise.all([LoadCanvasKit, otfFontLoaded, bungeeFontLoaded, woffFontLoaded, woff2FontLoaded]).then(catchException(done, () => { + Promise.all([LoadCanvasKit, otfFontLoaded, bungeeFontLoaded, woffFontLoaded, + woff2FontLoaded, ttcFontLoaded]).then(catchException(done, () => { const surface = CanvasKit.MakeCanvasSurface('test'); expect(surface).toBeTruthy('Could not make surface') if (!surface) { @@ -318,6 +319,9 @@ describe('CanvasKit\'s Font Behavior', function() { canvas.drawText(`The following should be ${inputs.length + 1} lines of text:`, 5, 30, fontPaint, defaultFont); for (const fontType of inputs) { + // smoke test that the font bytes loaded. + expect(fontType.buffer).toBeTruthy(fontType.type + ' did not load'); + const typeface = fontMgr.MakeTypefaceFromData(fontType.buffer); const font = new CanvasKit.SkFont(typeface, 24); @@ -332,7 +336,9 @@ describe('CanvasKit\'s Font Behavior', function() { // The only ttc font I could find was 14 MB big, so I'm using the smaller test font, // which doesn't have very many glyphs in it, so we just check that we got a non-zero - // typeface for it. I was able to load NotoSansCJK-Regular.ttc just fine in a manual test. + // typeface for it. I was able to load NotoSansCJK-Regular.ttc just fine in a + // manual test. + expect(ttcFontBuffer).toBeTruthy('.ttc font did not load'); const typeface = fontMgr.MakeTypefaceFromData(ttcFontBuffer); expect(typeface).toBeTruthy('.ttc font'); if (typeface) {