forked from aniani/vim
patch 8.1.0390: scrollbars are not tested
Problem: Scrollbars are not tested. Solution: Add test_scrollbar() and a test.
This commit is contained in:
@@ -2475,6 +2475,8 @@ test_null_partial() Funcref null value for testing
|
||||
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_scrollbar({which}, {value}, {dragging})
|
||||
none scroll in the GUI for testing
|
||||
test_settime({expr}) none set current time for testing
|
||||
timer_info([{id}]) List information about timers
|
||||
timer_pause({id}, {pause}) none pause or unpause a timer
|
||||
@@ -8773,6 +8775,23 @@ test_override({name}, {val}) *test_override()*
|
||||
< The value of "starting" is saved. It is restored by: >
|
||||
call test_override('starting', 0)
|
||||
|
||||
test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
|
||||
Pretend using scrollbar {which} to move it to position
|
||||
{value}. {which} can be:
|
||||
left Left scrollbar of the current window
|
||||
right Right scrollbar of the current window
|
||||
hor Horizontal scrollbar
|
||||
|
||||
For the vertical scrollbars {value} can be 1 to the
|
||||
line-count of the buffer. For the horizontal scrollbar the
|
||||
{value} can be between 1 and the maximum line length, assuming
|
||||
'wrap' is not set.
|
||||
|
||||
When {dragging} is non-zero it's like dragging the scrollbar,
|
||||
otherwise it's like clicking in the scrollbar.
|
||||
Only works when the {which} scrollbar actually exists,
|
||||
obviously only when using the GUI.
|
||||
|
||||
test_settime({expr}) *test_settime()*
|
||||
Set the time Vim uses internally. Currently only used for
|
||||
timestamps in the history, as they are used in viminfo, and
|
||||
|
||||
@@ -429,6 +429,9 @@ static void f_test_null_job(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_null_list(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_null_partial(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_null_string(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_GUI
|
||||
static void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
|
||||
#endif
|
||||
static void f_test_settime(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_FLOAT
|
||||
static void f_tan(typval_T *argvars, typval_T *rettv);
|
||||
@@ -925,6 +928,9 @@ static struct fst
|
||||
{"test_null_string", 0, 0, f_test_null_string},
|
||||
{"test_option_not_set", 1, 1, f_test_option_not_set},
|
||||
{"test_override", 2, 2, f_test_override},
|
||||
#ifdef FEAT_GUI
|
||||
{"test_scrollbar", 3, 3, f_test_scrollbar},
|
||||
#endif
|
||||
{"test_settime", 1, 1, f_test_settime},
|
||||
#ifdef FEAT_TIMERS
|
||||
{"timer_info", 0, 1, f_timer_info},
|
||||
@@ -13202,6 +13208,41 @@ f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
rettv->vval.v_string = NULL;
|
||||
}
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
static void
|
||||
f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
char_u *which;
|
||||
long value;
|
||||
int dragging;
|
||||
scrollbar_T *sb = NULL;
|
||||
|
||||
if (argvars[0].v_type != VAR_STRING
|
||||
|| (argvars[1].v_type) != VAR_NUMBER
|
||||
|| (argvars[2].v_type) != VAR_NUMBER)
|
||||
{
|
||||
EMSG(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
which = get_tv_string(&argvars[0]);
|
||||
value = get_tv_number(&argvars[1]);
|
||||
dragging = get_tv_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)
|
||||
{
|
||||
EMSG2(_(e_invarg2), which);
|
||||
return;
|
||||
}
|
||||
gui_drag_scrollbar(sb, value, dragging);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
f_test_settime(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
|
||||
@@ -667,6 +667,41 @@ func Test_set_guioptions()
|
||||
let &guioptions = guioptions_saved
|
||||
endfunc
|
||||
|
||||
func Test_scrollbars()
|
||||
new
|
||||
" buffer with 200 lines
|
||||
call setline(1, repeat(['one', 'two'], 100))
|
||||
set guioptions+=rlb
|
||||
|
||||
" scroll to move line 11 at top, moves the cursor there
|
||||
call test_scrollbar('left', 10, 0)
|
||||
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)
|
||||
redraw
|
||||
call assert_equal(11, winline())
|
||||
call assert_equal(11, line('.'))
|
||||
|
||||
set nowrap
|
||||
call setline(11, repeat('x', 150))
|
||||
redraw
|
||||
call assert_equal(1, wincol())
|
||||
call assert_equal(1, col('.'))
|
||||
|
||||
" scroll to character 11, cursor is moved
|
||||
call test_scrollbar('hor', 10, 0)
|
||||
redraw
|
||||
call assert_equal(1, wincol())
|
||||
call assert_equal(11, col('.'))
|
||||
|
||||
set guioptions&
|
||||
set wrap&
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_set_guipty()
|
||||
let guipty_saved = &guipty
|
||||
|
||||
|
||||
@@ -794,6 +794,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
390,
|
||||
/**/
|
||||
389,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user