Mercurial > vim
comparison src/testdir/test_gui.vim @ 27497:7480a2e2ca0f v8.2.4276
patch 8.2.4276: separate test function for the GUI scrollbar
Commit: https://github.com/vim/vim/commit/9e0208f51cf1354ce0a7d3988133041a78681605
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Jan 31 17:40:55 2022 +0000
patch 8.2.4276: separate test function for the GUI scrollbar
Problem: Separate test function for the GUI scrollbar.
Solution: Use test_gui_event(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9674)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 31 Jan 2022 18:45:03 +0100 |
parents | f0096e5b3df9 |
children | c6789534b255 |
comparison
equal
deleted
inserted
replaced
27496:cd5a89c0e571 | 27497:7480a2e2ca0f |
---|---|
712 " buffer with 200 lines | 712 " buffer with 200 lines |
713 call setline(1, repeat(['one', 'two'], 100)) | 713 call setline(1, repeat(['one', 'two'], 100)) |
714 set guioptions+=rlb | 714 set guioptions+=rlb |
715 | 715 |
716 " scroll to move line 11 at top, moves the cursor there | 716 " scroll to move line 11 at top, moves the cursor there |
717 eval 10->test_scrollbar('left', 0) | 717 let args = #{which: 'left', value: 10, dragging: 0} |
718 call test_gui_event('scrollbar', args) | |
718 redraw | 719 redraw |
719 call assert_equal(1, winline()) | 720 call assert_equal(1, winline()) |
720 call assert_equal(11, line('.')) | 721 call assert_equal(11, line('.')) |
721 | 722 |
722 " scroll to move line 1 at top, cursor stays in line 11 | 723 " scroll to move line 1 at top, cursor stays in line 11 |
723 call test_scrollbar('right', 0, 0) | 724 let args = #{which: 'right', value: 0, dragging: 0} |
725 call test_gui_event('scrollbar', args) | |
724 redraw | 726 redraw |
725 call assert_equal(11, winline()) | 727 call assert_equal(11, winline()) |
726 call assert_equal(11, line('.')) | 728 call assert_equal(11, line('.')) |
727 | 729 |
728 set nowrap | 730 set nowrap |
735 set nonumber | 737 set nonumber |
736 redraw | 738 redraw |
737 call assert_equal(1, col('.')) | 739 call assert_equal(1, col('.')) |
738 | 740 |
739 " scroll to character 11, cursor is moved | 741 " scroll to character 11, cursor is moved |
740 call test_scrollbar('hor', 10, 0) | 742 let args = #{which: 'hor', value: 10, dragging: 0} |
743 call test_gui_event('scrollbar', args) | |
741 redraw | 744 redraw |
742 call assert_equal(1, wincol()) | 745 call assert_equal(1, wincol()) |
743 set number | 746 set number |
744 redraw | 747 redraw |
745 call assert_equal(5, wincol()) | 748 call assert_equal(5, wincol()) |
746 set nonumber | 749 set nonumber |
747 redraw | 750 redraw |
748 call assert_equal(11, col('.')) | 751 call assert_equal(11, col('.')) |
752 | |
753 " Invalid arguments | |
754 call assert_false(test_gui_event('scrollbar', {})) | |
755 call assert_false(test_gui_event('scrollbar', #{value: 10, dragging: 0})) | |
756 call assert_false(test_gui_event('scrollbar', #{which: 'hor', dragging: 0})) | |
757 call assert_false(test_gui_event('scrollbar', #{which: 'hor', value: 1})) | |
758 call assert_fails("call test_gui_event('scrollbar', #{which: 'a', value: 1, dragging: 0})", 'E475:') | |
749 | 759 |
750 set guioptions& | 760 set guioptions& |
751 set wrap& | 761 set wrap& |
752 bwipe! | 762 bwipe! |
753 endfunc | 763 endfunc |
1344 | 1354 |
1345 " Invalid arguments | 1355 " Invalid arguments |
1346 call assert_false(test_gui_event("dropfiles", {})) | 1356 call assert_false(test_gui_event("dropfiles", {})) |
1347 let d = #{row: 1, col: 1, modifiers: 0} | 1357 let d = #{row: 1, col: 1, modifiers: 0} |
1348 call assert_false(test_gui_event("dropfiles", d)) | 1358 call assert_false(test_gui_event("dropfiles", d)) |
1359 let d = #{files: 1, row: 1, col: 1, modifiers: 0} | |
1360 call assert_false(test_gui_event("dropfiles", d)) | |
1349 let d = #{files: test_null_list(), row: 1, col: 1, modifiers: 0} | 1361 let d = #{files: test_null_list(), row: 1, col: 1, modifiers: 0} |
1350 call assert_false(test_gui_event("dropfiles", d)) | 1362 call assert_false(test_gui_event("dropfiles", d)) |
1351 let d = #{files: [test_null_string()], row: 1, col: 1, modifiers: 0} | 1363 let d = #{files: [test_null_string()], row: 1, col: 1, modifiers: 0} |
1352 call assert_true(test_gui_event("dropfiles", d)) | 1364 call assert_true(test_gui_event("dropfiles", d)) |
1353 endfunc | 1365 endfunc |
1458 " Replace all instances of a whole string with another matching case | 1470 " Replace all instances of a whole string with another matching case |
1459 call cursor(1, 1) | 1471 call cursor(1, 1) |
1460 let args = #{find_text: 'TWO', repl_text: 'two', flags: 0x1C, forward: 1} | 1472 let args = #{find_text: 'TWO', repl_text: 'two', flags: 0x1C, forward: 1} |
1461 call test_gui_event('findrepl', args) | 1473 call test_gui_event('findrepl', args) |
1462 call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$')) | 1474 call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$')) |
1475 | |
1476 " Invalid arguments | |
1477 call assert_false(test_gui_event('findrepl', {})) | |
1478 let args = #{repl_text: 'a', flags: 1, forward: 1} | |
1479 call assert_false(test_gui_event('findrepl', args)) | |
1480 let args = #{find_text: 'a', flags: 1, forward: 1} | |
1481 call assert_false(test_gui_event('findrepl', args)) | |
1482 let args = #{find_text: 'a', repl_text: 'b', forward: 1} | |
1483 call assert_false(test_gui_event('findrepl', args)) | |
1484 let args = #{find_text: 'a', repl_text: 'b', flags: 1} | |
1485 call assert_false(test_gui_event('findrepl', args)) | |
1486 | |
1463 bw! | 1487 bw! |
1464 endfunc | 1488 endfunc |
1465 | 1489 |
1466 " vim: shiftwidth=2 sts=2 expandtab | 1490 " vim: shiftwidth=2 sts=2 expandtab |