Gtk2-Ex-ErrorTextDialog
view release on metacpan or search on metacpan
t/ErrorTextDialog.t view on Meta::CPAN
}
#-----------------------------------------------------------------------------
# _textbuf_ensure_final_newline()
# {
# my $textbuf = Gtk2::TextBuffer->new;
# foreach my $elem (['', ''],
# ["\n", "\n"],
# ["hello", "hello\n"],
# ["hello\n", "hello\n"],
# ["hello\nhello", "hello\nhello\n"],
# ["hello\nhello\n", "hello\nhello\n"],
# ) {
# my ($text, $want) = @$elem;
#
# $textbuf->set (text => $text);
# ## no critic (ProtectPrivateSubs)
# Gtk2::Ex::ErrorTextDialog::_textbuf_ensure_final_newline($textbuf);
# is ($textbuf->get('text'), $want,
# "_textbuf_ensure_final_newline() on '$text'");
# }
# }
#-----------------------------------------------------------------------------
# _message_dialog_set_text()
{
my $dialog = Gtk2::MessageDialog->new (undef, [], 'info', 'ok',
'An informational message');
## no critic (ProtectPrivateSubs)
Gtk2::Ex::ErrorTextDialog::_message_dialog_set_text($dialog, 'new message');
if ($dialog->find_property('text')) {
is ($dialog->get('text'), 'new message',
'_message_dialog_text_widget() messagedialog');
} else {
ok (1, "_message_dialog_text_widget() no 'text' property to read back");
}
$dialog->destroy;
}
#-----------------------------------------------------------------------------
# get_text()
{
my $dialog = Gtk2::Ex::ErrorTextDialog->new;
is ($dialog->get_text, '', 'get_text() when empty');
$dialog->add_message ('hello');
is ($dialog->get_text, "hello\n", 'get_text() of some text');
$dialog->destroy;
}
#-----------------------------------------------------------------------------
# action signals
{
my $dialog = Gtk2::Ex::ErrorTextDialog->new;
my $textbuf = $dialog->{'textbuf'};
my ($find_popup) = grep {$_->{'signal_name'} eq 'popup-save-dialog'}
Glib::Type->list_signals ('Gtk2::Ex::ErrorTextDialog');
ok ($find_popup, 'have "popup-save-dialog" signal');
if ($find_popup) {
diag "$find_popup->{'signal_name'} $find_popup->{'signal_id'} $find_popup->{'itype'} $find_popup->{'signal_flags'}";
}
$dialog->add_message ('hello');
my $saw_popup = 0;
$dialog->signal_connect (popup_save_dialog => sub { $saw_popup = 1 });
{ local $SIG{'__WARN__'} = \&MyTestHelpers::warn_suppress_gtk_icon;
$dialog->popup_save_dialog;
}
is ($saw_popup, 1, 'popup_save_dialog() emits "popup-save-dialog"');
isnt ($textbuf->get_char_count, 0, 'popup - textbuf still has message');
$dialog->add_message ('hello');
my $saw_clear = 0;
$dialog->signal_connect (clear => sub { $saw_clear = 1 });
$dialog->clear;
is ($saw_clear, 1, 'clear() emits "clear"');
is ($textbuf->get_char_count, 0, 'clear - textbuf now empty');
$dialog->destroy;
}
#-----------------------------------------------------------------------------
# popup_add_message()
{
Gtk2::Ex::ErrorTextDialog->popup_add_message ('hello');
my $dialog = Gtk2::Ex::ErrorTextDialog->instance;
isa_ok ($dialog, 'Gtk2::Ex::ErrorTextDialog');
$dialog->popup_add_message ('hello');
}
exit 0;
( run in 1.125 second using v1.01-cache-2.11-cpan-364913b4093 )