annotate src/testdir/test_sound.vim @ 29163:9288c636ffa5 v8.2.5101

patch 8.2.5101: MS-Windows with MinGW: $CC may be "cc" instead of "gcc" Commit: https://github.com/vim/vim/commit/cf65d88ff844f042337dfd043e6e98f3b9270577 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jun 15 18:31:45 2022 +0100 patch 8.2.5101: MS-Windows with MinGW: $CC may be "cc" instead of "gcc" Problem: MS-Windows with MinGW: $CC may be "cc" instead of "gcc". Solution: Set $CC if it is not matching "clang". (Yegappan Lakshmanan, closes #10578)
author Bram Moolenaar <Bram@vim.org>
date Wed, 15 Jun 2022 19:45:04 +0200
parents 237dace53473
children 71137f73c94d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for the sound feature
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
3 source check.vim
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
4 source shared.vim
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
5
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
6 CheckFeature sound
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 func PlayCallback(id, result)
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
9 let g:playcallback_count += 1
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 let g:id = a:id
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 let g:result = a:result
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 endfunc
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 func Test_play_event()
17131
be5a5cfc991a patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
15 if has('win32')
be5a5cfc991a patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
16 throw 'Skipped: Playing event with callback is not supported on Windows'
be5a5cfc991a patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
17 endif
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
18 let g:playcallback_count = 0
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
19 let g:id = 0
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
20 let id = 'bell'->sound_playevent('PlayCallback')
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 if id == 0
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 throw 'Skipped: bell event not available'
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 endif
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
24
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 " Stop it quickly, avoid annoying the user.
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 sleep 20m
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
27 eval id->sound_stop()
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
28 call WaitForAssert({-> assert_equal(id, g:id)})
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call assert_equal(1, g:result) " sound was aborted
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
30 call assert_equal(1, g:playcallback_count)
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 endfunc
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 func Test_play_silent()
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 let fname = fnamemodify('silent.wav', '%p')
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
35 let g:playcallback_count = 0
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 " play without callback
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 let id1 = sound_playfile(fname)
17016
b99b33f8475b patch 8.1.1508: sound keeps failing on Travis
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
39 if id1 == 0
b99b33f8475b patch 8.1.1508: sound keeps failing on Travis
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
40 throw 'Skipped: playing a sound is not working'
b99b33f8475b patch 8.1.1508: sound keeps failing on Travis
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
41 endif
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 " play until the end
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
44 let id2 = fname->sound_playfile('PlayCallback')
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call assert_true(id2 > 0)
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
46 call WaitForAssert({-> assert_equal(id2, g:id)})
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call assert_equal(0, g:result)
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
48 call assert_equal(1, g:playcallback_count)
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 let id2 = sound_playfile(fname, 'PlayCallback')
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 call assert_true(id2 > 0)
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 sleep 20m
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17016
diff changeset
53 call sound_clear()
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
54 call WaitForAssert({-> assert_equal(id2, g:id)})
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
55 call assert_equal(1, g:result) " sound was aborted
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
56 call assert_equal(2, g:playcallback_count)
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
57
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
58 " Play 2 sounds almost at the same time to exercise
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
59 " code with multiple callbacks in the callback list.
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
60 call sound_playfile(fname, 'PlayCallback')
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
61 call sound_playfile(fname, 'PlayCallback')
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
62 call WaitForAssert({-> assert_equal(4, g:playcallback_count)})
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
63
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
64 " recursive use was causing a crash
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
65 func PlayAgain(id, fname)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
66 let g:id = a:id
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
67 let g:id_again = sound_playfile(a:fname)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
68 endfunc
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
69
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
70 let id3 = sound_playfile(fname, {id, res -> PlayAgain(id, fname)})
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
71 call assert_true(id3 > 0)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
72 sleep 50m
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
73 call sound_clear()
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
74 call WaitForAssert({-> assert_true(g:id > 0)})
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
76
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
77 func Test_play_event_error()
24842
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
78 " FIXME: sound_playevent() doesn't return 0 in case of error on Windows.
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
79 if !has('win32')
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
80 call assert_equal(0, sound_playevent(''))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
81 call assert_equal(0, sound_playevent(test_null_string()))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
82 call assert_equal(0, sound_playevent('doesnotexist'))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
83 call assert_equal(0, sound_playevent('doesnotexist', 'doesnotexist'))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
84 call assert_equal(0, sound_playevent(test_null_string(), test_null_string()))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
85 call assert_equal(0, sound_playevent(test_null_string(), test_null_function()))
237dace53473 patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 24824
diff changeset
86 endif
24824
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
87
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
88 call assert_equal(0, sound_playfile(''))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
89 call assert_equal(0, sound_playfile(test_null_string()))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
90 call assert_equal(0, sound_playfile('doesnotexist'))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
91 call assert_equal(0, sound_playfile('doesnotexist', 'doesnotexist'))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
92 call assert_equal(0, sound_playfile(test_null_string(), test_null_string()))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
93 call assert_equal(0, sound_playfile(test_null_string(), test_null_function()))
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
94 endfunc
a9ffc9154b32 patch 8.2.2950: sound code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 23118
diff changeset
95
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
96 " vim: shiftwidth=2 sts=2 expandtab