Bram Moolenaar | 321efdd | 2016-07-15 17:09:11 +0200 | [diff] [blame] | 1 | " Test the netbeans interface. |
| 2 | |
| 3 | if !has('netbeans_intg') |
| 4 | finish |
| 5 | endif |
| 6 | |
| 7 | source shared.vim |
| 8 | |
| 9 | let s:python = PythonProg() |
| 10 | if s:python == '' |
| 11 | " Can't run this test. |
| 12 | finish |
| 13 | endif |
| 14 | |
| 15 | " Run "testfunc" after sarting the server and stop the server afterwards. |
| 16 | func s:run_server(testfunc, ...) |
| 17 | call RunServer('test_netbeans.py', a:testfunc, a:000) |
| 18 | endfunc |
| 19 | |
| 20 | func 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') |
Bram Moolenaar | adfc5c2 | 2016-07-27 22:56:48 +0200 | [diff] [blame] | 30 | call WaitFor('getcurpos()[1] == 2') |
Bram Moolenaar | 321efdd | 2016-07-15 17:09:11 +0200 | [diff] [blame] | 31 | let pos = getcurpos() |
| 32 | call assert_equal(2, pos[1]) |
| 33 | call assert_equal(20, pos[2]) |
| 34 | close |
| 35 | nbclose |
| 36 | |
| 37 | call WaitFor('len(readfile("Xnetbeans")) > 6') |
| 38 | let lines = readfile("Xnetbeans") |
| 39 | call assert_equal('AUTH bunny', lines[0]) |
| 40 | call assert_equal('0:version=0 "2.5"', lines[1]) |
| 41 | call assert_equal('0:startupDone=0', lines[2]) |
| 42 | call assert_equal('0:fileOpened=0 "Makefile" T F', substitute(lines[3], '".*/', '"', '')) |
| 43 | |
| 44 | call assert_equal('0:disconnect=1', lines[6]) |
| 45 | |
| 46 | call delete("Xnetbeans") |
| 47 | endfunc |
| 48 | |
| 49 | func Test_nb_basic() |
| 50 | call ch_log('Test_nb_basic') |
| 51 | call s:run_server('Nb_basic') |
| 52 | endfunc |
Bram Moolenaar | 603d657 | 2016-07-15 17:41:56 +0200 | [diff] [blame] | 53 | |
| 54 | func Nb_file_auth(port) |
| 55 | call assert_fails('nbstart =notexist', 'E660:') |
| 56 | call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth') |
Bram Moolenaar | 53bdec2 | 2016-07-20 00:03:18 +0200 | [diff] [blame] | 57 | if has('unix') |
| 58 | call setfperm('Xnbauth', "rw-r--r--") |
| 59 | call assert_fails('nbstart =Xnbauth', 'E668:') |
| 60 | endif |
Bram Moolenaar | 603d657 | 2016-07-15 17:41:56 +0200 | [diff] [blame] | 61 | call setfperm('Xnbauth', "rw-------") |
| 62 | exe 'nbstart :localhost:' . a:port . ':bunny' |
| 63 | call assert_true(has("netbeans_enabled")) |
| 64 | |
| 65 | call WaitFor('len(readfile("Xnetbeans")) > 2') |
| 66 | nbclose |
| 67 | let lines = readfile("Xnetbeans") |
| 68 | call assert_equal('AUTH bunny', lines[0]) |
| 69 | call assert_equal('0:version=0 "2.5"', lines[1]) |
| 70 | call assert_equal('0:startupDone=0', lines[2]) |
| 71 | |
| 72 | call delete("Xnbauth") |
| 73 | call delete("Xnetbeans") |
| 74 | endfunc |
| 75 | |
| 76 | func Test_nb_file_auth() |
| 77 | call ch_log('Test_nb_file_auth') |
| 78 | call s:run_server('Nb_file_auth') |
| 79 | endfunc |