summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-01-31 17:40:55 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-31 17:40:55 +0000
commit9e0208f51cf1354ce0a7d3988133041a78681605 (patch)
tree21409202f259448aaca319fc084c536656b18190
parent223a950a85448253780da4e821a5b23dcdfad28f (diff)
downloadvim-git-9e0208f51cf1354ce0a7d3988133041a78681605.tar.gz
patch 8.2.4276: separate test function for the GUI scrollbarv8.2.4276
Problem: Separate test function for the GUI scrollbar. Solution: Use test_gui_event(). (Yegappan Lakshmanan, closes #9674)
-rw-r--r--runtime/doc/builtin.txt2
-rw-r--r--runtime/doc/usr_41.txt1
-rw-r--r--src/evalfunc.c9
-rw-r--r--src/proto/testing.pro1
-rw-r--r--src/testdir/test_gui.vim30
-rw-r--r--src/testdir/test_vim9_builtin.vim7
-rw-r--r--src/testing.c83
-rw-r--r--src/version.c2
8 files changed, 68 insertions, 67 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 943cd5175..98c358d6a 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -654,8 +654,6 @@ test_null_string() String null value for testing
test_option_not_set({name}) none reset flag indicating option was set
test_override({expr}, {val}) none test with Vim internal overrides
test_refcount({expr}) Number get the reference count of {expr}
-test_scrollbar({which}, {value}, {dragging})
- none scroll in the GUI for testing
test_setmouse({row}, {col}) none set the mouse position for testing
test_settime({expr}) none set current time for testing
test_srand_seed([seed]) none set seed for testing srand()
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index ebfbbe6bb..7bb363b43 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1130,7 +1130,6 @@ Testing: *test-functions*
test_setmouse() set the mouse position
test_feedinput() add key sequence to input buffer
test_option_not_set() reset flag indicating option was set
- test_scrollbar() simulate scrollbar movement in the GUI
test_refcount() return an expression's reference count
test_srand_seed() set the seed value for srand()
test_unknown() return a value with unknown type
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 1b788db9c..1c08f3dfc 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -933,7 +933,6 @@ static argcheck_T arg3_string_any_string[] = {arg_string, NULL, arg_string};
static argcheck_T arg3_string_bool_bool[] = {arg_string, arg_bool, arg_bool};
static argcheck_T arg3_string_bool_dict[] = {arg_string, arg_bool, arg_dict_any};
static argcheck_T arg3_string_number_bool[] = {arg_string, arg_number, arg_bool};
-static argcheck_T arg3_string_number_number[] = {arg_string, arg_number, arg_number};
static argcheck_T arg3_string_string_bool[] = {arg_string, arg_string, arg_bool};
static argcheck_T arg3_string_string_dict[] = {arg_string, arg_string, arg_dict_any};
static argcheck_T arg3_string_string_number[] = {arg_string, arg_string, arg_number};
@@ -2359,14 +2358,6 @@ static funcentry_T global_functions[] =
ret_void, f_test_override},
{"test_refcount", 1, 1, FEARG_1, NULL,
ret_number, f_test_refcount},
- {"test_scrollbar", 3, 3, FEARG_2, arg3_string_number_number,
- ret_void,
-#ifdef FEAT_GUI
- f_test_scrollbar
-#else
- NULL
-#endif
- },
{"test_setmouse", 2, 2, 0, arg2_number,
ret_void, f_test_setmouse},
{"test_settime", 1, 1, FEARG_1, arg1_number,
diff --git a/src/proto/testing.pro b/src/proto/testing.pro
index 1277a2e05..2192e91ec 100644
--- a/src/proto/testing.pro
+++ b/src/proto/testing.pro
@@ -32,7 +32,6 @@ void f_test_null_partial(typval_T *argvars, typval_T *rettv);
void f_test_null_string(typval_T *argvars, typval_T *rettv);
void f_test_unknown(typval_T *argvars, typval_T *rettv);
void f_test_void(typval_T *argvars, typval_T *rettv);
-void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
void f_test_setmouse(typval_T *argvars, typval_T *rettv);
void f_test_gui_event(typval_T *argvars, typval_T *rettv);
void f_test_settime(typval_T *argvars, typval_T *rettv);
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 5516c8904..61451bc3e 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -714,13 +714,15 @@ func Test_scrollbars()
set guioptions+=rlb
" scroll to move line 11 at top, moves the cursor there
- eval 10->test_scrollbar('left', 0)
+ let args = #{which: 'left', value: 10, dragging: 0}
+ call test_gui_event('scrollbar', args)
redraw
call assert_equal(1, winline())
call assert_equal(11, line('.'))
" scroll to move line 1 at top, cursor stays in line 11
- call test_scrollbar('right', 0, 0)
+ let args = #{which: 'right', value: 0, dragging: 0}
+ call test_gui_event('scrollbar', args)
redraw
call assert_equal(11, winline())
call assert_equal(11, line('.'))
@@ -737,7 +739,8 @@ func Test_scrollbars()
call assert_equal(1, col('.'))
" scroll to character 11, cursor is moved
- call test_scrollbar('hor', 10, 0)
+ let args = #{which: 'hor', value: 10, dragging: 0}
+ call test_gui_event('scrollbar', args)
redraw
call assert_equal(1, wincol())
set number
@@ -747,6 +750,13 @@ func Test_scrollbars()
redraw
call assert_equal(11, col('.'))
+ " Invalid arguments
+ call assert_false(test_gui_event('scrollbar', {}))
+ call assert_false(test_gui_event('scrollbar', #{value: 10, dragging: 0}))
+ call assert_false(test_gui_event('scrollbar', #{which: 'hor', dragging: 0}))
+ call assert_false(test_gui_event('scrollbar', #{which: 'hor', value: 1}))
+ call assert_fails("call test_gui_event('scrollbar', #{which: 'a', value: 1, dragging: 0})", 'E475:')
+
set guioptions&
set wrap&
bwipe!
@@ -1346,6 +1356,8 @@ func Test_gui_drop_files()
call assert_false(test_gui_event("dropfiles", {}))
let d = #{row: 1, col: 1, modifiers: 0}
call assert_false(test_gui_event("dropfiles", d))
+ let d = #{files: 1, row: 1, col: 1, modifiers: 0}
+ call assert_false(test_gui_event("dropfiles", d))
let d = #{files: test_null_list(), row: 1, col: 1, modifiers: 0}
call assert_false(test_gui_event("dropfiles", d))
let d = #{files: [test_null_string()], row: 1, col: 1, modifiers: 0}
@@ -1460,6 +1472,18 @@ func Test_gui_findrepl()
let args = #{find_text: 'TWO', repl_text: 'two', flags: 0x1C, forward: 1}
call test_gui_event('findrepl', args)
call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$'))
+
+ " Invalid arguments
+ call assert_false(test_gui_event('findrepl', {}))
+ let args = #{repl_text: 'a', flags: 1, forward: 1}
+ call assert_false(test_gui_event('findrepl', args))
+ let args = #{find_text: 'a', flags: 1, forward: 1}
+ call assert_false(test_gui_event('findrepl', args))
+ let args = #{find_text: 'a', repl_text: 'b', forward: 1}
+ call assert_false(test_gui_event('findrepl', args))
+ let args = #{find_text: 'a', repl_text: 'b', flags: 1}
+ call assert_false(test_gui_event('findrepl', args))
+
bw!
endfunc
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index d6b42bbfd..2e84011ac 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -4089,13 +4089,6 @@ def Test_test_override()
v9.CheckDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
-def Test_test_scrollbar()
- CheckGui
- v9.CheckDefAndScriptFailure(['test_scrollbar(1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_scrollbar("a", "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['test_scrollbar("a", 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
-enddef
-
def Test_test_setmouse()
v9.CheckDefAndScriptFailure(['test_setmouse("a", 10)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
v9.CheckDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
diff --git a/src/testing.c b/src/testing.c
index 5c4f118ce..6fcbaa72a 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -1253,50 +1253,6 @@ f_test_void(typval_T *argvars UNUSED, typval_T *rettv)
rettv->v_type = VAR_VOID;
}
-#ifdef FEAT_GUI
- void
-f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
-{
- char_u *which;
- long value;
- int dragging;
- scrollbar_T *sb = NULL;
-
- if (check_for_string_arg(argvars, 0) == FAIL
- || check_for_number_arg(argvars, 1) == FAIL
- || check_for_number_arg(argvars, 2) == FAIL)
- return;
-
- if (argvars[0].v_type != VAR_STRING
- || (argvars[1].v_type) != VAR_NUMBER
- || (argvars[2].v_type) != VAR_NUMBER)
- {
- emsg(_(e_invalid_argument));
- return;
- }
- which = tv_get_string(&argvars[0]);
- value = tv_get_number(&argvars[1]);
- dragging = tv_get_number(&argvars[2]);
-
- if (STRCMP(which, "left") == 0)
- sb = &curwin->w_scrollbars[SBAR_LEFT];
- else if (STRCMP(which, "right") == 0)
- sb = &curwin->w_scrollbars[SBAR_RIGHT];
- else if (STRCMP(which, "hor") == 0)
- sb = &gui.bottom_sbar;
- if (sb == NULL)
- {
- semsg(_(e_invalid_argument_str), which);
- return;
- }
- gui_drag_scrollbar(sb, value, dragging);
-# ifndef USE_ON_FLY_SCROLL
- // need to loop through normal_cmd() to handle the scroll events
- exec_normal(FALSE, TRUE, FALSE);
-# endif
-}
-#endif
-
void
f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
{
@@ -1430,6 +1386,43 @@ test_gui_mouse_event(dict_T *args)
}
static int
+test_gui_scrollbar(dict_T *args)
+{
+ char_u *which;
+ long value;
+ int dragging;
+ scrollbar_T *sb = NULL;
+
+ if (dict_find(args, (char_u *)"which", -1) == NULL
+ || dict_find(args, (char_u *)"value", -1) == NULL
+ || dict_find(args, (char_u *)"dragging", -1) == NULL)
+ return FALSE;
+
+ which = dict_get_string(args, (char_u *)"which", FALSE);
+ value = (long)dict_get_number(args, (char_u *)"value");
+ dragging = (int)dict_get_number(args, (char_u *)"dragging");
+
+ if (STRCMP(which, "left") == 0)
+ sb = &curwin->w_scrollbars[SBAR_LEFT];
+ else if (STRCMP(which, "right") == 0)
+ sb = &curwin->w_scrollbars[SBAR_RIGHT];
+ else if (STRCMP(which, "hor") == 0)
+ sb = &gui.bottom_sbar;
+ if (sb == NULL)
+ {
+ semsg(_(e_invalid_argument_str), which);
+ return FALSE;
+ }
+ gui_drag_scrollbar(sb, value, dragging);
+# ifndef USE_ON_FLY_SCROLL
+ // need to loop through normal_cmd() to handle the scroll events
+ exec_normal(FALSE, TRUE, FALSE);
+# endif
+
+ return TRUE;
+}
+
+ static int
test_gui_tabline_event(dict_T *args UNUSED)
{
# ifdef FEAT_GUI_TABLINE
@@ -1487,6 +1480,8 @@ f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);
else if (STRCMP(event, "mouse") == 0)
rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);
+ else if (STRCMP(event, "scrollbar") == 0)
+ rettv->vval.v_number = test_gui_scrollbar(argvars[1].vval.v_dict);
else if (STRCMP(event, "tabline") == 0)
rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);
else if (STRCMP(event, "tabmenu") == 0)
diff --git a/src/version.c b/src/version.c
index d3b7bf846..301f54421 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4276,
+/**/
4275,
/**/
4274,