2009-08-05 15:37:11 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
|
|
|
use Test::More tests => 4;
|
|
|
|
use Test::Deep;
|
|
|
|
use X11::XCB qw(:all);
|
|
|
|
use Data::Dumper;
|
|
|
|
use Time::HiRes qw(sleep);
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/lib";
|
|
|
|
use i3test;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use_ok('IO::Socket::UNIX') or BAIL_OUT('Cannot load IO::Socket::UNIX');
|
|
|
|
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
|
|
|
|
}
|
|
|
|
|
2009-10-26 15:04:37 -04:00
|
|
|
my $x = X11::XCB::Connection->new;
|
2009-08-05 15:37:11 -04:00
|
|
|
|
|
|
|
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
|
|
|
|
|
|
|
|
isa_ok($sock, 'IO::Socket::UNIX');
|
|
|
|
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# Ensure IPC works by switching workspaces
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
# Switch to the first workspace to get a clean testing environment
|
|
|
|
$sock->write(i3test::format_ipc_command("1"));
|
|
|
|
|
|
|
|
sleep(0.25);
|
|
|
|
|
|
|
|
# Create a window so we can get a focus different from NULL
|
2009-10-26 15:04:37 -04:00
|
|
|
my $window = i3test::open_standard_window($x);
|
2009-08-05 15:37:11 -04:00
|
|
|
diag("window->id = " . $window->id);
|
|
|
|
|
|
|
|
sleep(0.25);
|
|
|
|
|
2009-10-26 15:04:37 -04:00
|
|
|
my $focus = $x->input_focus;
|
2009-08-05 15:37:11 -04:00
|
|
|
diag("old focus = $focus");
|
|
|
|
|
|
|
|
# Switch to the nineth workspace
|
|
|
|
$sock->write(i3test::format_ipc_command("9"));
|
|
|
|
|
|
|
|
sleep(0.25);
|
|
|
|
|
2009-10-26 15:04:37 -04:00
|
|
|
my $new_focus = $x->input_focus;
|
2009-08-05 15:37:11 -04:00
|
|
|
isnt($focus, $new_focus, "Focus changed");
|
|
|
|
|
|
|
|
diag( "Testing i3, Perl $], $^X" );
|