Skip to content

Commit 3999cf5

Browse files
committed
Remove WaitForCommandRequestComplete from hover tests, use CheckNoCommandRequest instead
1 parent 701319a commit 3999cf5

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

test/hover.test.vim

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
function! s:WaitForCommandRequestComplete()
2-
return youcompleteme#test#commands#WaitForCommandRequestComplete()
3-
endfunction
4-
51
function! s:CheckNoCommandRequest()
62
return youcompleteme#test#commands#CheckNoCommandRequest()
73
endfunction
@@ -19,7 +15,7 @@ function! s:CheckPopupVisibleScreenPos( loc, text, syntax )
1915
" has 'text' (a list of lines) and 'syntax' the &syntax setting
2016
" popup found at that location
2117
redraw
22-
call s:WaitForCommandRequestComplete()
18+
call s:CheckNoCommandRequest()
2319
call WaitForAssert( { ->
2420
\ assert_notequal( 0,
2521
\ popup_locate( a:loc.row, a:loc.col ),
@@ -37,25 +33,21 @@ function! s:CheckPopupVisibleScreenPos( loc, text, syntax )
3733
call assert_equal( a:syntax, getbufvar( winbufnr( popup ), '&syntax' ) )
3834
endfunction
3935

40-
function! s:CheckPopupNotVisible( row, col, with_request=v:true )
36+
function! s:CheckPopupNotVisible( row, col )
4137
" Takes a buffer position and ensures there is no popup visible at that
4238
" position. Like CheckPopupVisible, the position must be valid (i.e. there
4339
" must be buffer text at that position). Otherwise, you need to pass the
4440
" _screen_ position to CheckPopupNotVisibleScreenPos
4541
redraw
4642
let loc = screenpos( win_getid(), a:row, a:col )
47-
return s:CheckPopupNotVisibleScreenPos( loc, a:with_request )
43+
return s:CheckPopupNotVisibleScreenPos( loc )
4844
endfunction
4945

50-
function! s:CheckPopupNotVisibleScreenPos( loc, with_request=v:true )
46+
function! s:CheckPopupNotVisibleScreenPos( loc )
5147
" Takes a position dict like the one returned by screenpos() and verifies it
5248
" does not have a popup drawn on it.
5349
redraw
54-
if a:with_request
55-
call s:WaitForCommandRequestComplete()
56-
else
57-
call s:CheckNoCommandRequest()
58-
endif
50+
call s:CheckNoCommandRequest()
5951
call WaitForAssert( { ->
6052
\ assert_equal( 0,
6153
\ popup_locate( a:loc.row, a:loc.col ) )
@@ -158,7 +150,7 @@ EOPYTHON
158150

159151
call setpos( '.', [ 0, 12, 3 ] )
160152
normal \D
161-
call s:CheckPopupNotVisible( 11, 4, v:false )
153+
call s:CheckPopupNotVisible( 11, 4 )
162154

163155
call popup_clear()
164156
endfunction
@@ -176,8 +168,8 @@ EOPYTHON
176168

177169
call assert_equal( { 'command': 'GetType', 'syntax': 'python' }, b:ycm_hover )
178170

179-
call s:CheckPopupNotVisible( 2, 1, v:none )
180-
call s:CheckPopupNotVisible( 2, 2, v:none )
171+
call s:CheckPopupNotVisible( 2, 1 )
172+
call s:CheckPopupNotVisible( 2, 2 )
181173

182174
" some doc - autocommand
183175
call setpos( '.', [ 0, 12, 3 ] )
@@ -247,7 +239,7 @@ function! Test_AutoHover_Disabled()
247239

248240
call setpos( '.', [ 0, 12, 3 ] )
249241
silent! doautocmd CursorHold
250-
call s:CheckPopupNotVisible( 11, 4, v:false )
242+
call s:CheckPopupNotVisible( 11, 4 )
251243
call assert_equal( messages_before, execute( 'messages' ) )
252244

253245
" Manual hover is still supported
@@ -258,7 +250,7 @@ function! Test_AutoHover_Disabled()
258250

259251
" Manual close hover is still supported
260252
normal \D
261-
call s:CheckPopupNotVisible( 11, 4, v:false )
253+
call s:CheckPopupNotVisible( 11, 4 )
262254
call assert_equal( messages_before, execute( 'messages' ) )
263255

264256
call popup_clear()
@@ -311,11 +303,11 @@ function! Test_Hover_Dismiss()
311303

312304
" Dismiss
313305
normal \D
314-
call s:CheckPopupNotVisible( 11, 3, v:false )
306+
call s:CheckPopupNotVisible( 11, 3 )
315307

316308
" Make sure it doesn't come back
317309
silent! doautocmd CursorHold
318-
call s:CheckPopupNotVisible( 11, 3, v:false )
310+
call s:CheckPopupNotVisible( 11, 3 )
319311

320312
" Move the cursor (again this is tricky). I couldn't find any tests in vim's
321313
" own code that trigger CursorMoved, so we just cheat. (for the record, just
@@ -351,7 +343,7 @@ function! Test_Hover_Custom_Syntax()
351343
\ 'cpp' )
352344

353345
normal \D
354-
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 9 }, v:false )
346+
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 9 } )
355347

