@@ -10,6 +10,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
10
10
var failTest = require ( '../assets/fail_test' ) ;
11
11
var mouseEvent = require ( '../assets/mouse_event' ) ;
12
12
var drag = require ( '../assets/drag' ) ;
13
+ var doubleClick = require ( '../assets/double_click' ) ;
13
14
14
15
var customAssertions = require ( '../assets/custom_assertions' ) ;
15
16
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
@@ -918,7 +919,7 @@ describe('@gl Test splom select:', function() {
918
919
}
919
920
920
921
it ( 'should emit correct event data and draw selection outlines' , function ( done ) {
921
- var fig = require ( '@mocks/splom_0.json' ) ;
922
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/splom_0.json' ) ) ;
922
923
fig . layout = {
923
924
dragmode : 'select' ,
924
925
width : 400 ,
@@ -1039,4 +1040,105 @@ describe('@gl Test splom select:', function() {
1039
1040
. catch ( failTest )
1040
1041
. then ( done ) ;
1041
1042
} ) ;
1043
+
1044
+ it ( 'should behave correctly during select->dblclick->pan scenarios' , function ( done ) {
1045
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/splom_0.json' ) ) ;
1046
+ fig . layout = {
1047
+ width : 400 ,
1048
+ height : 400 ,
1049
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 } ,
1050
+ grid : { xgap : 0 , ygap : 0 }
1051
+ } ;
1052
+
1053
+ var scene ;
1054
+
1055
+ function _assert ( msg , exp ) {
1056
+ expect ( scene . matrix . update ) . toHaveBeenCalledTimes ( exp . updateCnt , 'update cnt' ) ;
1057
+ expect ( scene . matrix . draw ) . toHaveBeenCalledTimes ( exp . drawCnt , 'draw cnt' ) ;
1058
+
1059
+ expect ( scene . matrix . traces . length ) . toBe ( exp . matrixTraces , '# of regl-splom traces' ) ;
1060
+ expect ( scene . selectBatch ) . toEqual ( exp . selectBatch , 'selectBatch' ) ;
1061
+ expect ( scene . unselectBatch ) . toEqual ( exp . unselectBatch , 'unselectBatch' ) ;
1062
+
1063
+ scene . matrix . update . calls . reset ( ) ;
1064
+ scene . matrix . draw . calls . reset ( ) ;
1065
+ }
1066
+
1067
+ Plotly . plot ( gd , fig ) . then ( function ( ) {
1068
+ scene = gd . calcdata [ 0 ] [ 0 ] . t . _scene ;
1069
+ spyOn ( scene . matrix , 'update' ) . and . callThrough ( ) ;
1070
+ spyOn ( scene . matrix , 'draw' ) . and . callThrough ( ) ;
1071
+ } )
1072
+ . then ( function ( ) {
1073
+ _assert ( 'base' , {
1074
+ updateCnt : 0 ,
1075
+ drawCnt : 0 ,
1076
+ matrixTraces : 1 ,
1077
+ selectBatch : null ,
1078
+ unselectBatch : null
1079
+ } ) ;
1080
+ } )
1081
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'select' ) ; } )
1082
+ . then ( function ( ) {
1083
+ _assert ( 'under dragmode:select' , {
1084
+ updateCnt : 3 , // updates positions, viewport and style in 3 calls
1085
+ drawCnt : 1 , // results in a 'plot' edit
1086
+ matrixTraces : 2 ,
1087
+ selectBatch : [ ] ,
1088
+ unselectBatch : [ ]
1089
+ } ) ;
1090
+ } )
1091
+ . then ( function ( ) { return _select ( [ [ 5 , 5 ] , [ 100 , 100 ] ] ) ; } )
1092
+ . then ( function ( ) {
1093
+ _assert ( 'after selection' , {
1094
+ updateCnt : 0 ,
1095
+ drawCnt : 1 ,
1096
+ matrixTraces : 2 ,
1097
+ selectBatch : [ 1 ] ,
1098
+ unselectBatch : [ 0 , 2 ]
1099
+ } ) ;
1100
+ } )
1101
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ; } )
1102
+ . then ( function ( ) {
1103
+ _assert ( 'under dragmode:pan with active selection' , {
1104
+ updateCnt : 0 ,
1105
+ drawCnt : 0 , // nothing here, this is a 'modebar' edit
1106
+ matrixTraces : 2 ,
1107
+ selectBatch : [ 1 ] ,
1108
+ unselectBatch : [ 0 , 2 ]
1109
+ } ) ;
1110
+ } )
1111
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'select' ) ; } )
1112
+ . then ( function ( ) {
1113
+ _assert ( 'back dragmode:select' , {
1114
+ updateCnt : 3 ,
1115
+ drawCnt : 1 , // a 'plot' edit (again)
1116
+ matrixTraces : 2 ,
1117
+ selectBatch : [ 1 ] ,
1118
+ unselectBatch : [ 0 , 2 ]
1119
+ } ) ;
1120
+ } )
1121
+ . then ( function ( ) { return doubleClick ( 100 , 100 ) ; } )
1122
+ . then ( function ( ) {
1123
+ _assert ( 'after dblclick clearing selection' , {
1124
+ updateCnt : 0 ,
1125
+ drawCnt : 1 ,
1126
+ matrixTraces : 2 ,
1127
+ selectBatch : null ,
1128
+ unselectBatch : [ ]
1129
+ } ) ;
1130
+ } )
1131
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ; } )
1132
+ . then ( function ( ) {
1133
+ _assert ( 'under dragmode:pan with NO active selection' , {
1134
+ updateCnt : 1 , // to clear off 1 matrixTrace
1135
+ drawCnt : 0 ,
1136
+ matrixTraces : 1 , // N.B. back to '1' here
1137
+ selectBatch : null ,
1138
+ unselectBatch : [ ]
1139
+ } ) ;
1140
+ } )
1141
+ . catch ( failTest )
1142
+ . then ( done ) ;
1143
+ } ) ;
1042
1144
} ) ;
0 commit comments