Skip to content

Commit 81e2dce

Browse files
committed
add test for non-integer gd width/height
1 parent 1c8702a commit 81e2dce

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Diff for: test/jasmine/tests/gl2d_plot_interact_test.js

+51
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,57 @@ describe('Test gl plot side effects', function() {
261261
.catch(failTest)
262262
.then(done);
263263
});
264+
265+
it('@gl should not clear context when dimensions are not integers', function(done) {
266+
spyOn(Plots, 'cleanPlot').and.callThrough();
267+
spyOn(Lib, 'log').and.callThrough();
268+
269+
var w = 500.5;
270+
var h = 400.5;
271+
var w0 = Math.floor(w);
272+
var h0 = Math.floor(h);
273+
274+
function assertDims(msg) {
275+
var fullLayout = gd._fullLayout;
276+
expect(fullLayout.width).toBe(w, msg);
277+
expect(fullLayout.height).toBe(h, msg);
278+
279+
var canvas = fullLayout._glcanvas;
280+
expect(canvas.node().width).toBe(w0, msg);
281+
expect(canvas.node().height).toBe(h0, msg);
282+
283+
var gl = canvas.data()[0].regl._gl;
284+
expect(gl.drawingBufferWidth).toBe(w0, msg);
285+
expect(gl.drawingBufferHeight).toBe(h0, msg);
286+
}
287+
288+
Plotly.plot(gd, [{
289+
type: 'scattergl',
290+
mode: 'lines',
291+
y: [1, 2, 1]
292+
}], {
293+
width: w,
294+
height: h
295+
})
296+
.then(function() {
297+
assertDims('base state');
298+
299+
// once from supplyDefaults
300+
expect(Plots.cleanPlot).toHaveBeenCalledTimes(1);
301+
expect(Lib.log).toHaveBeenCalledTimes(0);
302+
303+
return Plotly.restyle(gd, 'mode', 'markers');
304+
})
305+
.then(function() {
306+
assertDims('after restyle');
307+
308+
// one more supplyDefaults
309+
expect(Plots.cleanPlot).toHaveBeenCalledTimes(2);
310+
expect(Lib.log).toHaveBeenCalledTimes(0);
311+
})
312+
.catch(failTest)
313+
.then(done);
314+
});
264315
});
265316

266317
describe('Test gl2d plots', function() {

0 commit comments

Comments
 (0)