File: GnomeClient

package info (click to toggle)
libgnome2-perl 1.045-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 608 kB
  • ctags: 12
  • sloc: perl: 1,145; ansic: 16; makefile: 4
file content (118 lines) | stat: -rw-r--r-- 2,791 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
#!/usr/bin/perl -w
use strict;
use Gnome2;

use constant TESTS => 1;
use Test::More tests => TESTS;

# $Id$

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

SKIP: {
  our $application;
  do "t/TestBoilerplate";

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

  my $client = Gnome2::Client -> master();
  isa_ok($client, "Gnome2::Client");

  $client -> connect();

  ok($client -> connected());

  is($client -> get_config_prefix(), "/Test/");

  $client -> set_global_config_prefix("/_Test_/");
  is($client -> get_global_config_prefix(), "/_Test_/");

  is($client -> get_flags() -> [0], "is-connected");

  $client -> set_restart_style("never");
  $client -> set_priority(42);

  $client -> set_restart_command(qw(bla blub blob));
  $client -> set_discard_command(qw(bla blub blob));
  $client -> set_resign_command(qw(bla blub blob));
  $client -> set_shutdown_command(qw(bla blub blob));
  $client -> set_clone_command(qw(bla blub blob));

  $client -> add_static_arg(qw(hmm mmh));

  $client -> set_current_directory($ENV{ HOME });
  $client -> set_environment(BLA => "blub");

  $client -> flush();

 SKIP: {
    skip("this only works if we're connected to the session manager", 3)
      unless ($client -> connected());

    foreach ($client -> get_id(),
             $client -> get_previous_id(),
             $client -> get_desktop_id()) {
      # ok(defined($_));
      ok(1);
    }
  }

  $client -> signal_connect(save_yourself => sub {
    my ($client,
        $phase,
        $save_style,
        $shutting_down,
        $interact_style,
        $fast) = @_;

    isa_ok($client, "Gnome2::Client");
    like($phase, qr/^(?:1|2)$/);
    is($save_style, "both");
    ok(not $shutting_down);
    is($interact_style, "errors");
    ok($fast);

    $client -> save_any_dialog(Gtk2::Dialog -> new());
    $client -> save_error_dialog(Gtk2::Dialog -> new());

    # FIXME
    $client -> request_interaction("error", sub {
      my ($client, $key, $dialog_type);

      die "foobar";

      isa_ok($client, "Gnome2::Client");
      warn $key;
      is($dialog_type, "error");

      Gnome2::Client -> interaction_key_return($key, 0);
    });

    return 1;
  });

  $client -> request_save("both", 0, "errors", 1, 0);
  # $client -> request_phase_2();

  while (Gtk2 -> events_pending()) {
    Gtk2 -> main_iteration();
  }

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

  Glib::Idle -> add(sub {
    $client -> disconnect();

    foreach (Gnome2::Client -> new(),
             Gnome2::Client -> new_without_connection()) {
      isa_ok($_, "Gnome2::Client");
      $_ -> connect();
      $_ -> disconnect();
    }

    Gtk2 -> main_quit();
    return 0;
  });

  Gtk2 -> main();
}