Gtk2-Ex-ErrorTextDialog
view release on metacpan or search on metacpan
t/SaveDialog.t view on Meta::CPAN
or plan skip_all => "due to no DISPLAY available";
plan tests => 10;
#-----------------------------------------------------------------------------
my $want_version = 11;
is ($Gtk2::Ex::ErrorTextDialog::SaveDialog::VERSION, $want_version,
'VERSION variable');
is (Gtk2::Ex::ErrorTextDialog::SaveDialog->VERSION, $want_version,
'VERSION class method');
ok (eval { Gtk2::Ex::ErrorTextDialog::SaveDialog->VERSION($want_version); 1 },
"VERSION class check $want_version");
ok (! eval { Gtk2::Ex::ErrorTextDialog::SaveDialog->VERSION($want_version + 1000); 1 },
"VERSION class check " . ($want_version + 1000));
#-----------------------------------------------------------------------------
# dialog and saving
{
my $dialog = do {
local $SIG{'__WARN__'} = \&MyTestHelpers::warn_suppress_gtk_icon;
Gtk2::Ex::ErrorTextDialog::SaveDialog->new;
};
is ($dialog->VERSION, $want_version, 'VERSION object method');
ok (eval { $dialog->VERSION($want_version); 1 },
"VERSION object check $want_version");
ok (! eval { $dialog->VERSION($want_version + 1000); 1 },
"VERSION object check " . ($want_version + 1000));
my $errdialog = Gtk2::Ex::ErrorTextDialog->new;
$errdialog->add_message ("hello\n");
$dialog->set_transient_for ($errdialog);
require File::Temp;
my $fh = File::Temp->new;
my $filename = $fh->filename;
diag "temp file $filename";
# for some very dubious reason set_current_name() doesn't work until the
# dialog is shown, and not just realized either, :-(
$dialog->show;
MyTestHelpers::main_iterations ();
$dialog->set_current_name($filename);
is ($dialog->get_filename, $filename, "filename set into dialog: $filename");
SKIP: {
$dialog->get_filename eq $filename
or skip "filename not set correctly into dialog, don't want to overwrite something else", 1;
$dialog->save;
my $str = do { local $/ = undef; <$fh> }; # slurp
is ($str, "hello\n", "saved to $filename");
}
$dialog->destroy;
$errdialog->destroy;
}
#-----------------------------------------------------------------------------
# destroy and weaken
{
my $dialog = do {
local $SIG{'__WARN__'} = \&MyTestHelpers::warn_suppress_gtk_icon;
Gtk2::Ex::ErrorTextDialog::SaveDialog->new;
};
require Scalar::Util;
Scalar::Util::weaken ($dialog);
$dialog->destroy;
MyTestHelpers::main_iterations ();
is ($dialog, undef, 'garbage collect after destroy');
}
exit 0;
( run in 0.870 second using v1.01-cache-2.11-cpan-39bf76dae61 )