File: test.pl

package info (click to toggle)
zenity 4.1.99-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,704 kB
  • sloc: ansic: 6,042; perl: 533; sh: 92; xml: 75; makefile: 9
file content (665 lines) | stat: -rwxr-xr-x 18,689 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
#!/usr/bin/env perl

# vim: ts=4 sw=4 linebreak breakindent breakindentopt=shift\:4

use strict;
use warnings;
use v5.12;

my $ZENITY = $ENV{ZENITY} || 'zenity';

my %tests;
my $n_tests_passed = 0;
my $n_tests_failed = 0;

my @all_dialogs = (qw[
	--calendar
	--entry
	--error
	--info
	--file-selection
	--list
	--notification
	--progress
	--question
	--warning
	--scale
	--text-info
	--color-selection
	--password
	--forms
	]);

my @all_dialogs_except_notification = @all_dialogs;
{
	for (my $index = 0; $all_dialogs_except_notification[$index]; ++$index)
	{
		if ($all_dialogs_except_notification[$index] eq '--notification') {
			splice @all_dialogs_except_notification, $index, 1;
			last;
		}
	}
}

sub get_dialogs_with_plain_vanilla_options
{
	my $arrRef = shift;
	my @retval;

	foreach my $d (@$arrRef)
	{
		# special case: list & notification - can't be run without arguments.
		if ($d eq '--list') {
			$d .= ' --column=foo foo';
		} elsif ($d eq '--notification') {
			$d .= ' --text=test';
		# special case: progress - can't click ok until percentage full
		} elsif  ($d eq '--progress') {
			$d .= ' --percentage=100';
		}

		push @retval, $d;
	}

	return @retval;
}

sub usage
{
	say "Usage: '$0 [test_name]' or '$0' with no arguments to run all tests. '$0 --help' to list tests.";
	exit 1;
}

sub print_tests_and_exit
{
	say "Available tests:";
	say join(', ', sort keys %tests);
	exit 1;
}

sub test_passed
{
	my $test_name = shift;

	my $str = "\tPASSED";
	if (defined $test_name) {
		$str = "$test_name: $str";
	}

	say $str;
	++$n_tests_passed;
}

sub test_failed
{
	my $test_name = shift;

	my $str = "\tFAILED";
	if (defined $test_name) {
		$str = "$test_name: $str";
	}

	say $str;
	++$n_tests_failed;
}

sub test_summary
{
	say '***** TEST SUMMARY *****';
	say "Tests passed: $n_tests_passed";
	say "Tests failed: $n_tests_failed";

	if ($n_tests_failed > 0) {
		exit 1;
	} else {
		exit 0;
	}
}

sub get_exit_status
{
	my $raw = $?;
	return $raw ? $raw >> 8 : 0;
}

sub create_test
{
	my ($test_basename, $test_desc, $test_subRef) = @_;
	my $subRef = undef;

	$subRef = sub {
		say "***** RUNNING TEST: $test_basename *****";
		say "\t$test_desc";
		&$test_subRef ();
		say "***** TEST FINISHED *****";
		say '';
	};

	$tests{$test_basename} = $subRef;
}

sub test_cmd_for_exit_status
{
	my ($cmd, $target_exit_status) = @_;
	my $output;
	my $exit_status;

	say "Running command: $cmd";
	$output = `$cmd >/dev/null 2>&1`;
	$exit_status = get_exit_status ();
	say "\ttarget exit status: $target_exit_status";
	say "\tgot exit status: $exit_status";

	if ($exit_status == $target_exit_status) {
		test_passed ();
	} else {
		test_failed ();
	}
}

sub sort_multi_stdout_list {
	my ($input_string, $separator) = @_;

	if (length($separator) != 1) {
		warn "Invalid separator: $separator (must be one character)\n";
		return;
	}

	my @matches = split /\Q$separator\E/, $input_string;
	my @sorted_matches = sort @matches;
	my $output_string = join $separator, @sorted_matches;

	return $output_string;
}

sub test_cmd_for_stdout
{
	my ($cmd, $expected_stdout, $multi_separator) = @_;

	say "Running command: $cmd";
	my $stdout = `$cmd`;

	chomp $stdout;

	if ($multi_separator) {
		$stdout = sort_multi_stdout_list ($stdout, $multi_separator);
		$expected_stdout = sort_multi_stdout_list ($expected_stdout, $multi_separator);
	}

	say "\t\tExpected stdout: $expected_stdout";
	say "\t\tGot stdout: $stdout";

	if ($stdout eq $expected_stdout) {
		test_passed ();
	} else {
		test_failed ();
	}
}

