]> git.sur5r.net Git - i3/i3/blob - testcases/t/05-ipc.t
Merge branch 'next'
[i3/i3] / testcases / t / 05-ipc.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use Test::More tests => 4;
5 use Test::Deep;
6 use X11::XCB qw(:all);
7 use Data::Dumper;
8 use Time::HiRes qw(sleep);
9 use FindBin;
10 use lib "$FindBin::Bin/lib";
11 use i3test;
12
13 BEGIN {
14     use_ok('IO::Socket::UNIX') or BAIL_OUT('Cannot load IO::Socket::UNIX');
15     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
16 }
17
18 my $x = X11::XCB::Connection->new;
19
20 my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
21
22 isa_ok($sock, 'IO::Socket::UNIX');
23
24
25 #####################################################################
26 # Ensure IPC works by switching workspaces
27 #####################################################################
28
29 # Switch to the first workspace to get a clean testing environment
30 $sock->write(i3test::format_ipc_command("1"));
31
32 sleep(0.25);
33
34 # Create a window so we can get a focus different from NULL
35 my $window = i3test::open_standard_window($x);
36 diag("window->id = " . $window->id);
37
38 sleep(0.25);
39
40 my $focus = $x->input_focus;
41 diag("old focus = $focus");
42
43 # Switch to the nineth workspace
44 $sock->write(i3test::format_ipc_command("9"));
45
46 sleep(0.25);
47
48 my $new_focus = $x->input_focus;
49 isnt($focus, $new_focus, "Focus changed");
50
51 diag( "Testing i3, Perl $], $^X" );