@@ -11,6 +11,8 @@ var Editor = require("../editor").Editor;
11
11
var Mode = require ( "../mode/java" ) . Mode ;
12
12
var VirtualRenderer = require ( "../virtual_renderer" ) . VirtualRenderer ;
13
13
var assert = require ( "../test/assertions" ) ;
14
+ var user = require ( "../test/user" ) ;
15
+ const { GUTTER_TOOLTIP_LEFT_OFFSET , GUTTER_TOOLTIP_TOP_OFFSET } = require ( "./default_gutter_handler" ) ;
14
16
var MouseEvent = function ( type , opts ) {
15
17
var e = document . createEvent ( "MouseEvents" ) ;
16
18
e . initMouseEvent ( / c l i c k | w h e e l / . test ( type ) ? type : "mouse" + type ,
@@ -36,8 +38,7 @@ module.exports = {
36
38
editor = this . editor ;
37
39
next ( ) ;
38
40
} ,
39
-
40
- "test: gutter error tooltip" : function ( ) {
41
+ "test: gutter error tooltip" : function ( done ) {
41
42
var editor = this . editor ;
42
43
var value = "" ;
43
44
@@ -56,11 +57,12 @@ module.exports = {
56
57
// Wait for the tooltip to appear after its timeout.
57
58
setTimeout ( function ( ) {
58
59
editor . renderer . $loop . _flush ( ) ;
59
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
60
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
60
61
assert . ok ( / e r r o r t e s t / . test ( tooltip . textContent ) ) ;
61
- } , 100 ) ;
62
+ done ( ) ;
63
+ } , 100 ) ;
62
64
} ,
63
- "test: gutter security tooltip" : function ( ) {
65
+ "test: gutter security tooltip" : function ( done ) {
64
66
var editor = this . editor ;
65
67
var value = "" ;
66
68
@@ -79,11 +81,12 @@ module.exports = {
79
81
// Wait for the tooltip to appear after its timeout.
80
82
setTimeout ( function ( ) {
81
83
editor . renderer . $loop . _flush ( ) ;
82
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
84
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
83
85
assert . ok ( / s e c u r i t y f i n d i n g t e s t / . test ( tooltip . textContent ) ) ;
84
- } , 100 ) ;
86
+ done ( ) ;
87
+ } , 100 ) ;
85
88
} ,
86
- "test: gutter warning tooltip" : function ( ) {
89
+ "test: gutter warning tooltip" : function ( done ) {
87
90
var editor = this . editor ;
88
91
var value = "" ;
89
92
@@ -102,11 +105,12 @@ module.exports = {
102
105
// Wait for the tooltip to appear after its timeout.
103
106
setTimeout ( function ( ) {
104
107
editor . renderer . $loop . _flush ( ) ;
105
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
108
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
106
109
assert . ok ( / w a r n i n g t e s t / . test ( tooltip . textContent ) ) ;
107
- } , 100 ) ;
110
+ done ( ) ;
111
+ } , 100 ) ;
108
112
} ,
109
- "test: gutter info tooltip" : function ( ) {
113
+ "test: gutter info tooltip" : function ( done ) {
110
114
var editor = this . editor ;
111
115
var value = "" ;
112
116
@@ -125,11 +129,12 @@ module.exports = {
125
129
// Wait for the tooltip to appear after its timeout.
126
130
setTimeout ( function ( ) {
127
131
editor . renderer . $loop . _flush ( ) ;
128
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
132
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
129
133
assert . ok ( / i n f o t e s t / . test ( tooltip . textContent ) ) ;
130
- } , 100 ) ;
134
+ done ( ) ;
135
+ } , 100 ) ;
131
136
} ,
132
- "test: gutter hint tooltip" : function ( ) {
137
+ "test: gutter hint tooltip" : function ( done ) {
133
138
var editor = this . editor ;
134
139
var value = "" ;
135
140
@@ -148,9 +153,10 @@ module.exports = {
148
153
// Wait for the tooltip to appear after its timeout.
149
154
setTimeout ( function ( ) {
150
155
editor . renderer . $loop . _flush ( ) ;
151
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
156
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
152
157
assert . ok ( / s u g g e s t i o n t e s t / . test ( tooltip . textContent ) ) ;
153
- } , 100 ) ;
158
+ done ( ) ;
159
+ } , 100 ) ;
154
160
} ,
155
161
"test: gutter svg icons" : function ( ) {
156
162
var editor = this . editor ;
@@ -169,7 +175,7 @@ module.exports = {
169
175
var annotation = line . children [ 2 ] . firstChild ;
170
176
assert . ok ( / a c e _ i c o n _ s v g / . test ( annotation . className ) ) ;
171
177
} ,
172
- "test: error show up in fold" : function ( ) {
178
+ "test: error show up in fold" : function ( done ) {
173
179
var editor = this . editor ;
174
180
var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
175
181
value = value . repeat ( 50 ) ;
@@ -200,11 +206,12 @@ module.exports = {
200
206
// Wait for the tooltip to appear after its timeout.
201
207
setTimeout ( function ( ) {
202
208
editor . renderer . $loop . _flush ( ) ;
203
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
209
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
204
210
assert . ok ( / e r r o r i n f o l d e d / . test ( tooltip . textContent ) ) ;
205
- } , 100 ) ;
211
+ done ( ) ;
212
+ } , 50 ) ;
206
213
} ,
207
- "test: security show up in fold" : function ( ) {
214
+ "test: security show up in fold" : function ( done ) {
208
215
var editor = this . editor ;
209
216
var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
210
217
value = value . repeat ( 50 ) ;
@@ -235,11 +242,12 @@ module.exports = {
235
242
// Wait for the tooltip to appear after its timeout.
236
243
setTimeout ( function ( ) {
237
244
editor . renderer . $loop . _flush ( ) ;
238
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
245
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
239
246
assert . ok ( / s e c u r i t y f i n d i n g i n f o l d e d / . test ( tooltip . textContent ) ) ;
240
- } , 100 ) ;
247
+ done ( ) ;
248
+ } , 100 ) ;
241
249
} ,
242
- "test: warning show up in fold" : function ( ) {
250
+ "test: warning show up in fold" : function ( done ) {
243
251
var editor = this . editor ;
244
252
var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
245
253
value = value . repeat ( 50 ) ;
@@ -270,9 +278,10 @@ module.exports = {
270
278
// Wait for the tooltip to appear after its timeout.
271
279
setTimeout ( function ( ) {
272
280
editor . renderer . $loop . _flush ( ) ;
273
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
281
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
274
282
assert . ok ( / w a r n i n g i n f o l d e d / . test ( tooltip . textContent ) ) ;
275
- } , 100 ) ;
283
+ done ( ) ;
284
+ } , 100 ) ;
276
285
} ,
277
286
"test: info not show up in fold" : function ( ) {
278
287
var editor = this . editor ;
@@ -396,12 +405,12 @@ module.exports = {
396
405
// Wait for the tooltip to appear after its timeout.
397
406
setTimeout ( function ( ) {
398
407
editor . renderer . $loop . _flush ( ) ;
399
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
408
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
400
409
assert . ok ( / e r r o r t e s t / . test ( tooltip . textContent ) ) ;
401
- assert . equal ( tooltip . style . left , `${ rect . right } px` ) ;
402
- assert . equal ( tooltip . style . top , `${ rect . bottom } px` ) ;
410
+ assert . equal ( tooltip . style . left , `${ rect . right - GUTTER_TOOLTIP_LEFT_OFFSET } px` ) ;
411
+ assert . equal ( tooltip . style . top , `${ rect . bottom - GUTTER_TOOLTIP_TOP_OFFSET } px` ) ;
403
412
done ( ) ;
404
- } , 100 ) ;
413
+ } , 100 ) ;
405
414
} ,
406
415
"test: gutter tooltip should properly display special characters (\" ' & <)" : function ( done ) {
407
416
var editor = this . editor ;
@@ -422,12 +431,43 @@ module.exports = {
422
431
// Wait for the tooltip to appear after its timeout.
423
432
setTimeout ( function ( ) {
424
433
editor . renderer . $loop . _flush ( ) ;
425
- var tooltip = editor . container . querySelector ( ".ace_tooltip " ) ;
434
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip " ) ;
426
435
assert . ok ( / s p e c i a l c h a r a c t e r s " ' & < / . test ( tooltip . textContent ) ) ;
427
436
done ( ) ;
428
- } , 100 ) ;
437
+ } , 100 ) ;
438
+ } ,
439
+ "test: gutter hover tooltip should remain open when pressing ctrl key combination" : function ( done ) {
440
+ var editor = this . editor ;
441
+ var value = "" ;
442
+
443
+ editor . session . setMode ( new Mode ( ) ) ;
444
+ editor . setValue ( value , - 1 ) ;
445
+ editor . session . setAnnotations ( [ { row : 0 , column : 0 , text : "error test" , type : "error" } ] ) ;
446
+ editor . renderer . $loop . _flush ( ) ;
447
+
448
+ var lines = editor . renderer . $gutterLayer . $lines ;
449
+ var annotation = lines . cells [ 0 ] . element ;
450
+ assert . ok ( / a c e _ e r r o r / . test ( annotation . className ) ) ;
451
+
452
+ var rect = annotation . getBoundingClientRect ( ) ;
453
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
454
+
455
+ // Wait for the tooltip to appear after its timeout.
456
+ setTimeout ( function ( ) {
457
+ editor . renderer . $loop . _flush ( ) ;
458
+ var tooltip = editor . container . querySelector ( ".ace_gutter-tooltip" ) ;
459
+ assert . ok ( / e r r o r t e s t / . test ( tooltip . textContent ) ) ;
460
+ user . type ( "Ctrl-C" ) ;
461
+ tooltip = editor . container . querySelector ( ".ace_gutter-tooltip" ) ;
462
+ assert . ok ( / e r r o r t e s t / . test ( tooltip . textContent ) ) ;
463
+ // also verify if it closes when presses another key
464
+ user . type ( "Escape" ) ;
465
+ tooltip = editor . container . querySelector ( ".ace_gutter-tooltip" ) ;
466
+ assert . strictEqual ( tooltip , undefined ) ;
467
+ done ( ) ;
468
+ } , 100 ) ;
429
469
} ,
430
-
470
+
431
471
tearDown : function ( ) {
432
472
this . editor . destroy ( ) ;
433
473
document . body . removeChild ( this . editor . container ) ;
0 commit comments