embed_spec.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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{args_rm={'--headless'}, 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. [5] = {bold = true, reverse = true},
  19. })
  20. end
  21. it('can display errors', function()
  22. startup('--cmd', 'echoerr invalid+')
  23. screen:expect([[
  24. |
  25. |
  26. |
  27. |
  28. |
  29. Error detected while processing pre-vimrc command line: |
  30. E121: Undefined variable: invalid |
  31. Press ENTER or type command to continue^ |
  32. ]])
  33. feed('<cr>')
  34. screen:expect([[
  35. ^ |
  36. {3:~ }|
  37. {3:~ }|
  38. {3:~ }|
  39. {3:~ }|
  40. {3:~ }|
  41. {3:~ }|
  42. |
  43. ]])
  44. end)
  45. it("doesn't erase output when setting color scheme", function()
  46. if 'openbsd' == helpers.uname() then
  47. pending('FIXME #10804')
  48. end
  49. startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"')
  50. screen:expect([[
  51. |
  52. |
  53. |
  54. {5: }|
  55. Error detected while processing pre-vimrc command line: |
  56. foo |
  57. {1:bar} |
  58. {4:Press ENTER or type command to continue}^ |
  59. ]])
  60. end)
  61. it("doesn't erase output when setting Normal colors", function()
  62. startup('--cmd', 'echoerr "foo"', '--cmd', 'hi Normal guibg=Green', '--cmd', 'echoerr "bar"')
  63. screen:expect{grid=[[
  64. |
  65. |
  66. |
  67. |
  68. Error detected while processing pre-vimrc command line: |
  69. foo |
  70. bar |
  71. Press ENTER or type command to continue^ |
  72. ]], condition=function()
  73. eq(Screen.colors.Green, screen.default_colors.rgb_bg)
  74. end}
  75. end)
  76. it("set display-=msgsep before first redraw", function()
  77. startup('--cmd', 'set display-=msgsep')
  78. screen:expect{grid=[[
  79. ^ |
  80. {3:~ }|
  81. {3:~ }|
  82. {3:~ }|
  83. {3:~ }|
  84. {3:~ }|
  85. {3:~ }|
  86. |
  87. ]]}
  88. end)
  89. end
  90. describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end)
  91. describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end)