From 0642af21a73f5128106b456195ab128bcb4619b6 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Mon, 23 Feb 2015 10:00:30 +0100 Subject: fixed confirmimg dialog size by adding min_size param to interactive_msg added a test case for interactive_msg --- MANIFEST | 3 ++- lib/AdminPanel/Rpmdragora/pkg.pm | 2 +- lib/AdminPanel/rpmdragora.pm | 17 +++++++++++------ t/06-rpmdragora.t | 30 ++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 t/06-rpmdragora.t diff --git a/MANIFEST b/MANIFEST index 47a24a88..156f60be 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,4 @@ -Changes +hanges COPYING.GPLv2 extras/bash_completion/mana extras/conf/categories.conf @@ -131,6 +131,7 @@ t/02-Users.t t/03-Shared_GUI.t t/04-Shared_TimeZone.t t/05-rpmnew.t +t/05-rpmdragora.t t/boilerplate.t t/manifest.t t/pod-coverage.t diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm index 36ee2593..16f27119 100644 --- a/lib/AdminPanel/Rpmdragora/pkg.pm +++ b/lib/AdminPanel/Rpmdragora/pkg.pm @@ -812,7 +812,7 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( format_filesize($filesize), $loc->N("Is it ok to continue?")), scroll => 1, - yesno => 1) or return 1; + yesno => 1, min_size => {lines => 18},) or return 1; my $_umount_guard = MDK::Common::Func::before_leaving { urpm::removable::try_umounting_removables($urpm) }; diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm index 287dfc5c..98e5d279 100644 --- a/lib/AdminPanel/rpmdragora.pm +++ b/lib/AdminPanel/rpmdragora.pm @@ -273,16 +273,17 @@ sub getbanner() { $title: dialog title $contents: dialog text %options: optional HASH containing { - scroll => Rich Text with scroll bar used - yesno => dialog with "yes" and "no" buttons (deafult yes) + scroll => Rich Text with scroll bar used + yesno => dialog with "yes" and "no" buttons (deafult yes) dont_ask_again => add a checkbox with "dont ask again text" - main_dialog => create a main dialog instead of a popup one + main_dialog => create a main dialog instead of a popup one + min_size => {columns => X, lines => Y} for minimum dialog size, } =head3 OUTPUT retval: if dont_ask_again HASH reference containig { - value => 1 yes (or ok) pressed, 0 no pressed + value => 1 yes (or ok) pressed, 0 no pressed dont_ask_again => 1 if checked } or if dont_ask_again is not passed: @@ -292,7 +293,9 @@ sub getbanner() { This function shows a dialog with contents text and return the button pressed (1 ok or yes), optionally returns the checkbox value if dont_ask_again is - passed + passed. + If min_size is passed a minimum dialog size is set (default is 75x6) see libyui + createMinSize documenatation for explanation. =cut @@ -316,7 +319,9 @@ sub interactive_msg { my $dlg = $options{main_dialog} ? $factory->createMainDialog() : $factory->createPopupDialog(); - my $minSize = $factory->createMinSize( $dlg, 75, 6); + my $columns = $options{min_size}->{columns} || 75; + my $lines = $options{min_size}->{lines} || 6; + my $minSize = $factory->createMinSize( $dlg, $columns, $lines); my $vbox = $factory->createVBox( $minSize ); my $midhbox = $factory->createHBox($vbox); ## app description diff --git a/t/06-rpmdragora.t b/t/06-rpmdragora.t new file mode 100644 index 00000000..e59533df --- /dev/null +++ b/t/06-rpmdragora.t @@ -0,0 +1,30 @@ +use 5.006; +use strict; +use warnings FATAL => 'all'; +use Test::More; + +BEGIN { + use_ok( 'AdminPanel::rpmdragora' ) || print "AdminPanel::rpmdragora failed!\n"; +} + + +SKIP: { + #remember to skip the righ number of tests + skip "To enable dialog tests set TEST_GUI", 1, unless $ENV{TEST_GUI}; + + ok( interactive_msg( "Interactive msg title", + join( + "\n\n", + "text line 1", + "text line 2", + "text line 3", + "set yesno => 1 to have a yesno dialog otherwhise just ok button is shown", + "press ok to continue"), + scroll => 1, + ), + 'interactive_msg', + ); +} + + +done_testing; -- cgit v1.2.1