blob: 690ac673c13ff19c86ae6e99580faf7f77e9bd71 [file] [log] [blame]
Bram Moolenaar321efdd2016-07-15 17:09:11 +02001" Test the netbeans interface.
2
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02003source check.vim
4CheckFeature netbeans_intg
Bram Moolenaar321efdd2016-07-15 17:09:11 +02005
6source shared.vim
7
8let s:python = PythonProg()
9if s:python == ''
Bram Moolenaarb46fecd2019-06-15 17:58:09 +020010 throw 'Skipped: python program missing'
Bram Moolenaar321efdd2016-07-15 17:09:11 +020011endif
12
13" Run "testfunc" after sarting the server and stop the server afterwards.
14func s:run_server(testfunc, ...)
15 call RunServer('test_netbeans.py', a:testfunc, a:000)
16endfunc
17
18func Nb_basic(port)
19 call delete("Xnetbeans")
Bram Moolenaarc20e0d52017-11-02 18:19:19 +010020 call writefile([], "Xnetbeans")
Bram Moolenaar10efcd52018-11-26 21:22:07 +010021 call writefile(repeat(['abcdefghijklmnopqrstuvwxyz'], 5), "XREADME.txt")
Bram Moolenaar321efdd2016-07-15 17:09:11 +020022 exe 'nbstart :localhost:' . a:port . ':bunny'
23 call assert_true(has("netbeans_enabled"))
24
25 call WaitFor('len(readfile("Xnetbeans")) > 2')
Bram Moolenaar10efcd52018-11-26 21:22:07 +010026 split +$ XREADME.txt
Bram Moolenaar321efdd2016-07-15 17:09:11 +020027
Bram Moolenaar10efcd52018-11-26 21:22:07 +010028 " Opening XREADME.txt will result in a setDot command
Bram Moolenaar321efdd2016-07-15 17:09:11 +020029 call WaitFor('len(readfile("Xnetbeans")) > 4')
Bram Moolenaar3e1c6172017-11-02 16:58:00 +010030 call WaitFor('getcurpos()[1] == 3')
Bram Moolenaar321efdd2016-07-15 17:09:11 +020031 let pos = getcurpos()
Bram Moolenaarff330ff2016-09-09 15:31:34 +020032 call assert_equal(3, pos[1])
Bram Moolenaar321efdd2016-07-15 17:09:11 +020033 call assert_equal(20, pos[2])
34 close
35 nbclose
36
37 call WaitFor('len(readfile("Xnetbeans")) > 6')
Bram Moolenaar8ddef482016-10-09 15:43:25 +020038 call assert_false(has("netbeans_enabled"))
Bram Moolenaar321efdd2016-07-15 17:09:11 +020039 let lines = readfile("Xnetbeans")
40 call assert_equal('AUTH bunny', lines[0])
41 call assert_equal('0:version=0 "2.5"', lines[1])
42 call assert_equal('0:startupDone=0', lines[2])
Bram Moolenaar10efcd52018-11-26 21:22:07 +010043 call assert_equal('0:fileOpened=0 "XREADME.txt" T F', substitute(lines[3], '".*/', '"', ''))
Bram Moolenaar321efdd2016-07-15 17:09:11 +020044
45 call assert_equal('0:disconnect=1', lines[6])
46
47 call delete("Xnetbeans")
Bram Moolenaar10efcd52018-11-26 21:22:07 +010048 call delete("XREADME.txt")
Bram Moolenaar321efdd2016-07-15 17:09:11 +020049endfunc
50
51func Test_nb_basic()
52 call ch_log('Test_nb_basic')
53 call s:run_server('Nb_basic')
54endfunc
Bram Moolenaar603d6572016-07-15 17:41:56 +020055
56func Nb_file_auth(port)
Bram Moolenaarc20e0d52017-11-02 18:19:19 +010057 call delete("Xnetbeans")
58 call writefile([], "Xnetbeans")
59
Bram Moolenaar603d6572016-07-15 17:41:56 +020060 call assert_fails('nbstart =notexist', 'E660:')
61 call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth')
Bram Moolenaar53bdec22016-07-20 00:03:18 +020062 if has('unix')
63 call setfperm('Xnbauth', "rw-r--r--")
64 call assert_fails('nbstart =Xnbauth', 'E668:')
65 endif
Bram Moolenaar603d6572016-07-15 17:41:56 +020066 call setfperm('Xnbauth', "rw-------")
Bram Moolenaarffdf08c2016-08-27 19:52:47 +020067 exe 'nbstart =Xnbauth'
Bram Moolenaar603d6572016-07-15 17:41:56 +020068 call assert_true(has("netbeans_enabled"))
69
70 call WaitFor('len(readfile("Xnetbeans")) > 2')
71 nbclose
72 let lines = readfile("Xnetbeans")
73 call assert_equal('AUTH bunny', lines[0])
74 call assert_equal('0:version=0 "2.5"', lines[1])
75 call assert_equal('0:startupDone=0', lines[2])
76
77 call delete("Xnbauth")
78 call delete("Xnetbeans")
79endfunc
80
81func Test_nb_file_auth()
82 call ch_log('Test_nb_file_auth')
83 call s:run_server('Nb_file_auth')
84endfunc