sub do_twice_in_parallel
{
	my $cmd = shift;

	print "Performing twice in parallel: $cmd\t\t";

	my %retval;
	my $pid = fork;

	die "$0: Could not fork" unless defined $pid;

	# child
	if ($pid == 0) {
		my $dummy_stdout = `$cmd`;
		my $exit_status;

		$exit_status = get_exit_status ();

		exit $exit_status;
	}
	# parent
	else {
		my $dummy_stdout = `$cmd`;

		$retval{exit_status1} = get_exit_status ();

		waitpid $pid, 0;
		$retval{exit_status2} = get_exit_status ();
	}

	print "[DONE]\n";

	return %retval;
}

create_test ("timeout",
	"Please allow these dialogs to close themselves while the test runs.",
	sub {
		my $timeout_exit_status = 5;
		my @dialogs = get_dialogs_with_plain_vanilla_options (\@all_dialogs);

		foreach my $d (@dialogs)
		{
			my $test = "$ZENITY $d --timeout=1";

			test_cmd_for_exit_status ($test, $timeout_exit_status);
		}
	}
);

create_test ("checklist_search",
	"Type 'fruit', select all checkboxes that appear, and click OK",
	sub {
		my $cmd = "$ZENITY --width=640 --height=480 --list --checklist --column=Check --column=Produce FALSE 'Apple fruit' FALSE 'Orange fruit' FALSE 'Carrot veg' FALSE 'Celery veg'";
		my $expected_stdout = 'Apple fruit|Orange fruit';

		test_cmd_for_stdout ($cmd, $expected_stdout);
	}
);

create_test ("radiolist_search",
	"Type 'fruit', select the first (and only) radio button that appears, and click OK",
	sub {
		my $cmd = "$ZENITY --width=640 --height=480 --list --radiolist --column=Radio --column=Produce FALSE 'Onion veg' FALSE 'Apple fruit' FALSE 'Carrot veg' FALSE 'Celery veg'";
		my $expected_stdout = 'Apple fruit';

		test_cmd_for_stdout ($cmd, $expected_stdout);
	}
);

create_test ("list_search_multi",
	"Type 'fruit', select all list items that appear, and click OK",
	sub {
		my $cmd = "$ZENITY --width=640 --height=480 --list --multiple --print-column=2 --column=Junk --column=Produce Candy 'Apple fruit' Chocolate 'Orange fruit' Chips 'Carrot veg' Fries 'Celery veg' Soda 'Grapefruit juice'";
		my $expected_stdout = 'Apple fruit|Orange fruit|Grapefruit juice';
		my $stdout = `$cmd`;

		chomp $stdout;

		say "\t\tExpected stdout: $expected_stdout";
		say "\t\tGot stdout: $stdout";

		if ($stdout eq $expected_stdout) {
			test_passed ();
		} else {
			test_failed ();
		}
	}
);

create_test ("ok_button",
	"Click the affirmative (OK, Yes, etc) on all dialogs that appear.",
	sub {
		foreach my $d (get_dialogs_with_plain_vanilla_options (\@all_dialogs_except_notification))
		{
			my $test = "$ZENITY $d";
			my $ok_exit_status = 0;
			my $custom_exit_status = 111;

			test_cmd_for_exit_status ($test, $ok_exit_status);

			$test = "ZENITY_OK=$custom_exit_status $test";
			test_cmd_for_exit_status ($test, $custom_exit_status);
		}
	}
);

create_test ("custom_title",
	"Check the dialogs to ensure there is a custom title visible called 'FOOBAR'.\nIf so, click the affirmative (OK, Yes, etc) on all dialogs that appear.",
	sub {
		foreach my $d (get_dialogs_with_plain_vanilla_options (\@all_dialogs_except_notification))
		{
			my $test = "$ZENITY $d --title='FOOBAR'";
			my $ok_exit_status = 0;

			test_cmd_for_exit_status ($test, $ok_exit_status);
		}
	}
);

create_test ("esc_or_close",
	"Close the dialogs (or hit the ESC key) on all dialogs that appear",
	sub {
		foreach my $d (get_dialogs_with_plain_vanilla_options (\@all_dialogs_except_notification))
		{
			my $test = "$ZENITY $d";
			my $esc_exit_status = 1;
			my $custom_exit_status = 222;

			test_cmd_for_exit_status ($test, $esc_exit_status);

			$test = "ZENITY_ESC=$custom_exit_status $test";
			test_cmd_for_exit_status ($test, $custom_exit_status);
		}
	}
);

