Skip to content

Commit 8cb10c1

Browse files
committed
try to make test that update the scene camera more robust
1 parent f61cd4d commit 8cb10c1

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function delay() {
1919
});
2020
}
2121

22-
function waitForModeBar() {
22+
// updating the camera requires some waiting
23+
function waitForCamera() {
2324
return new Promise(function(resolve) {
2425
setTimeout(resolve, 200);
2526
});
@@ -836,7 +837,7 @@ describe('Test gl2d plots', function() {
836837
expect(gd.layout.xaxis.range).toBeCloseToArray(originalX, precision);
837838
expect(gd.layout.yaxis.range).toBeCloseToArray(originalY, precision);
838839
})
839-
.then(waitForModeBar)
840+
.then(waitForCamera)
840841
.then(function() {
841842
gd.on('plotly_relayout', relayoutCallback);
842843

@@ -879,7 +880,7 @@ describe('Test gl2d plots', function() {
879880
expect(gd.layout.xaxis.range).toBeCloseToArray(originalX, precision);
880881
expect(gd.layout.yaxis.range).toBeCloseToArray(originalY, precision);
881882
})
882-
.then(waitForModeBar)
883+
.then(waitForCamera)
883884
.then(function() {
884885
// callback count expectation: X and back; Y and back; XY and back
885886
expect(relayoutCallback).toHaveBeenCalledTimes(6);
@@ -1373,15 +1374,11 @@ describe('Test gl3d annotations', function() {
13731374

13741375
// more robust (especially on CI) than update camera via mouse events
13751376
function updateCamera(x, y, z) {
1376-
return new Promise(function(resolve) {
1377-
var scene = gd._fullLayout.scene._scene;
1378-
var camera = scene.getCamera();
1379-
1380-
camera.eye = {x: x, y: y, z: z};
1381-
scene.setCamera(camera);
1377+
var scene = gd._fullLayout.scene._scene;
1378+
var camera = scene.getCamera();
13821379

1383-
setTimeout(resolve, 100);
1384-
});
1380+
camera.eye = {x: x, y: y, z: z};
1381+
scene.setCamera(camera);
13851382
}
13861383

13871384
it('should move with camera', function(done) {
@@ -1410,11 +1407,13 @@ describe('Test gl3d annotations', function() {
14101407

14111408
return updateCamera(1.5, 2.5, 1.5);
14121409
})
1410+
.then(waitForCamera)
14131411
.then(function() {
14141412
assertAnnotationsXY([[340, 187], [341, 142], [325, 221]], 'after camera update');
14151413

14161414
return updateCamera(2.1, 0.1, 0.9);
14171415
})
1416+
.then(waitForCamera)
14181417
.then(function() {
14191418
assertAnnotationsXY([[262, 199], [257, 135], [325, 233]], 'base 0');
14201419
})

0 commit comments

Comments
 (0)