blob: e47c677e99f6608a97605c7bd5b4e88dcef99c4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
" Tests for the sound feature
if !has('sound')
throw 'Skipped: sound feature not available'
endif
func PlayCallback(id, result)
let g:id = a:id
let g:result = a:result
endfunc
func Test_play_event()
let id = sound_playevent('bell', 'PlayCallback')
if id == 0
throw 'Skipped: bell event not available'
endif
" Stop it quickly, avoid annoying the user.
sleep 20m
call sound_stop(id)
sleep 20m
call assert_equal(id, g:id)
call assert_equal(1, g:result) " sound was aborted
endfunc
func Test_play_silent()
let fname = fnamemodify('silent.wav', '%p')
" play without callback
let id1 = sound_playfile(fname)
if id1 == 0
throw 'Skipped: playing a sound is not working'
endif
" play until the end
let id2 = sound_playfile(fname, 'PlayCallback')
call assert_true(id2 > 0)
sleep 500m
call assert_equal(id2, g:id)
call assert_equal(0, g:result)
let id2 = sound_playfile(fname, 'PlayCallback')
call assert_true(id2 > 0)
sleep 20m
call sound_stopall()
call assert_equal(id2, g:id)
call assert_equal(1, g:result)
endfunc
|