create_test ("cancel_button",
	"Click the negative (Cancel, No, etc.) on all dialogs that appear",
	sub {
		# easier to just specify these dialogs which have cancel buttons manually :-(
		my @dialogs = qw[--calendar --entry --file-selection --list --progress --scale --color-selection --password --forms];
		foreach my $d (get_dialogs_with_plain_vanilla_options (\@dialogs))
		{
			my $test = "$ZENITY $d";
			my $cancel_exit_status = 1;
			my $custom_exit_status = 222;

			test_cmd_for_exit_status ($test, $cancel_exit_status);

			$test = "ZENITY_CANCEL=$custom_exit_status $test";
			test_cmd_for_exit_status ($test, $custom_exit_status);
		}
	}
);

create_test ("custom_ok_cancel_buttons",
	"Ensure that both the OK and Cancel buttons contain a frowny- or smiley-faced cat emoji respetively, and click the smiley face. If either okay or cancel do not contain the kitty emoji, click cancel or close the window.",
	sub {
		# mostly the same as the Cancel dialogs - but custom ok/cancel labels is NOT supported for --file-selection
		my @dialogs = qw[--calendar --entry --list --progress --scale --color-selection --password --forms];
		foreach my $d (get_dialogs_with_plain_vanilla_options (\@dialogs))
		{
			my $test = qq[$ZENITY $d --ok-label="😺" --cancel-label="😾"];
			my $expected_exit_status = 0;

			test_cmd_for_exit_status ($test, $expected_exit_status);
		}
	}
);

create_test ("test_entry",
	"Follow the instructions on the dialogs",
	sub {
		my $expected_stdout = 'foo bar baz';
		my $cmd1 = "$ZENITY --entry --text='Click OK' --entry-text='$expected_stdout'";

		test_cmd_for_stdout ($cmd1, $expected_stdout);

		my $cmd2 = "$ZENITY --entry --hide-text --text='Click OK if you see dots; click Cancel if you see plaintext' --entry-text='$expected_stdout'";

		test_cmd_for_stdout ($cmd2, $expected_stdout);
	}
);

create_test ("test_text_info",
	"Type 'foobar' in the textview and click OK",
	sub {
		my $expected_stdout = 'foobar';
		my $cmd = "$ZENITY --text-info --editable";

		test_cmd_for_stdout ($cmd, $expected_stdout);
	}
);

create_test ("test_text_info_font",
	"Type 'foobar' in the textview.\n\tClick OK the text is monospace. Otherwise, click Cancel or close window.",
	sub {
		my $expected_stdout = 'foobar';
		my $cmd = "$ZENITY --text-info --editable --font=monospace";

		test_cmd_for_stdout ($cmd, $expected_stdout);
	}
);

create_test ("multiple_zenity_instances",
	"Wait for both dialogs to terminate",
	sub {
		my $expected_exit_status = 5;
		my $cmd = "$ZENITY --info --timeout=3";
		my %retval = do_twice_in_parallel ($cmd);

		say "\t\tExpected exit status: $expected_exit_status";
		say "\t\tGot exit status #1: $retval{exit_status1}";
		say "\t\tGot exit status #2: $retval{exit_status2}";

		if ($expected_exit_status == $retval{exit_status1} == $retval{exit_status2})
		{
			test_passed ();
		}
		else
		{
			test_failed ();
		}
	}
);

create_test ("issue_72_list_infloop",
	"Double-click the item in the list within 20 seconds (this test only applicable to GTK 4.12+)",
	sub {
		my $expected_exit_status = 0;
		my $cmd = <<"EOF";

# Running the following script:
$ZENITY --list --column=foo foo &
pid=\$!

sleep 20

if ps -p \$pid >/dev/null; then
  kill -TERM \$pid
  exit 1
else
  exit 0
fi
EOF
		test_cmd_for_exit_status ($cmd, 0);
	}
);

# --list has a LOT of options. Let's make sure they actually work.
create_test ("list_o_mania",
	"Change the 3 items in this list to foo, bar and baz respectively, and check all the boxes.",
	sub {
		my $cmd = qq[$ZENITY --list --width=640 --height=480 --checklist --editable --column=Check --column=Crap --column=Item --print-column=2,3 --hide-header --hide-column=2 --text="Follow the instructions on the terminal.\nThis dialog should have checkboxes but should NOT have headers.\nIt should contain only the checkbox and the words Alpha, Beta and Gamma.\nIf any of this isn't the case, click Cancel or close the window." --separator=',' FALSE Bleh Alpha FALSE Meh Beta FALSE Blah Gamma];
		test_cmd_for_stdout ($cmd, 'Bleh,foo,Meh,bar,Blah,baz');
	}
);

