1" 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 call writefile([], "Xnetbeans") 23 call writefile(repeat(['abcdefghijklmnopqrstuvwxyz'], 5), "XREADME.txt") 24 exe 'nbstart :localhost:' . a:port . ':bunny' 25 call assert_true(has("netbeans_enabled")) 26 27 call WaitFor('len(readfile("Xnetbeans")) > 2') 28 split +$ XREADME.txt 29 30 " Opening XREADME.txt will result in a setDot command 31 call WaitFor('len(readfile("Xnetbeans")) > 4') 32 call WaitFor('getcurpos()[1] == 3') 33 let pos = getcurpos() 34 call assert_equal(3, pos[1]) 35 call assert_equal(20, pos[2]) 36 close 37 nbclose 38 39 call WaitFor('len(readfile("Xnetbeans")) > 6') 40 call assert_false(has("netbeans_enabled")) 41 let lines = readfile("Xnetbeans") 42 call assert_equal('AUTH bunny', lines[0]) 43 call assert_equal('0:version=0 "2.5"', lines[1]) 44 call assert_equal('0:startupDone=0', lines[2]) 45 call assert_equal('0:fileOpened=0 "XREADME.txt" T F', substitute(lines[3], '".*/', '"', '')) 46 47 call assert_equal('0:disconnect=1', lines[6]) 48 49 call delete("Xnetbeans") 50 call delete("XREADME.txt") 51endfunc 52 53func Test_nb_basic() 54 call ch_log('Test_nb_basic') 55 call s:run_server('Nb_basic') 56endfunc 57 58func Nb_file_auth(port) 59 call delete("Xnetbeans") 60 call writefile([], "Xnetbeans") 61 62 call assert_fails('nbstart =notexist', 'E660:') 63 call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth') 64 if has('unix') 65 call setfperm('Xnbauth', "rw-r--r--") 66 call assert_fails('nbstart =Xnbauth', 'E668:') 67 endif 68 call setfperm('Xnbauth', "rw-------") 69 exe 'nbstart =Xnbauth' 70 call assert_true(has("netbeans_enabled")) 71 72 call WaitFor('len(readfile("Xnetbeans")) > 2') 73 nbclose 74 let lines = readfile("Xnetbeans") 75 call assert_equal('AUTH bunny', lines[0]) 76 call assert_equal('0:version=0 "2.5"', lines[1]) 77 call assert_equal('0:startupDone=0', lines[2]) 78 79 call delete("Xnbauth") 80 call delete("Xnetbeans") 81endfunc 82 83func Test_nb_file_auth() 84 call ch_log('Test_nb_file_auth') 85 call s:run_server('Nb_file_auth') 86endfunc 87