annotate src/testdir/test_sound.vim @ 24731:a6a4224902f5 v8.2.2904

patch 8.2.2904: "g$" causes scroll if half a double width char is visible Commit: https://github.com/vim/vim/commit/74ede80aeb272ac81d41a256057c4f250372dd00 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 29 19:18:01 2021 +0200 patch 8.2.2904: "g$" causes scroll if half a double width char is visible Problem: "g$" causes scroll if half a double width char is visible. Solution: Advance to the last fully visible character. (closes https://github.com/vim/vim/issues/8254)
author Bram Moolenaar <Bram@vim.org>
date Sat, 29 May 2021 19:30:03 +0200
parents 24326797a9aa
children a9ffc9154b32
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
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
3 source shared.vim
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
4
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 if !has('sound')
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 throw 'Skipped: sound feature not available'
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 endif
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 func PlayCallback(id, result)
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
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
18 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
19 let id = 'bell'->sound_playevent('PlayCallback')
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 if id == 0
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 throw 'Skipped: bell event not available'
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 endif
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 " Stop it quickly, avoid annoying the user.
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 sleep 20m
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
25 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
26 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
27 call assert_equal(1, g:result) " sound was aborted
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 endfunc
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 func Test_play_silent()
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 let fname = fnamemodify('silent.wav', '%p')
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 " play without callback
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 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
35 if id1 == 0
b99b33f8475b patch 8.1.1508: sound keeps failing on Travis
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
36 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
37 endif
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 " 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
40 let id2 = fname->sound_playfile('PlayCallback')
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 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
42 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
43 call assert_equal(0, g:result)
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let id2 = sound_playfile(fname, 'PlayCallback')
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 call assert_true(id2 > 0)
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 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
48 call sound_clear()
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
49 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
50 call assert_equal(1, g:result) " sound was aborted
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
51
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
52 " 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
53 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
54 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
55 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
56 endfunc
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
57
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
58 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
59 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
60 sleep 50m
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17131
diff changeset
61 call sound_clear()
23118
24326797a9aa patch 8.2.2105: sound test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
62 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
63 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
64
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
65 " vim: shiftwidth=2 sts=2 expandtab