Skip to content

Commit 348d4d0

Browse files
committed
Add big points selection test
1 parent 1f6e68b commit 348d4d0

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ describe('Test gl2d plots', function() {
14461446
var mock = require('@mocks/gl2d_10.json');
14471447

14481448
beforeEach(function() {
1449-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
1449+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
14501450
gd = createGraphDiv();
14511451
});
14521452

@@ -1462,6 +1462,26 @@ describe('Test gl2d plots', function() {
14621462
return drag(node, dx, dy, null, p0[0], p0[1]);
14631463
}
14641464

1465+
function select(path) {
1466+
return new Promise(function(resolve) {
1467+
gd.once('plotly_selected', resolve);
1468+
1469+
var len = path.length;
1470+
1471+
// do selection
1472+
Lib.clearThrottle();
1473+
mouseEvent('mousemove', path[0][0], path[0][1]);
1474+
mouseEvent('mousedown', path[0][0], path[0][1]);
1475+
1476+
path.slice(1, len).forEach(function(pt) {
1477+
Lib.clearThrottle();
1478+
mouseEvent('mousemove', pt[0], pt[1]);
1479+
});
1480+
1481+
mouseEvent('mouseup', path[len - 1][0], path[len - 1][1]);
1482+
});
1483+
}
1484+
14651485
it('should respond to drag interactions', function(done) {
14661486
var _mock = Lib.extendDeep({}, mock);
14671487

@@ -1562,7 +1582,7 @@ describe('Test gl2d plots', function() {
15621582
.then(done);
15631583
});
15641584

1565-
it('@noCI should be able to toggle visibility', function(done) {
1585+
it('should be able to toggle visibility', function(done) {
15661586
var _mock = Lib.extendDeep({}, mock);
15671587

15681588
Plotly.plot(gd, _mock)
@@ -1592,6 +1612,34 @@ describe('Test gl2d plots', function() {
15921612
.then(done);
15931613
});
15941614

1615+
it('should display selection of big number of points', function(done) {
1616+
// generate large number of points
1617+
var x = [], y = [];
1618+
for(var i = 0; i < 2e4; i++) {
1619+
x.push(Math.random());
1620+
y.push(Math.random());
1621+
}
1622+
1623+
var mock = {
1624+
data: [{
1625+
x: x, y: y, type: 'scattergl', mode: 'markers'
1626+
}],
1627+
layout: {
1628+
dragmode: 'select'
1629+
}
1630+
};
1631+
1632+
Plotly.plot(gd, mock)
1633+
.then(select([[160, 100], [180, 100]]))
1634+
.then(function() {
1635+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
1636+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 158, 100)[3]).not.toBe(0);
1637+
expect(readPixel(gd.querySelector('.gl-canvas-focus'), 168, 100)[3]).not.toBe(0);
1638+
})
1639+
.catch(fail)
1640+
.then(done);
1641+
});
1642+
15951643
it('should be able to toggle from svg to gl', function(done) {
15961644
Plotly.plot(gd, [{
15971645
y: [1, 2, 1],

0 commit comments

Comments
 (0)