blob: d4791683896764e421dbe724ad570a42faadcb3e [file] [log] [blame]
Bram Moolenaar321efdd2016-07-15 17:09:11 +02001" Test the netbeans interface.
2
3if !has('netbeans_intg')
4 finish
5endif
6
7source shared.vim
8
9let s:python = PythonProg()
10if s:python == ''
11 " Can't run this test.
12 finish
13endif
14
15" Run "testfunc" after sarting the server and stop the server afterwards.
16func s:run_server(testfunc, ...)
17 call RunServer('test_netbeans.py', a:testfunc, a:000)
18endfunc
19
20func Nb_basic(port)
21 call delete("Xnetbeans")
22 exe 'nbstart :localhost:' . a:port . ':bunny'
23 call assert_true(has("netbeans_enabled"))
24
25 call WaitFor('len(readfile("Xnetbeans")) > 2')
26 split +$ Makefile
27
28 " Opening Makefile will result in a setDot command
29 call WaitFor('len(readfile("Xnetbeans")) > 4')
30 let pos = getcurpos()
31 call assert_equal(2, pos[1])
32 call assert_equal(20, pos[2])
33 close
34 nbclose
35
36 call WaitFor('len(readfile("Xnetbeans")) > 6')
37 let lines = readfile("Xnetbeans")
38 call assert_equal('AUTH bunny', lines[0])
39 call assert_equal('0:version=0 "2.5"', lines[1])
40 call assert_equal('0:startupDone=0', lines[2])
41 call assert_equal('0:fileOpened=0 "Makefile" T F', substitute(lines[3], '".*/', '"', ''))
42
43 call assert_equal('0:disconnect=1', lines[6])
44
45 call delete("Xnetbeans")
46endfunc
47
48func Test_nb_basic()
49 call ch_log('Test_nb_basic')
50 call s:run_server('Nb_basic')
51endfunc
Bram Moolenaar603d6572016-07-15 17:41:56 +020052
53func Nb_file_auth(port)
54 call assert_fails('nbstart =notexist', 'E660:')
55 call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth')
56 call setfperm('Xnbauth', "rw-r--r--")
57 call assert_fails('nbstart =Xnbauth', 'E668:')
58 call setfperm('Xnbauth', "rw-------")
59 exe 'nbstart :localhost:' . a:port . ':bunny'
60 call assert_true(has("netbeans_enabled"))
61
62 call WaitFor('len(readfile("Xnetbeans")) > 2')
63 nbclose
64 let lines = readfile("Xnetbeans")
65 call assert_equal('AUTH bunny', lines[0])
66 call assert_equal('0:version=0 "2.5"', lines[1])
67 call assert_equal('0:startupDone=0', lines[2])
68
69 call delete("Xnbauth")
70 call delete("Xnetbeans")
71endfunc
72
73func Test_nb_file_auth()
74 call ch_log('Test_nb_file_auth')
75 call s:run_server('Nb_file_auth')
76endfunc