File: 02input-key.t

package info (click to toggle)
libtickit-widget-scrollbox-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 168 kB
  • sloc: perl: 868; makefile: 2
file content (79 lines) | stat: -rw-r--r-- 2,039 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

use Tickit::Test;

use Tickit::Widget::Static;
use Tickit::Widget::ScrollBox;

my $win = mk_window;

my $static = Tickit::Widget::Static->new(
   text => join "\n", map { "X" x 200 } 1 .. 100
);

my $widget = Tickit::Widget::ScrollBox->new(
   horizontal => 1,
   vertical   => 1,
);

$widget->add( $static );
$widget->set_window( $win );

my $vextent = $widget->vextent;
my $hextent = $widget->hextent;

# We won't use the is_display tests here because they're annoying to write.
# Having asserted that the Extent objects do the right thing in earlier tests,
# we'll just check the input events have the right effect on those.

is( $vextent->start, 0, 'start is 0 initially' );
is( $hextent->start, 0, 'hextent start is 0 initially' );

# vertical
{
   presskey( key => "Down" );
   is( $vextent->start, 1, 'start moves down +1 after <Down>' );

   presskey( key => "PageDown" );
   is( $vextent->start, 13, 'start moves down +12 after <PageDown>' );

   presskey( key => "Up" );
   is( $vextent->start, 12, 'start moves up -1 after <Up>' );

   presskey( key => "PageUp" );
   is( $vextent->start, 0, 'start moves up -12 after <PageUp>' );

   presskey( key => "C-End", 0x04 );
   is( $vextent->start, 76, 'start moves to 76 after <C-End>' );

   presskey( key => "C-Home", 0x04 );
   is( $vextent->start, 0, 'start moves to 0 after <C-Home>' );
}

# horizontal
{
   presskey( key => "Right" );
   is( $hextent->start, 1, 'start moves right +1 after <Right>' );

   presskey( key => "C-Right", 0x4 );
   is( $hextent->start, 40, 'start moves right +39 after <C-Right>' );

   presskey( key => "Left" );
   is( $hextent->start, 39, 'start moves up -1 after <Left>' );

   presskey( key => "C-Left", 0x4 );
   is( $hextent->start, 0, 'start moves up -39 after <C-Left>' );

   presskey( key => "End" );
   is( $hextent->start, 121, 'start moves to 121 after <End>' );

   presskey( key => "Home" );
   is( $hextent->start, 0, 'start moves to 0 after <Home>' );
}

done_testing;