File: UI-Dialog-Backend-Zenity.t

package info (click to toggle)
libui-dialog-perl 1.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 808 kB
  • sloc: perl: 7,403; makefile: 2
file content (88 lines) | stat: -rw-r--r-- 3,327 bytes parent folder | download | duplicates (2)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use Test::More;
BEGIN { use_ok( 'UI::Dialog::Backend::Zenity' ); }
require_ok( 'UI::Dialog::Backend::Zenity' );

#########################

eval { new UI::Dialog::Backend::Zenity(test_mode=>1); };
if ( $@ ) {
  if ($@ =~ m!binary could not be found!) {
    diag("Tests skipped, backend binary not found.");
  }
  else {
    diag("An unknown error occurred while trying to use backend: ".$@);
  }
  done_testing();
}
else {

  my $obj = new UI::Dialog::Backend::Zenity
    ( test_mode => 1 );
  isa_ok( $obj, 'UI::Dialog::Backend::Zenity' );

  my $bin = $obj->get_bin();

  my @methods = qw( new state ra rs rv nautilus xosd beep clear
                    yesno msgbox inputbox password textbox menu
                    checklist radiolist fselect dselect );
  can_ok( 'UI::Dialog::Backend::Zenity', @methods );

  $obj->yesno( title=>"TITLE", text => "TEXT",
               width => 64, height => 16 );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --question --text TEXT|
    );

  $obj->msgbox( title=>"TITLE", text => "TEXT",
                width => 64, height => 16 );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --info --text TEXT|
    );

  $obj->infobox( title=>"TITLE", text => "TEXT",
                 width => 64, height => 16 );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --info --text TEXT|
    );

  $obj->inputbox( title=>"TITLE", text => "TEXT",
                  width => 64, height => 16, entry => "ENTRY" );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --entry --entry-text ENTRY --text TEXT|
    );

  $obj->password( title=>"TITLE", text => "TEXT",
                  width => 64, height => 16, entry => "ENTRY" );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --entry --hide-text --entry-text ENTRY --text TEXT|
    );

  $obj->textbox( title=>"TITLE", path => "$0",
                 width => 64, height => 16 );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --text-info --filename t/UI-Dialog-Backend-Zenity.t|
    );

  $obj->menu( title=>"TITLE", text => "TEXT",
              width => 64, height => 16,
              list => [ "tag0", "item0", "tag1", "item1" ] );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --list --separator '\n' --column " " --column " " "tag0" "item0" "tag1" "item1"|
    );

  $obj->checklist( title=>"TITLE", text => "TEXT",
                   width => 64, height => 16,
                   list => [ "tag0", [ "item0", 0 ], "tag1", [ "item1", 1 ] ] );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --list --checklist --separator '\n' --column " " --column " " --column " " "FALSE" "tag0" "item0" "TRUE" "tag1" "item1"|
    );

  $obj->radiolist( title=>"TITLE", text => "TEXT",
                   width => 64, height => 16,
                   list => [ "tag0", [ "item0", 0 ], "tag1", [ "item1", 1 ] ] );
  is( $obj->get_unit_test_result(),
      $bin.q| --title TITLE --width 64 --height 16 --list --radiolist --separator '\n' --column " " --column " " --column " " "FALSE" "tag0" "item0" "TRUE" "tag1" "item1"|
    );

  done_testing();
}