File: 23-tab-subclass.t

package info (click to toggle)
libtickit-widget-tabbed-perl 0.028-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 260 kB
  • sloc: perl: 1,851; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 869 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
#!/usr/bin/perl

use v5.26;
use warnings;

use Test::More;

use Tickit::Test;

use Tickit::Widget::Static;
use Tickit::Widget::Tabbed;

my $widget = Tickit::Widget::Tabbed->new(
        tab_position => "top",
        tab_class => "TestWidget::Tab",
);

my $tab = $widget->add_tab(
        Tickit::Widget::Static->new( text => "" ),
        label => "newtab",
        custom_attr => 123,
);

isa_ok( $tab, "TestWidget::Tab", '$tab from custom tab_class' );

is( $tab->custom_attr, 123, '$tab->custom_attr' );

done_testing;

package TestWidget::Tab;
use base qw( Tickit::Widget::Tabbed::Tab );

sub new
{
        my $class = shift;
        ( undef, my %args ) = @_;
        my $self = $class->SUPER::new( @_ );
        $self->{custom_attr} = $args{custom_attr};
        return $self;
}

sub custom_attr
{
        my $self = shift;
        return $self->{custom_attr};
}