Mercurial > vim
annotate src/testdir/test_sound.vim @ 19501:f872daa2031b v8.2.0308
patch 8.2.0308: 'showbreak' does not work for a very long line
Commit: https://github.com/vim/vim/commit/1aa76b8fd06c278fe36c39b0bbe7233c775d7423
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 23 15:17:27 2020 +0100
patch 8.2.0308: 'showbreak' does not work for a very long line
Problem: 'showbreak' does not work for a very long line. (John Little)
Solution: Check whether 'briopt' contains "sbr". (Ken Takata, closes https://github.com/vim/vim/issues/5523,
closes #5684)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 23 Feb 2020 15:30:03 +0100 |
parents | 988e5a868b60 |
children | 08940efa6b4e |
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 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 if !has('sound') |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 throw 'Skipped: sound feature not available' |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 endif |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 func PlayCallback(id, result) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 let g:id = a:id |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 let g:result = a:result |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 endfunc |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 func Test_play_event() |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
13 if has('win32') |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
14 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
|
15 endif |
18017
988e5a868b60
patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
16 let id = 'bell'->sound_playevent('PlayCallback') |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 if id == 0 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 throw 'Skipped: bell event not available' |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 endif |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 " Stop it quickly, avoid annoying the user. |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 sleep 20m |
18017
988e5a868b60
patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
22 eval id->sound_stop() |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17131
diff
changeset
|
23 sleep 30m |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 call assert_equal(id, g:id) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 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
|
26 endfunc |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 func Test_play_silent() |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 let fname = fnamemodify('silent.wav', '%p') |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 " play without callback |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 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
|
33 if id1 == 0 |
b99b33f8475b
patch 8.1.1508: sound keeps failing on Travis
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
34 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
|
35 endif |
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 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
|
38 let id2 = fname->sound_playfile('PlayCallback') |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 call assert_true(id2 > 0) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 sleep 500m |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 call assert_equal(id2, g:id) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 call assert_equal(0, g:result) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 let id2 = sound_playfile(fname, 'PlayCallback') |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 call assert_true(id2 > 0) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 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
|
47 call sound_clear() |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17131
diff
changeset
|
48 sleep 30m |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 call assert_equal(id2, g:id) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 call assert_equal(1, g:result) |
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() |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17131
diff
changeset
|
62 sleep 30m |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17131
diff
changeset
|
63 call assert_true(g:id_again > 0) |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 endfunc |