Skip to content

Commit 6ae2809

Browse files
committed
improve aspectmode tests
1 parent 1fdc49c commit 6ae2809

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,19 @@ describe('Test gl3d modebar handlers - perspective case', function() {
575575
buttonDefault.click();
576576
});
577577

578-
it('@gl button resetCameraDefault3d should reset to initial aspectratios', function(done) {
578+
it('@gl button resetCameraDefault3d should reset to initial aspectmode & aspectratios', function(done) {
579579
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
580580

581+
expect(gd._fullLayout.scene._scene.viewInitial.aspectmode).toEqual('auto');
582+
expect(gd._fullLayout.scene2._scene.viewInitial.aspectmode).toEqual('manual');
583+
581584
expect(gd._fullLayout.scene._scene.viewInitial.aspectratio).toEqual({ x: 1, y: 1, z: 1 });
582585
expect(gd._fullLayout.scene2._scene.viewInitial.aspectratio).toEqual({ x: 3, y: 2, z: 1 });
583586

584587
gd.once('plotly_relayout', function() {
588+
expect(gd._fullLayout.scene._scene.fullSceneLayout.aspectmode).toBe('auto');
589+
expect(gd._fullLayout.scene2._scene.fullSceneLayout.aspectmode).toBe('manual');
590+
585591
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().x).toBeCloseTo(1);
586592
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().y).toBeCloseTo(1);
587593
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().z).toBeCloseTo(1);
@@ -595,9 +601,12 @@ describe('Test gl3d modebar handlers - perspective case', function() {
595601
buttonDefault.click();
596602
});
597603

598-
it('@gl button resetCameraLastSave3d should reset to initial aspectratios', function(done) {
604+
it('@gl button resetCameraLastSave3d should reset to initial aspectmode & aspectratios', function(done) {
599605
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
600606

607+
expect(gd._fullLayout.scene._scene.viewInitial.aspectmode).toEqual('auto');
608+
expect(gd._fullLayout.scene2._scene.viewInitial.aspectmode).toEqual('manual');
609+
601610
expect(gd._fullLayout.scene._scene.viewInitial.aspectratio).toEqual({ x: 1, y: 1, z: 1 });
602611
expect(gd._fullLayout.scene2._scene.viewInitial.aspectratio).toEqual({ x: 3, y: 2, z: 1 });
603612

@@ -771,13 +780,19 @@ describe('Test gl3d modebar handlers - orthographic case', function() {
771780
buttonDefault.click();
772781
});
773782

774-
it('@gl button resetCameraDefault3d should reset to initial aspectratios', function(done) {
783+
it('@gl button resetCameraDefault3d should reset to initial aspectmode & aspectratios', function(done) {
775784
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
776785

786+
expect(gd._fullLayout.scene._scene.viewInitial.aspectmode).toEqual('auto');
787+
expect(gd._fullLayout.scene2._scene.viewInitial.aspectmode).toEqual('manual');
788+
777789
expect(gd._fullLayout.scene._scene.viewInitial.aspectratio).toEqual({ x: 1, y: 1, z: 1 });
778790
expect(gd._fullLayout.scene2._scene.viewInitial.aspectratio).toEqual({ x: 3, y: 2, z: 1 });
779791

780792
gd.once('plotly_relayout', function() {
793+
expect(gd._fullLayout.scene._scene.aspectmode).toEqual(undefined);
794+
expect(gd._fullLayout.scene2._scene.aspectmode).toEqual(undefined);
795+
781796
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().x).toBeCloseTo(1);
782797
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().y).toBeCloseTo(1);
783798
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().z).toBeCloseTo(1);
@@ -791,13 +806,19 @@ describe('Test gl3d modebar handlers - orthographic case', function() {
791806
buttonDefault.click();
792807
});
793808

794-
it('@gl button resetCameraLastSave3d should reset to initial aspectratios', function(done) {
809+
it('@gl button resetCameraLastSave3d should reset to initial aspectmode & aspectratios', function(done) {
795810
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
796811

812+
expect(gd._fullLayout.scene._scene.viewInitial.aspectmode).toEqual('auto');
813+
expect(gd._fullLayout.scene2._scene.viewInitial.aspectmode).toEqual('manual');
814+
797815
expect(gd._fullLayout.scene._scene.viewInitial.aspectratio).toEqual({ x: 1, y: 1, z: 1 });
798816
expect(gd._fullLayout.scene2._scene.viewInitial.aspectratio).toEqual({ x: 3, y: 2, z: 1 });
799817

800818
gd.once('plotly_relayout', function() {
819+
expect(gd._fullLayout.scene._scene.fullSceneLayout.aspectmode).toBe('auto');
820+
expect(gd._fullLayout.scene2._scene.fullSceneLayout.aspectmode).toBe('manual');
821+
801822
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().x).toBeCloseTo(1);
802823
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().y).toBeCloseTo(1);
803824
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().z).toBeCloseTo(1);
@@ -1175,7 +1196,7 @@ describe('Test gl3d drag and wheel interactions', function() {
11751196
.then(done);
11761197
});
11771198

1178-
it('@gl should update the scene aspectratio when zooming with scroll wheel i.e. orthographic case', function(done) {
1199+
it('@gl should update the scene aspectmode & aspectratio when zooming with scroll wheel i.e. orthographic case', function(done) {
11791200
var sceneLayout, sceneLayout2, sceneTarget, sceneTarget2;
11801201

11811202
var mock = {
@@ -1192,8 +1213,13 @@ describe('Test gl3d drag and wheel interactions', function() {
11921213
var aspectratio;
11931214
var relayoutEvent;
11941215
var relayoutCnt = 0;
1216+
var modeBar;
11951217

11961218
Plotly.plot(gd, mock)
1219+
.then(delay(20))
1220+
.then(function() {
1221+
modeBar = gd._fullLayout._modeBar;
1222+
})
11971223
.then(function() {
11981224
gd.on('plotly_relayout', function(e) {
11991225
relayoutCnt++;
@@ -1220,6 +1246,7 @@ describe('Test gl3d drag and wheel interactions', function() {
12201246
expect(aspectratio.z).toBeCloseTo(0.909, 3, 'aspectratio.z');
12211247

12221248
expect(relayoutEvent['scene.aspectmode']).toBe('manual');
1249+
expect(gd._fullLayout.scene._scene.fullSceneLayout.aspectmode).toBe('manual');
12231250
})
12241251
.then(function() {
12251252
return scroll(sceneTarget2);
@@ -1232,7 +1259,24 @@ describe('Test gl3d drag and wheel interactions', function() {
12321259
expect(aspectratio.y).toBeCloseTo(1.818, 3, 'aspectratio.y');
12331260
expect(aspectratio.z).toBeCloseTo(0.909, 3, 'aspectratio.z');
12341261

1235-
expect(relayoutEvent['scene.aspectmode']).not.toBe('manual');
1262+
expect(relayoutEvent['scene2.aspectmode']).toBe('manual');
1263+
expect(gd._fullLayout.scene2._scene.fullSceneLayout.aspectmode).toBe('manual');
1264+
})
1265+
.then(function() {
1266+
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
1267+
1268+
buttonDefault.click();
1269+
})
1270+
.then(function() {
1271+
expect(gd._fullLayout.scene._scene.aspectmode).toEqual(undefined);
1272+
expect(gd._fullLayout.scene2._scene.aspectmode).toEqual(undefined);
1273+
1274+
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().x).toBeCloseTo(1);
1275+
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().y).toBeCloseTo(1);
1276+
expect(gd._fullLayout.scene._scene.glplot.getAspectratio().z).toBeCloseTo(1);
1277+
expect(gd._fullLayout.scene2._scene.glplot.getAspectratio().x).toBeCloseTo(3);
1278+
expect(gd._fullLayout.scene2._scene.glplot.getAspectratio().y).toBeCloseTo(2);
1279+
expect(gd._fullLayout.scene2._scene.glplot.getAspectratio().z).toBeCloseTo(1);
12361280
})
12371281
.catch(failTest)
12381282
.then(done);
@@ -1464,6 +1508,7 @@ describe('Test gl3d drag and wheel interactions', function() {
14641508
expect(aspectratio.z).toBeCloseTo(1.269, 3, 'aspectratio.z');
14651509

14661510
expect(relayoutEvent['scene.aspectmode']).toBe('manual');
1511+
expect(gd._fullLayout.scene._scene.fullSceneLayout.aspectmode).toBe('manual');
14671512
})
14681513
.then(function() {
14691514
// select a point

0 commit comments

Comments
 (0)