File: match.t

package info (click to toggle)
libtk-histentry-perl 0.45-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: perl: 485; makefile: 4
file content (79 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (3)
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
# -*- perl -*-

#
# Author: Slaven Rezic
#
# Copyright (C) 1997,1998,2007,2008,2016 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# Mail: eserte@cs.tu-berlin.de
# WWW:  http://user.cs.tu-berlin.de/~eserte/
#

BEGIN {
    if (!eval q{
	use Test::More;
	1;
    }) {
	print "1..0 # skip: no Test::More module\n";
	exit;
    }
}

use Tk;

my $top;
BEGIN {
    if (!eval { $top = new MainWindow }) {
	print "1..0 # skip cannot open DISPLAY\n";
	CORE::exit;
    }
    $top->geometry('+10+10');
}

use Tk::HistEntry;
use strict;

plan tests => 4;

$top->geometry($top->screenwidth . "x" .$top->screenheight . "+0+0");

my $he = $top->HistEntry(-match => 1,
			)->pack;
isa_ok($he, "Tk::HistEntry");

$he->addhistory('Foo');
$he->addhistory('Bar');
my $e = $he->_entry;
isa_ok($e, "Tk::LabEntry");
my $focus_e = $e->Subwidget("entry");
$e->focus;
$e->update;

eval {
    $e->event('generate', '<KeyPress>', -keysym => 'F');
    $e->event('generate', '<KeyPress>', -keysym => 'o');
    $e->update;
};
SKIP: {
    skip("Focus lost? $@", 1) if $@;
    skip("Focus lost!", 1) if ($top->focusCurrent||"") ne $focus_e;
    is($e->get, 'Foo', "Expected first entry");
}

{
    local $TODO = "Rethink BackSpace behavior...";

    eval {
	$e->event('generate', '<KeyPress>', -keysym => 'BackSpace');
	$e->update;
    };
 SKIP: {
	skip("Focus lost? $@", 1) if $@;
	skip("Focus lost!", 1) if ($top->focusCurrent||"") ne $focus_e;
	is($e->get, 'F', 'Only one character entered');
    }
}

#MainLoop;