Skip to content

Commit

Permalink
feat(g-canvas): 增加 antvis#726 bug单测
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxun03 committed Feb 9, 2021
1 parent 9a96f7a commit d0b0872
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/g-canvas/tests/bugs/issue-726-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const expect = require('chai').expect;
import { Canvas } from '../../src';
const container = document.createElement('canvas');
document.body.appendChild(container);

describe('#726', () => {
it('Total canvas memory use exceeds xxxMB bug', () => {
const canvas = new Canvas({
container,
width: 600,
height: 500,
});

const canvasEl = canvas.get('el');
const pixelRatio = canvas.getPixelRatio();

expect(canvasEl.width).eql(600 * pixelRatio);
expect(canvasEl.height).eql(500 * pixelRatio);

canvas.destroy();

// 销毁canvas后需要设置宽高为0
// 解决ios场景下 canvas无法进行垃圾回收的问题
expect(canvasEl.width).eql(0);
expect(canvasEl.height).eql(0);
});
});

0 comments on commit d0b0872

Please sign in to comment.