completion.vim 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function! CheckCompletionItems( expected_props, ... )
  2. let prop = 'abbr'
  3. if a:0 > 0
  4. let prop = a:1
  5. endif
  6. let items = complete_info( [ 'items' ] )[ 'items' ]
  7. let abbrs = []
  8. for item in items
  9. call add( abbrs, get( item, prop ) )
  10. endfor
  11. call assert_equal( a:expected_props,
  12. \ abbrs,
  13. \ 'not matched: '
  14. \ .. string( a:expected_props )
  15. \ .. ' against '
  16. \ .. prop
  17. \ .. ' in '
  18. \ .. string( items )
  19. \ .. ' matching '
  20. \ .. string( abbrs ) )
  21. endfunction
  22. function! FeedAndCheckMain( keys, func )
  23. call timer_start( 500, a:func )
  24. call feedkeys( a:keys, 'tx!' )
  25. endfunction
  26. function! FeedAndCheckAgain( keys, func )
  27. call timer_start( 500, a:func )
  28. call feedkeys( a:keys )
  29. endfunction
  30. function! WaitForCompletion()
  31. call WaitForAssert( {->
  32. \ assert_true( pyxeval( 'ycm_state.GetCurrentCompletionRequest() is not None' ) )
  33. \ } )
  34. call WaitForAssert( {->
  35. \ assert_true( pyxeval( 'ycm_state.CompletionRequestReady()' ) )
  36. \ } )
  37. redraw
  38. call WaitForAssert( {->
  39. \ assert_true( pumvisible(), 'pumvisible()' )
  40. \ }, 10000 )
  41. endfunction