mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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 #9674)
This commit is contained in:
committed by
Bram Moolenaar
parent
223a950a85
commit
9e0208f51c
@@ -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_option_not_set({name}) none reset flag indicating option was set
|
||||||
test_override({expr}, {val}) none test with Vim internal overrides
|
test_override({expr}, {val}) none test with Vim internal overrides
|
||||||
test_refcount({expr}) Number get the reference count of {expr}
|
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_setmouse({row}, {col}) none set the mouse position for testing
|
||||||
test_settime({expr}) none set current time for testing
|
test_settime({expr}) none set current time for testing
|
||||||
test_srand_seed([seed]) none set seed for testing srand()
|
test_srand_seed([seed]) none set seed for testing srand()
|
||||||
|
@@ -1130,7 +1130,6 @@ Testing: *test-functions*
|
|||||||
test_setmouse() set the mouse position
|
test_setmouse() set the mouse position
|
||||||
test_feedinput() add key sequence to input buffer
|
test_feedinput() add key sequence to input buffer
|
||||||
test_option_not_set() reset flag indicating option was set
|
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_refcount() return an expression's reference count
|
||||||
test_srand_seed() set the seed value for srand()
|
test_srand_seed() set the seed value for srand()
|
||||||
test_unknown() return a value with unknown type
|
test_unknown() return a value with unknown type
|
||||||
|
@@ -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_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_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_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_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_dict[] = {arg_string, arg_string, arg_dict_any};
|
||||||
static argcheck_T arg3_string_string_number[] = {arg_string, arg_string, arg_number};
|
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},
|
ret_void, f_test_override},
|
||||||
{"test_refcount", 1, 1, FEARG_1, NULL,
|
{"test_refcount", 1, 1, FEARG_1, NULL,
|
||||||
ret_number, f_test_refcount},
|
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,
|
{"test_setmouse", 2, 2, 0, arg2_number,
|
||||||
ret_void, f_test_setmouse},
|
ret_void, f_test_setmouse},
|
||||||
{"test_settime", 1, 1, FEARG_1, arg1_number,
|
{"test_settime", 1, 1, FEARG_1, arg1_number,
|
||||||
|
@@ -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_null_string(typval_T *argvars, typval_T *rettv);
|
||||||
void f_test_unknown(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_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_setmouse(typval_T *argvars, typval_T *rettv);
|
||||||
void f_test_gui_event(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);
|
void f_test_settime(typval_T *argvars, typval_T *rettv);
|
||||||
|
@@ -714,13 +714,15 @@ func Test_scrollbars()
|
|||||||
set guioptions+=rlb
|
set guioptions+=rlb
|
||||||
|
|
||||||
" scroll to move line 11 at top, moves the cursor there
|
" 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
|
redraw
|
||||||
call assert_equal(1, winline())
|
call assert_equal(1, winline())
|
||||||
call assert_equal(11, line('.'))
|
call assert_equal(11, line('.'))
|
||||||
|
|
||||||
" scroll to move line 1 at top, cursor stays in line 11
|
" 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
|
redraw
|
||||||
call assert_equal(11, winline())
|
call assert_equal(11, winline())
|
||||||
call assert_equal(11, line('.'))
|
call assert_equal(11, line('.'))
|
||||||
@@ -737,7 +739,8 @@ func Test_scrollbars()
|
|||||||
call assert_equal(1, col('.'))
|
call assert_equal(1, col('.'))
|
||||||
|
|
||||||
" scroll to character 11, cursor is moved
|
" 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
|
redraw
|
||||||
call assert_equal(1, wincol())
|
call assert_equal(1, wincol())
|
||||||
set number
|
set number
|
||||||
@@ -747,6 +750,13 @@ func Test_scrollbars()
|
|||||||
redraw
|
redraw
|
||||||
call assert_equal(11, col('.'))
|
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 guioptions&
|
||||||
set wrap&
|
set wrap&
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -1346,6 +1356,8 @@ func Test_gui_drop_files()
|
|||||||
call assert_false(test_gui_event("dropfiles", {}))
|
call assert_false(test_gui_event("dropfiles", {}))
|
||||||
let d = #{row: 1, col: 1, modifiers: 0}
|
let d = #{row: 1, col: 1, modifiers: 0}
|
||||||
call assert_false(test_gui_event("dropfiles", d))
|
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}
|
let d = #{files: test_null_list(), row: 1, col: 1, modifiers: 0}
|
||||||
call assert_false(test_gui_event("dropfiles", d))
|
call assert_false(test_gui_event("dropfiles", d))
|
||||||
let d = #{files: [test_null_string()], row: 1, col: 1, modifiers: 0}
|
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}
|
let args = #{find_text: 'TWO', repl_text: 'two', flags: 0x1C, forward: 1}
|
||||||
call test_gui_event('findrepl', args)
|
call test_gui_event('findrepl', args)
|
||||||
call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$'))
|
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!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -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'])
|
v9.CheckDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
|
||||||
enddef
|
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()
|
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("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'])
|
v9.CheckDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
|
||||||
|
@@ -1253,50 +1253,6 @@ f_test_void(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
rettv->v_type = VAR_VOID;
|
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
|
void
|
||||||
f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
|
f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
|
||||||
{
|
{
|
||||||
@@ -1429,6 +1385,43 @@ test_gui_mouse_event(dict_T *args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static int
|
||||||
test_gui_tabline_event(dict_T *args UNUSED)
|
test_gui_tabline_event(dict_T *args UNUSED)
|
||||||
{
|
{
|
||||||
@@ -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);
|
rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);
|
||||||
else if (STRCMP(event, "mouse") == 0)
|
else if (STRCMP(event, "mouse") == 0)
|
||||||
rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);
|
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)
|
else if (STRCMP(event, "tabline") == 0)
|
||||||
rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);
|
rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);
|
||||||
else if (STRCMP(event, "tabmenu") == 0)
|
else if (STRCMP(event, "tabmenu") == 0)
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4276,
|
||||||
/**/
|
/**/
|
||||||
4275,
|
4275,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user