diff options
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | t/03-Shared_GUI.t | 103 | ||||
-rw-r--r-- | t/05-rpmnew.t | 24 |
3 files changed, 65 insertions, 71 deletions
@@ -53,6 +53,9 @@ To install this module, run the following commands: make test make install +To test gui dialogs run: + make test TEST_GUI=1 + To install this module with local::lib (see perldoc local::lib for details) # add also -MCPAN if you want to install from cpan locally @@ -62,9 +65,9 @@ details) make test make install -Since admin panel works with root privilege you can do the above -or just install it locally and run as root but using user environment -variable to know which ones run perl -Mlocal::lib as user and +Since admin panel works with root privileges you can do the above +and install it locally then run tools as root adding your user environment +variables, to know which ones run perl -Mlocal::lib as user and execute the output as root. diff --git a/t/03-Shared_GUI.t b/t/03-Shared_GUI.t index c2cef880..1a781cb4 100644 --- a/t/03-Shared_GUI.t +++ b/t/03-Shared_GUI.t @@ -12,60 +12,55 @@ BEGIN { ok( my $gui = AdminPanel::Shared::GUI->new(), 'create'); - diag "\n\nNext tests will create some gui dialogs"; - diag "Perform tests (y/n) [n] ?"; - - my $a = <>; chomp $a; $a = "n" unless $a; - - SKIP: { - #remember to skip the righ number of tests - skip "You didn't say yes...", 11, unless ( $a eq "y" ); - - 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'); - } +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; diff --git a/t/05-rpmnew.t b/t/05-rpmnew.t index cc1021f6..ce561397 100644 --- a/t/05-rpmnew.t +++ b/t/05-rpmnew.t @@ -7,30 +7,26 @@ BEGIN { use_ok( 'AdminPanel::Rpmdragora::rpmnew' ) || print "AdminPanel::Rpmdragora::rpmnew failed!\n"; } - diag "\n\nNext tests will create some gui dialogs"; - diag "Perform tests (y/n) [n] ?"; - my $a = <>; chomp $a; $a = "n" unless $a; +SKIP: { + #remember to skip the righ number of tests + skip "To enable dialog tests set TEST_GUI", 1, unless $ENV{TEST_GUI}; - SKIP: { - #remember to skip the righ number of tests - skip "You didn't say yes...", 1, unless ( $a eq "y" ); - - open (MYFILE, '>/tmp/_rpmnew_test'); + open (MYFILE, '>/tmp/_rpmnew_test'); print MYFILE "value = 1\n"; print MYFILE "value1 = 2\n"; close (MYFILE); - open (MYFILE, '>/tmp/_rpmnew_test.rpmnew'); + open (MYFILE, '>/tmp/_rpmnew_test.rpmnew'); print MYFILE "value = 2\n"; print MYFILE "value1 = 1\n"; close (MYFILE); - is( AdminPanel::Rpmdragora::rpmnew::rpmnew_dialog("Test rpmnew dialog", ( - test_package => ["/tmp/_rpmnew_test", "/tmp/rpmnew_test"], - test_package2 => ["/tmp/tp2"], - )), 0, 'rpmnew'); + is( AdminPanel::Rpmdragora::rpmnew::rpmnew_dialog("Test rpmnew dialog", ( + test_package => ["/tmp/_rpmnew_test", "/tmp/rpmnew_test"], + test_package2 => ["/tmp/tp2"], + )), 0, 'rpmnew'); - } +} done_testing; |