summaryrefslogtreecommitdiff
path: root/t/04on_demand.t
blob: 16f45a300ce4d430529ad5119f8f99f491b62d22 (plain)
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
#!/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;

# Needs 40x20
my $static = Tickit::Widget::Static->new(
   text => join "\n", map { $_ x 40 } 'A' .. 'T'
);

my $widget = Tickit::Widget::ScrollBox->new(
   horizontal => "on_demand",
   vertical   => "on_demand",
   child => $static,
);

$widget->set_window( $win );
flush_tickit;

# Oversized at 80x25
{
   ok( !$widget->_h_visible, 'H invisible at 80x25' );
   ok( !$widget->_v_visible, 'V invisible at 80x25' );
}

# Undersized vertically at 80x15
{
   $win->resize( 15, 80 );
   ok( !$widget->_h_visible, 'H invisible at 80x15' );
   ok(  $widget->_v_visible, 'V visible at 80x15' );
}

# Undersized horizontally at 30x25
{
   $win->resize( 25, 30 );
   ok(  $widget->_h_visible, 'H visible at 30x25' );
   ok( !$widget->_v_visible, 'V invisible at 30x25' );
}

# Undersized at 30x15
{
   $win->resize( 15, 30 );
   ok(  $widget->_h_visible, 'H visible at 30x15' );
   ok(  $widget->_v_visible, 'V visible at 30x15' );
}

# Exactly at limits
{
   $win->resize( 20, 40 );
   ok( !$widget->_h_visible, 'H invisible at 40x20' );
   ok( !$widget->_v_visible, 'V invisible at 40x20' );
}

# Making either scrollbar visible forces the other when at-limit
{
   $win->resize( 20, 39 );
   ok(  $widget->_h_visible, 'H visible at 39x20' );
   ok(  $widget->_v_visible, 'V visible at 39x20' );

   $win->resize( 19, 40 );
   ok(  $widget->_h_visible, 'H visible at 40x19' );
   ok(  $widget->_v_visible, 'V visible at 40x19' );
}

done_testing;