{"size": 1757, "ext": "js", "max_stars_repo_path": "modules/canvaskit/tests/core.spec.js", "max_stars_repo_name": "Shachlan/skia", "max_stars_repo_stars_event_min_datetime": "2019-04-20T09:12:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-06T20:04:22.000Z", "max_issues_repo_path": "modules/canvaskit/tests/core.spec.js", "max_issues_repo_name": "Shachlan/skia", "max_issues_repo_issues_event_min_datetime": "2019-04-29T06:34:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-18T11:56:32.000Z", "max_forks_repo_path": "modules/canvaskit/tests/core.spec.js", "max_forks_repo_name": "Shachlan/skia", "max_forks_repo_forks_event_min_datetime": "2018-10-31T03:07:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T08:53:21.000Z"}
{"max_stars_count": 8, "max_issues_count": 3, "max_forks_count": 9, "avg_line_length": 34.4509803922, "max_line_length": 89, "alphanum_fraction": 0.5680136596}
describe('Core canvas behavior', function() {
    let container = document.createElement('div');
    document.body.appendChild(container);
    const CANVAS_WIDTH = 600;
    const CANVAS_HEIGHT = 600;

    beforeEach(function() {
        container.innerHTML = `
            <canvas width=600 height=600 id=test></canvas>
            <canvas width=600 height=600 id=report></canvas>`;
    });

    afterEach(function() {
        container.innerHTML = '';
    });

    it('can draw an SkPicture', function(done) {
        LoadCanvasKit.then(catchException(done, () => {
            // This is taken from example.html
            const surface = CanvasKit.MakeCanvasSurface('test');
            expect(surface).toBeTruthy('Could not make surface')
            if (!surface) {
                done();
                return;
            }
            const spr = new CanvasKit.SkPictureRecorder();
            const rcanvas = spr.beginRecording(
                            CanvasKit.LTRBRect(0, 0, surface.width(), surface.height()));
            const paint = new CanvasKit.SkPaint();
            paint.setStrokeWidth(2.0);
            paint.setAntiAlias(true);
            paint.setColor(CanvasKit.Color(0, 0, 0, 1.0));
            paint.setStyle(CanvasKit.PaintStyle.Stroke);

            rcanvas.drawRoundRect(CanvasKit.LTRBRect(5, 35, 45, 80), 15, 10, paint);

            const font = new CanvasKit.SkFont(null, 20);
            rcanvas.drawText('this picture has a round rect', 5, 100, paint, font);
            const pic = spr.finishRecordingAsPicture();
            spr.delete();


            const canvas = surface.getCanvas();
            canvas.drawPicture(pic);

            reportSurface(surface, 'picture_test', done);
        }));
    });

});
