embed_spec.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local feed = helpers.feed
  4. local eq = helpers.eq
  5. local clear = helpers.clear
  6. local function test_embed(ext_linegrid)
  7. local screen
  8. local function startup(...)
  9. clear{headless=false, args={...}}
  10. -- attach immediately after startup, for early UI
  11. screen = Screen.new(60, 8)
  12. screen:attach{ext_linegrid=ext_linegrid}
  13. screen:set_default_attr_ids({
  14. [1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  15. [2] = {bold = true, foreground = Screen.colors.SeaGreen4},
  16. [3] = {bold = true, foreground = Screen.colors.Blue1},
  17. [4] = {bold = true, foreground = Screen.colors.Green},
  18. })
  19. end
  20. it('can display errors', function()
  21. startup('--cmd', 'echoerr invalid+')
  22. screen:expect([[
  23. |
  24. |
  25. |
  26. |
  27. |
  28. Error detected while processing pre-vimrc command line: |
  29. E121: Undefined variable: invalid |
  30. Press ENTER or type command to continue^ |
  31. ]])
  32. feed('<cr>')
  33. screen:expect([[
  34. ^ |
  35. {3:~ }|
  36. {3:~ }|
  37. {3:~ }|
  38. {3:~ }|
  39. {3:~ }|
  40. {3:~ }|
  41. |
  42. ]])
  43. end)
  44. it("doesn't erase output when setting color scheme", function()
  45. startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"')
  46. screen:expect([[
  47. |
  48. |
  49. |
  50. |
  51. Error detected while processing pre-vimrc command line: |
  52. foo |
  53. {1:bar} |
  54. {4:Press ENTER or type command to continue}^ |
  55. ]])
  56. end)
  57. it("doesn't erase output when setting Normal colors", function()
  58. startup('--cmd', 'echoerr "foo"', '--cmd', 'hi Normal guibg=Green', '--cmd', 'echoerr "bar"')
  59. screen:expect{grid=[[
  60. |
  61. |
  62. |
  63. |
  64. Error detected while processing pre-vimrc command line: |
  65. foo |
  66. bar |
  67. Press ENTER or type command to continue^ |
  68. ]], condition=function()
  69. eq(Screen.colors.Green, screen.default_colors.rgb_bg)
  70. end}
  71. end)
  72. end
  73. describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end)
  74. describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end)