Debian Codegraph @

debian/tests/libportal-gtk4-dev

raw
1 #!/bin/sh
2 # Copyright 2022 Simon McVittie
3 # SPDX-License-Identifier: LGPL-2.1-or-later
4
5 set -e
6 exec 2>&1
7 set -u
8 set -x
9
10 cd "$AUTOPKGTEST_TMP"
11 HOME="$(pwd)"
12 export GTK_A11Y=none
13 export HOME
14 export NO_AT_BRIDGE=1
15
16 if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
17 CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
18 else
19 CROSS_COMPILE=
20 fi
21
22 cat > test.c <<'EOF'
23 #include <libportal-gtk4/portal-gtk4.h>
24
25 static gboolean go = TRUE;
26
27 static gboolean
28 do_quit (gpointer user_data)
29 {
30 go = FALSE;
31 return G_SOURCE_REMOVE;
32 }
33
34 int main (int argc, char *argv[])
35 {
36 GtkWidget *dialog = NULL;
37 XdpParent *parent = NULL;
38
39 gtk_init ();
40 dialog = g_object_ref_sink (gtk_about_dialog_new ());
41 g_timeout_add_seconds (1, do_quit, NULL);
42 gtk_window_present (GTK_WINDOW (dialog));
43 parent = xdp_parent_new_gtk (GTK_WINDOW (dialog));
44 g_assert_nonnull (parent);
45
46 while (go)
47 g_main_context_iteration (NULL, TRUE);
48
49 xdp_parent_free (parent);
50 g_object_unref (dialog);
51
52 return 0;
53 }
54 EOF
55
56 # Deliberately word-splitting, that's how pkg-config works:
57 # shellcheck disable=SC2046
58 "${CROSS_COMPILE}gcc" -g -o test test.c $("${CROSS_COMPILE}pkgconf" --cflags --libs libportal-gtk4 gtk4)
59 test -x ./test
60 set -- ./test
61
62 if [ -z "${TEST_INTERACTIVE-}" ]; then
63 export GDK_BACKEND=x11
64 set -- xvfb-run -a dbus-run-session -- "$@"
65 fi
66
67 "$@"