# ... same with --forms
create_test ("forms_options",
	"For 'My entry', enter 'foo'; for 'My password' enter 'bar'; for 'My text info' enter 'baz<return>boo'\n\tKeep today's date selected for the calendar; select the first item in the list;\n\tselect the second item in both dropdowns.",
	sub {
		my $cmd = qq[$ZENITY --forms --add-entry='My entry' --add-password='My password' --add-calendar='My calendar' --add-list='My list' --list-values='foo bar|baz boo|bleh blah|boo urns' --column-values='foo|bar' --add-combo='My combo box' --combo-values='combo1|combo2|combo3' --add-combo='My other combo box' --combo-values='combo4|combo5|combo6' --show-header --text="My Form" --separator='^' --forms-date-format='%F' --add-multiline-entry='My text info'];
		my $iso_date = `date --iso-8601`;
		chomp $iso_date;
		my $expected_stdout = "foo^bar^$iso_date^foo bar,baz boo,^combo2^combo5^baz\nboo";

		test_cmd_for_stdout ($cmd, $expected_stdout);
	}
);

create_test ("test_progress",
	"Allow these progress dialogs to close themselves unless the dialog says otherwise",
	sub {
		my $ok_exit_status = 0;
		my $cancel_exit_status = 1;
		my $error_exit_status = 255;
		my $pulsate_opt_cmd = "sleep 3 | $ZENITY --progress --pulsate --auto-close";

		test_cmd_for_exit_status ($pulsate_opt_cmd, $ok_exit_status);

		# --auto-close and --percentage=100 not supported.
		my $percentage_100_cmd = "$ZENITY --progress --auto-close --percentage=100";

		test_cmd_for_exit_status ($percentage_100_cmd, $error_exit_status);

		my $cancel_progress_cmd = "ping 127.0.0.1 | $ZENITY --progress --text='Click Cancel please' --pulsate";

		test_cmd_for_exit_status ($cancel_progress_cmd, $cancel_exit_status);

		my $auto_close_cmd = <<"EOF";
(
sleep 5;
echo "10" ; sleep 2
echo "# Blah1" ; sleep 2
echo "20" ; sleep 2
echo "# Blah2" ; sleep 2
echo "50" ; sleep 2
echo "If you see this line, click Cancel" ; sleep 4
echo "75" ; sleep 2
echo "# Blah3" ; sleep 2
echo "100" ; sleep 2
) |
$ZENITY --progress \\
  --auto-close \\
  --percentage=0 \\
  --text='Let this dialog auto-close.\\n\\nTime remaining should be shown in a few seconds after the progress bar starts.\\n\\nIf time remaining is not shown by \`Blah3\`, click Cancel.' \\
  --time-remaining
EOF

		test_cmd_for_exit_status ($auto_close_cmd, $ok_exit_status);

		my $pulsate_from_stdin_cmd = <<"EOF";
(
echo pulsate: true
sleep 5
echo pulsate: false
echo 99
sleep 1
echo 100
) |
$ZENITY --progress --auto-close --text='Progress should pulsate for about 5 seconds.\\n\\nIf not, click Cancel.'
EOF
		test_cmd_for_exit_status ($pulsate_from_stdin_cmd, $ok_exit_status);
	}
);

create_test ("test_icon",
	"Click OK (or Yes/affirmative answer) if you see a star icon on these dialogs",
	sub {
		my $expected_exit_status = 0;
		foreach my $opt ('--error', '--info', '--question', '--warning')
		{
			my $cmd = "$ZENITY $opt --icon=starred";
			test_cmd_for_exit_status ($cmd, $expected_exit_status);
		}
	}
);

create_test ("test_ellipsize",
	"If you see a '...' at the end of the dialog text, click OK (or Yes/affirmative answer).\n\n\tOtherwise, click Cancel or close the dialog.",
	sub {
		my $expected_exit_status = 0;
		foreach my $opt ('--error', '--info', '--question', '--warning')
		{
			my $cmd = "$ZENITY $opt --text='asfdsafdsfadsfdsafasdfadsfdsafadsfdsafadsfsadfasdfasdfsadfadsfadsfadsfadsfadsfadsfadsfadsfadsf' --ellipsize";
			test_cmd_for_exit_status ($cmd, $expected_exit_status);
		}
	}
);

create_test ("test_no_markup",
	"If you see a visible '\\n', click OK (or affirmative answer).\n\n\tIf you see a linebreak, click Cancel/negative answer/close the dialog.",
	sub {
		my $expected_exit_status = 0;
		foreach my $opt ('--error', '--info', '--question', '--warning')
		{
			my $cmd = "$ZENITY $opt --no-markup --text='foo\\nbar'";
			test_cmd_for_exit_status ($cmd, $expected_exit_status);
		}
	}
);

