[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 <nifong@google.com>
This commit is contained in:
Kevin Lubick 2020-02-04 12:37:40 -05:00
parent a2406f9218
commit 6e1320da6b

View File

@ -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) {