File: 02tabs.t

package info (click to toggle)
libtickit-console-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 771; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download
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
#!/usr/bin/perl

use v5.26;
use warnings;

use Test2::V0;

use Tickit::Test;

use Tickit::Console;

my $win = mk_window;

my $console = Tickit::Console->new;

$console->set_window( $win );

my @tabs = map { $console->add_tab( name => $_ ) } qw( Tab0 Tab1 Tab2 );

flush_tickit;

is_display( [ BLANKLINES(23),
              [TEXT("[",fg=>7,bg=>4),TEXT("Tab0",fg=>14,bg=>4),TEXT("]Tab1 Tab2 ",fg=>7,bg=>4),TEXT("",bg=>4)],
              BLANKLINE() ],
            'Display after ->add_tab' );

is_cursorpos( 24, 0, 'Cursor position after ->add_tab' );

is( $console->active_tab_index, 0, '$console->active_tab_index' );
ref_is( $console->active_tab, $tabs[0], '$console->active_tab' );

is( $tabs[0]->index, 0,     '$tab[0]->index' );
is( $tabs[0]->name, "Tab0", '$tab[0]->name' );

$tabs[0]->set_name( "Newname" );

is( $tabs[0]->name, "Newname", '$tab[0]->name after ->set_name' );

flush_tickit;

is_display( [ BLANKLINES(23),
              [TEXT("[",fg=>7,bg=>4),TEXT("Newname",fg=>14,bg=>4),TEXT("]Tab1 Tab2 ",fg=>7,bg=>4),TEXT("",bg=>4)],
              BLANKLINE() ],
            'Display after $tab->set_name' );

$console->activate_tab( 1 );

is( $console->active_tab_index, 1, '$console->active_tab_index after ->activate_tab' );
ref_is( $console->active_tab, $tabs[1], '$console->active_tab after ->activate_tab' );

flush_tickit;

is_display( [ BLANKLINES(23),
              [TEXT(" Newname[",fg=>7,bg=>4),TEXT("Tab1",fg=>14,bg=>4),TEXT("]Tab2 ",fg=>7,bg=>4),TEXT("",bg=>4)],
              BLANKLINE() ],
            'Display after ->activate_tab' );

done_testing;