create_test ("issue_75_ensure_num_entries",
	"3 entry dialogs will appear. For #1, just click OK.\n\tFor #2, select the 2nd item and click OK.\n\tFor #3, select the 3rd item and click OK.\n\tIf there is no 2nd (or 3rd) item for #2 or #3, click Cancel.",
	sub {
		my $expected_stdout = 'foo bar';
		my $cmd1 = "$ZENITY --entry --entry-text 'foo bar'";
		my $cmd2 = "$ZENITY --entry --entry-text 'baz boo' 'foo bar'";
		my $cmd3 = "$ZENITY --entry --entry-text 'bleh bah' 'baz boo' 'foo bar'";

		foreach ($cmd1, $cmd2, $cmd3) {
			test_cmd_for_stdout ($_, $expected_stdout);
		}
	}
);

create_test ("test_calendar",
	"Some calendars will appear. Follow the instructions on each dialog.",
	sub {
		my $iso_date = `date --iso-8601`;
		chomp $iso_date;
		my $base_cmd = "$ZENITY --calendar --date-format='%F'";

		test_cmd_for_stdout (qq[$base_cmd --text="Ensure today's date is selected and click OK. If the date is wrong, click Cancel."], $iso_date);
		test_cmd_for_stdout (qq[$base_cmd --text="Select November 11, 1985 and click OK."], '1985-11-11');
		test_cmd_for_stdout (qq[$base_cmd --text="Click OK." --day=29 --month=2 --year=2024], '2024-02-29');
	}
);

create_test ("file_selection",
	"Some file selection dialogs will appear.\n\tFollow the instructions that appear in the console for each dialog.\n\tYou will need write permission to /tmp for this test to work.",
	sub {
		my $tmpfile;
		my $expected_stdout;
		my $base_cmd = "$ZENITY --file-selection";

		chomp($tmpfile = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		say "\nClick OK. If OK is greyed out, click Cancel.";
		test_cmd_for_stdout (qq[$base_cmd --filename="$tmpfile"], "$tmpfile");
		unlink $tmpfile;

		chomp($tmpfile = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		unlink $tmpfile;
		say "\nClick OK. If OK is greyed out, click Cancel.";
		test_cmd_for_stdout (qq[$base_cmd --save --filename="$tmpfile"], "$tmpfile");

		chomp($tmpfile = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		unlink $tmpfile;
		say "\nClick OK. If OK is greyed out, click Cancel.";
		test_cmd_for_stdout (qq[$base_cmd --save --filename="file://$tmpfile"], "$tmpfile");

		chomp($tmpfile = `mktemp -d /tmp/zenity_test.XXXXXXXXXX`);
		say "\nEnter abcd then Click OK. If OK is greyed out, click Cancel.";
		test_cmd_for_stdout (qq[$base_cmd --save --filename="$tmpfile/"], "${tmpfile}/abcd");
		rmdir $tmpfile;

		chomp($tmpfile = `mktemp -d /tmp/zenity_test.XXXXXXXXXX`);
		say "\nEnter abcd then Click OK. If OK is greyed out, click Cancel.";
		test_cmd_for_stdout (qq[$base_cmd --save --filename="file://$tmpfile/"], "${tmpfile}/abcd");
		rmdir $tmpfile;

		my $tmpfile2;

		chomp($tmpfile = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		chomp($tmpfile2 = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		say "\nSelect BOTH temporary files (one has been pre-selected) and click OK.";
		test_cmd_for_stdout (qq[$base_cmd --multiple --file-filter="zenity_test.*" --filename="$tmpfile"], "${tmpfile}|${tmpfile2}", '|');
		unlink $tmpfile;
		unlink $tmpfile2;

		chomp($tmpfile = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		chomp($tmpfile2 = `mktemp /tmp/zenity_test.XXXXXXXXXX`);
		say "\nSelect BOTH temporary files (one has been pre-selected) and click OK.";
		test_cmd_for_stdout (qq[$base_cmd --multiple --file-filter="zenity_test.*" --separator="~" --filename="$tmpfile"], "${tmpfile}~${tmpfile2}", '~');
		unlink $tmpfile;
		unlink $tmpfile2;
	}
);

# MAIN

if ($ARGV[0])
{
	if ($ARGV[0] eq '--help') {
		print_tests_and_exit ();
	}

	foreach my $arg (@ARGV)
	{
		if ($tests{$arg}) {
			$tests{$arg}();
		} else {
			usage ();
		}
	}
}
else
{
	foreach my $key (sort keys %tests)
	{
		$tests{$key}();
	}
}

test_summary();