contrib
debian
docs
i3-config-wizard
i3-dump-log
i3-input
i3-msg
i3-nagbar
i3bar
include
libi3
man
parser-specs
src
testcases
lib
t
000-load-deps.t
001-tile.t
002-i3-sync.t
003-ipc.t
004-unmanaged.t
005-floating.t
100-fullscreen.t
101-focus.t
102-dock.t
103-move.t
104-focus-stack.t
105-stacking.t
111-goto.t
112-floating-resize.t
113-urgent.t
114-client-leader.t
115-ipc-workspaces.t
116-nestedcons.t
117-workspace.t
118-openkill.t
119-match.t
120-multiple-cmds.t
121-next-prev.t
122-split.t
124-move.t
126-regress-close.t
127-regress-floating-parent.t
128-open-order.t
129-focus-after-close.t
130-close-empty-split.t
131-stacking-order.t
132-move-workspace.t
133-size-hints.t
134-invalid-command.t
135-floating-focus.t
136-floating-ws-empty.t
137-floating-unmap.t
138-floating-attach.t
139-ws-numbers.t
140-focus-lost.t
141-resize.t
142-regress-move-floating.t
143-regress-floating-restart.t
144-regress-floating-resize.t
145-flattening.t
146-floating-reinsert.t
147-regress-floatingmove.t
148-regress-floatingmovews.t
150-regress-dock-restart.t
151-regress-float-size.t
152-regress-level-up.t
153-floating-originalsize.t
154-regress-multiple-dock.t
155-floating-split-size.t
156-fullscreen-focus.t
158-wm_take_focus.t
159-socketpaths.t
161-regress-borders-restart.t
162-regress-dock-urgent.t
163-wm-state.t
164-kill-win-vs-client.t
165-for_window.t
166-assign.t
167-workspace_layout.t
168-regress-fullscreen-restart.t
169-border-toggle.t
170-force_focus_wrapping.t
171-config-migrate.t
172-start-on-named-ws.t
173-get-marks.t
173-regress-focus-assign.t
174-border-config.t
174-regress-focus-toggle.t
175-startup-notification.t
176-workspace-baf.t
177-bar-config.t
178-regress-workspace-open.t
179-regress-multiple-ws.t
180-fd-leaks.t
181-regress-float-border.t
182-regress-focus-dock.t
183-config-variables.t
184-regress-float-split-resize.t
185-scratchpad.t
186-regress-assign-focus-parent.t
187-commands-parser.t
188-regress-focus-restart.t
189-floating-constraints.t
190-scratchpad-diff-ws.t
191-resize-levels.t
192-layout.t
193-ipc-version.t
194-regress-floating-size.t
195-net-active-window.t
196-randr-output-names.t
197-regression-move-vanish.t
198-regression-scratchpad-crash.t
199-ipc-mode-event.t
200-urgency-timer.t
500-multi-monitor.t
501-scratchpad.t
502-focus-output.t
503-workspace.t
504-move-workspace-to-output.t
505-scratchpad-resolution.t
Makefile.PL
Xdummy
complete-run.pl
i3-test.config
restart-state.golden
tests
yajl-fallback
.gitignore
DEPENDS
LICENSE
Makefile
PACKAGE-MAINTAINER
RELEASE-NOTES-4.2
RELEASE-NOTES-4.3
common.mk
generate-command-parser.pl
i3-migrate-config-to-v4
i3-sensible-editor
i3-sensible-pager
i3-sensible-terminal
i3.applications.desktop
i3.config
i3.config.keycodes
i3.xsession.desktop
logo.svg
pseudo-doc.doxygen
183 lines
5.2 KiB
Perl
183 lines
5.2 KiB
Perl
#!perl
|
||
# vim:ts=4:sw=4:expandtab
|
||
#
|
||
# Please read the following documents before working on tests:
|
||
# • http://build.i3wm.org/docs/testsuite.html
|
||
# (or docs/testsuite)
|
||
#
|
||
# • http://build.i3wm.org/docs/lib-i3test.html
|
||
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||
#
|
||
# • http://build.i3wm.org/docs/ipc.html
|
||
# (or docs/ipc)
|
||
#
|
||
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||
# (unless you are already familiar with Perl)
|
||
#
|
||
# Test for the startup notification protocol.
|
||
#
|
||
|
||
use i3test;
|
||
use POSIX qw(mkfifo);
|
||
use File::Temp qw(:POSIX);
|
||
|
||
use ExtUtils::PkgConfig;
|
||
|
||
# setup dependency on libstartup-notification using pkg-config
|
||
my %sn_config;
|
||
BEGIN {
|
||
%sn_config = ExtUtils::PkgConfig->find('libstartup-notification-1.0');
|
||
}
|
||
|
||
use Inline C => Config => LIBS => $sn_config{libs}, CCFLAGS => $sn_config{cflags};
|
||
use Inline C => <<'END_OF_C_CODE';
|
||
|
||
#include <xcb/xcb.h>
|
||
|
||
#define SN_API_NOT_YET_FROZEN 1
|
||
#include <libsn/sn-common.h>
|
||
#include <libsn/sn-launchee.h>
|
||
|
||
static SnDisplay *sndisplay;
|
||
static SnLauncheeContext *ctx;
|
||
static xcb_connection_t *conn;
|
||
|
||
// TODO: this should use $x
|
||
void init_ctx() {
|
||
int screen;
|
||
if ((conn = xcb_connect(NULL, &screen)) == NULL ||
|
||
xcb_connection_has_error(conn))
|
||
errx(1, "x11 conn failed");
|
||
|
||
printf("screen = %d\n", screen);
|
||
sndisplay = sn_xcb_display_new(conn, NULL, NULL);
|
||
ctx = sn_launchee_context_new_from_environment(sndisplay, screen);
|
||
}
|
||
|
||
const char *get_startup_id() {
|
||
return sn_launchee_context_get_startup_id(ctx);
|
||
}
|
||
|
||
void mark_window(int window) {
|
||
sn_launchee_context_setup_window(ctx, (Window)window);
|
||
xcb_flush(conn);
|
||
}
|
||
|
||
void complete_startup() {
|
||
/* mark the startup process complete */
|
||
sn_launchee_context_complete(ctx);
|
||
}
|
||
END_OF_C_CODE
|
||
|
||
my $first_ws = fresh_workspace;
|
||
|
||
is_num_children($first_ws, 0, 'no containers on this workspace yet');
|
||
|
||
######################################################################
|
||
# 1) initiate startup, switch workspace, create window
|
||
# (should be placed on the original workspace)
|
||
######################################################################
|
||
|
||
# Start a new process via i3 (to initialize a new startup notification
|
||
# context), then steal its DESKTOP_STARTUP_ID variable. We handle the startup
|
||
# notification in the testcase from there on.
|
||
#
|
||
# This works by setting up a FIFO in which the process (started by i3) will
|
||
# echo its $DESKTOP_STARTUP_ID. We (blockingly) read the variable into
|
||
# $startup_id in the testcase.
|
||
my $tmp = tmpnam();
|
||
mkfifo($tmp, 0600) or die "Could not create FIFO in $tmp";
|
||
|
||
cmd qq|exec echo \$DESKTOP_STARTUP_ID >$tmp|;
|
||
|
||
open(my $fh, '<', $tmp);
|
||
chomp(my $startup_id = <$fh>);
|
||
close($fh);
|
||
|
||
unlink($tmp);
|
||
|
||
isnt($startup_id, '', 'startup_id not empty');
|
||
|
||
$ENV{DESKTOP_STARTUP_ID} = $startup_id;
|
||
|
||
# Create a new libstartup-notification launchee context
|
||
init_ctx();
|
||
|
||
# Make sure the context was set up successfully
|
||
is(get_startup_id(), $startup_id, 'libstartup-notification returns the same id');
|
||
|
||
my $second_ws = fresh_workspace;
|
||
|
||
is_num_children($second_ws, 0, 'no containers on the second workspace yet');
|
||
|
||
my $win = open_window({ dont_map => 1 });
|
||
mark_window($win->id);
|
||
$win->map;
|
||
# We don’t use wait_for_map because the window will not get mapped -- it is on
|
||
# a different workspace.
|
||
# We sync with i3 here to make sure $x->input_focus is updated.
|
||
sync_with_i3;
|
||
|
||
is_num_children($second_ws, 0, 'still no containers on the second workspace');
|
||
is_num_children($first_ws, 1, 'one container on the first workspace');
|
||
|
||
######################################################################
|
||
# same thing, but with _NET_STARTUP_ID set on the leader
|
||
######################################################################
|
||
|
||
my $leader = open_window({ dont_map => 1 });
|
||
mark_window($leader->id);
|
||
|
||
$win = open_window({ dont_map => 1, client_leader => $leader });
|
||
$win->map;
|
||
sync_with_i3;
|
||
|
||
is_num_children($second_ws, 0, 'still no containers on the second workspace');
|
||
is_num_children($first_ws, 2, 'two containers on the first workspace');
|
||
|
||
######################################################################
|
||
# 2) open another window after the startup process is completed
|
||
# (should be placed on the current workspace)
|
||
######################################################################
|
||
|
||
complete_startup();
|
||
sync_with_i3;
|
||
|
||
my $otherwin = open_window;
|
||
is_num_children($second_ws, 1, 'one container on the second workspace');
|
||
|
||
######################################################################
|
||
# 3) test that the --no-startup-id flag for exec leads to no DESKTOP_STARTUP_ID
|
||
# environment variable.
|
||
######################################################################
|
||
|
||
mkfifo($tmp, 0600) or die "Could not create FIFO in $tmp";
|
||
|
||
cmd qq|exec --no-startup-id echo \$DESKTOP_STARTUP_ID >$tmp|;
|
||
|
||
open($fh, '<', $tmp);
|
||
chomp($startup_id = <$fh>);
|
||
close($fh);
|
||
|
||
unlink($tmp);
|
||
|
||
is($startup_id, '', 'startup_id empty');
|
||
|
||
######################################################################
|
||
# 4) same thing, but with double quotes in exec
|
||
######################################################################
|
||
|
||
mkfifo($tmp, 0600) or die "Could not create FIFO in $tmp";
|
||
|
||
cmd qq|exec --no-startup-id "echo \$DESKTOP_STARTUP_ID >$tmp"|;
|
||
|
||
open($fh, '<', $tmp);
|
||
chomp($startup_id = <$fh>);
|
||
close($fh);
|
||
|
||
unlink($tmp);
|
||
|
||
is($startup_id, '', 'startup_id empty');
|
||
|
||
done_testing;
|