356348
call popup_clear()
357349
endfunction
@@ -424,10 +416,10 @@ function! Test_Hover_Custom_Popup()
424416
\ s:cpp_lifetime.GetDoc,
425417
\ 'cpp' )
426418
" Check that popup's width is limited by maxwidth being passed
427-
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 20 }, v:false )
419+
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 20 } )
428420

429421
normal \D
430-
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 9 }, v:false )
422+
call s:CheckPopupNotVisibleScreenPos( { 'row': 7, 'col': 9 } )
431423

432424
call popup_clear()
433425
endfunction
@@ -446,8 +438,8 @@ function! Test_Long_Single_Line()
446438
call s:CheckPopupVisible( 36, 1, v:none, '' )
447439
call s:CheckPopupVisible( 36, &columns, v:none, '' )
448440

449-
call s:CheckPopupNotVisible( 37, 1, v:false )
450-
call s:CheckPopupNotVisible( 37, &columns, v:false )
441+
call s:CheckPopupNotVisible( 37, 1 )
442+
call s:CheckPopupNotVisible( 37, &columns )
451443

452444
" Also wrap is ON so it should cover at least 2 lines + 2 for the header/empty
453445
" line
@@ -469,16 +461,16 @@ function! Test_Long_Wrapped()
469461
call s:CheckPopupVisible( 37, 1, v:none, '' )
470462
call s:CheckPopupVisible( 37, &columns, v:none, '' )
471463

472-
call s:CheckPopupNotVisible( 38, 1, v:false )
473-
call s:CheckPopupNotVisible( 38, &columns, v:false )
464+
call s:CheckPopupNotVisible( 38, 1 )
465+
call s:CheckPopupNotVisible( 38, &columns )
474466

475467
" Also, wrap is off, so it should be _exactly_ 9 lines + 2 for the signature
476468
" and the empty line
477469
call s:CheckPopupVisible( 27, 1, v:none, '' )
478470
call s:CheckPopupVisible( 27, &columns, v:none, '' )
479471

480-
call s:CheckPopupNotVisible( 26, 1, v:false )
481-
call s:CheckPopupNotVisible( 26, &columns, v:false )
472+
call s:CheckPopupNotVisible( 26, 1 )
473+
call s:CheckPopupNotVisible( 26, &columns )
482474

483475
call popup_clear()
484476
endfunction

test/lib/autoload/youcompleteme/test/commands.vim

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
function! youcompleteme#test#commands#WaitForCommandRequestComplete() abort
2-
call WaitForAssert( { ->
3-
\ assert_true( py3eval(
4-
\ 'ycm_state.GetCommandRequest( '
5-
\ . ' ycm_state._next_command_request_id - 1 ) is not None and '
6-
\ . 'ycm_state.GetCommandRequest( '
7-
\ . ' ycm_state._next_command_request_id - 1 ).Done()' ) )
8-
\ } )
9-
10-
call WaitForAssert( { ->
11-
\ assert_equal( -1,
12-
\ youcompleteme#Test_GetPollers().command.id )
13-
\ } )
14-
endfunction
15-
161
function! youcompleteme#test#commands#CheckNoCommandRequest() abort
172
call WaitForAssert( { ->
183
\ assert_true( py3eval(

0 commit comments

Comments
 (0)