File: GtkPageSetup.t

package info (click to toggle)
libgtk2-perl 1%3A1.190-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,132 kB
  • ctags: 516
  • sloc: perl: 16,575; sh: 149; ansic: 148; makefile: 76
file content (82 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download
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
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper
  tests => 18,
  at_least_version => [2, 10, 0, "GtkPageSetup is new in 2.10"];

# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkPageSetup.t,v 1.4 2007/09/15 14:33:00 kaffeetisch Exp $

my $setup = Gtk2::PageSetup -> new();
isa_ok($setup, "Gtk2::PageSetup");

$setup -> set_orientation("landscape");
is($setup -> get_orientation(), "landscape");

my $size = Gtk2::PaperSize -> new("iso_a4");

$setup -> set_paper_size($size);
isa_ok($setup -> get_paper_size(), "Gtk2::PaperSize");

$setup -> set_top_margin(23, "mm");
is($setup -> get_top_margin("mm"), 23);

$setup -> set_bottom_margin(23, "mm");
is($setup -> get_bottom_margin("mm"), 23);

$setup -> set_left_margin(23, "mm");
is($setup -> get_left_margin("mm"), 23);

$setup -> set_right_margin(23, "mm");
is($setup -> get_right_margin("mm"), 23);

$setup -> set_paper_size_and_default_margins($size);

ok(defined $setup -> get_paper_width("mm"));
ok(defined $setup -> get_paper_height("mm"));
ok(defined $setup -> get_page_width("mm"));
ok(defined $setup -> get_page_height("mm"));

SKIP: {
  skip "new 2.12 stuff", 7
    unless Gtk2->CHECK_VERSION (2, 12, 0);

  my $new_setup;
  $setup -> set_top_margin(23, 'mm');

  my $file = 'tmp.setup';

  eval {
    $setup -> to_file($file);
  };
  is($@, '');

  eval {
    $new_setup = Gtk2::PageSetup -> new_from_file($file);
  };
  is($@, '');
  isa_ok($new_setup, 'Gtk2::PageSetup');
  is($new_setup -> get_top_margin('mm'), 23);

  my $key_file = Glib::KeyFile -> new();
  my $group = undef;
  $setup -> to_key_file($key_file, $group);
  open my $fh, '>', $file or skip 'key file tests', 3;
  print $fh $key_file -> to_data();
  close $fh;

  $key_file = Glib::KeyFile -> new();
  eval {
    $key_file -> load_from_file($file, 'none');
    $new_setup = Gtk2::PageSetup -> new_from_key_file($key_file, $group);
  };
  is($@, '');
  isa_ok($new_setup, 'Gtk2::PageSetup');
  is($new_setup -> get_top_margin('mm'), 23);

  unlink $file;
}

__END__

Copyright (C) 2006 by the gtk2-perl team (see the file AUTHORS for the
full list).  See LICENSE for more information.