aboutsummaryrefslogtreecommitdiffstats
path: root/t/03-Shared_GUI.t
blob: 1a781cb4a0f38830485ec755bcf9273c43f9a4af (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
use 5.006;
use strict;
use warnings FATAL => 'all';
use Test::More;

BEGIN {
    use_ok( 'AdminPanel::Shared::GUI' ) || print "AdminPanel::Shared::GUI failed!\n";
    use_ok( 'AdminPanel::Shared' ) || print "AdminPanel::Shared failed!\n";
}

    is (AdminPanel::Shared::distName(), 'adminpanel', 'distname');

    ok( my $gui = AdminPanel::Shared::GUI->new(), 'create');

SKIP: {
    #remember to skip the righ number of tests
    skip "To enable dialog tests set TEST_GUI", 11, unless $ENV{TEST_GUI};

    ok( $gui->warningMsgBox({text => "Warning message! (no title, no richtext)<br> line two"}), 'wmb1');

    ok( $gui->warningMsgBox({text => "Warning message!<br> line two", title => "WARN", richtext => 1}), 'wmb2');

    ok($gui->infoMsgBox({text => "Info message!<br> line two", title => "INFO", richtext => 1}), 'imb');

    ok($gui->msgBox({text => "Normal message! (no title, no richtext)<br> line two"}), 'mb1');

    ok($gui->msgBox({title => "Message", text => "Normal message!<br> line two", richtext=>1}), 'mb2');

    cmp_ok(my $btn = $gui->ask_OkCancel({title => "Tests", text => "All these tests seem to be passed"}), ">=", 0, 'askOkCancel');
    diag "ask_OkCancel got: < " . ($btn == 1 ? "Ok": "Cancel"). " >";

    cmp_ok($btn = $gui->ask_YesOrNo({title => "Question on tests", text => "Did these tests all pass?"}), ">=", 0, 'ask_YesOrNo');
    diag "ask_YesOrNo got: < " . ($btn == 1 ? "Yes": "No"). " >";

    #TODO cancel makes this test failing
    ok(my $item = $gui->ask_fromList({title => "Choose from list", header => "Which one do you select? [default is item 3]", default_button => 1,
                                        list  => ['item 1', 'item 2', 'item 3', 'item 4'],
                                        default_item => 'item 3'
    }), 'ask_fromList');
    diag "ask_fromList got: < " . ($item ? $item : "none") . " >";

    #TODO cancel makes this test failing
    ok($item = $gui->ask_fromTreeList({title => "Choose from list", header => "Which one do you select? [default is leaf 2]", default_button => 1,
                                        default_item => 'leaf 2',
                                    list  => ['item 1/item 2/item 3', 'item 1/item 2/leaf 1', 'item 1/item 2/leaf 2', 'item 4/leaf 3', 'item 5']}),
                                    'ask_fromTreeList');
    diag "ask_fromTreeList got: < " . ($item ? $item : "none") . " >";

    ok($gui->AboutDialog({ name => "Shared::GUI TABBED",
                    version => $AdminPanel::Shared::VERSION,
                    credits => "Copyright (C) 2014 Angelo Naselli",
                    license => 'GPLv2',
                    authors => "Angelo Naselli <anaselli\@linux.it>\nMatteo Pasotti <matteo.pasotti\@gmail.com>",
                    }), 'AboutDialog');

    ok($gui->AboutDialog({ name => "Shared::GUI CLASSIC",
                    version => $AdminPanel::Shared::VERSION,
                    credits => "Copyright (C) 2014 Angelo Naselli",
                    license => 'GPLv2',
                    authors => "Angelo Naselli <anaselli\@linux.it>\nMatteo Pasotti <matteo.pasotti\@gmail.com>",
                    dialog_mode => 1,
                    }), 'ClassicAboutDialog');
}


done_testing;