summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-03-12 18:36:21 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2017-05-03 15:10:53 +0100
commitd276cd47a5db26718f03b84ca3586a4fc5475f1b (patch)
treee03410ef300a9bc6e917dd3a92923213b0e9d30f /tests
parent08153c38547f0e23ab3f22844f5a0537c7095d65 (diff)
downloadgtk+-d276cd47a5db26718f03b84ca3586a4fc5475f1b.tar.gz
meson: tests: make tests find resources from the source dir
Should probably also do this in the autotools build, since the same problem exists there as well if we use srcdir != builddir.
Diffstat (limited to 'tests')
-rw-r--r--tests/meson.build10
-rw-r--r--tests/testdialog.c5
-rw-r--r--tests/testgiconpixbuf.c5
-rw-r--r--tests/testgtk.c6
-rw-r--r--tests/testiconview.c5
-rw-r--r--tests/testpopover.c5
-rw-r--r--tests/testselectionmode.c5
-rw-r--r--tests/testsplitheaders.c5
-rw-r--r--tests/teststackedheaders.c5
9 files changed, 48 insertions, 3 deletions
diff --git a/tests/meson.build b/tests/meson.build
index 34bd68aff0..2435e3d0e4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -137,12 +137,16 @@ if x11_enabled
gtk_tests += [['testerrors']]
endif
-# TODO: need to pass source dir so progs can find .ui files and such
-# (with autotools this only works in the builddir == srcdir case)
+# Pass the source dir here so programs can change into the source directory
+# and find .ui files and .png files and such that they load at runtime
+test_args = ['-DGTK_SRCDIR="@0@"'.format(meson.current_source_dir())]
+
foreach t : gtk_tests
test_name = t.get(0)
test_srcs = ['@0@.c'.format(test_name), t.get(1, [])]
- executable(test_name, test_srcs, dependencies: [libgtk_dep, libm])
+ executable(test_name, test_srcs,
+ c_args : test_args,
+ dependencies : [libgtk_dep, libm])
endforeach
subdir('visuals')
diff --git a/tests/testdialog.c b/tests/testdialog.c
index 941acfdba1..07eba4b7b9 100644
--- a/tests/testdialog.c
+++ b/tests/testdialog.c
@@ -1,4 +1,5 @@
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
static void
show_message_dialog1 (GtkWindow *parent)
@@ -316,6 +317,10 @@ main (int argc, char *argv[])
GtkWidget *box;
GtkWidget *button;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
diff --git a/tests/testgiconpixbuf.c b/tests/testgiconpixbuf.c
index 8e9b7af587..fd9ab1d558 100644
--- a/tests/testgiconpixbuf.c
+++ b/tests/testgiconpixbuf.c
@@ -17,6 +17,7 @@
*/
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
int
main (int argc,
@@ -28,6 +29,10 @@ main (int argc,
GEmblem *emblem;
gchar *str;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 082ea55e0b..93f8c96928 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -37,6 +37,8 @@
#include <unistd.h>
#endif
+#include <glib/gstdio.h>
+
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
@@ -8805,6 +8807,10 @@ main (int argc, char *argv[])
g_set_application_name ("GTK+ Test Program");
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
provider = gtk_css_provider_new ();
diff --git a/tests/testiconview.c b/tests/testiconview.c
index 0a89fa6a5b..c35916cc7d 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -16,6 +16,7 @@
*/
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
#include <sys/types.h>
#include <string.h>
@@ -420,6 +421,10 @@ main (gint argc, gchar **argv)
GtkCellRenderer *cell;
GtkTreeViewColumn *tvc;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
/* to test rtl layout, set RTL=1 in the environment */
diff --git a/tests/testpopover.c b/tests/testpopover.c
index 6d12d6c8ac..da5839de1c 100644
--- a/tests/testpopover.c
+++ b/tests/testpopover.c
@@ -1,4 +1,5 @@
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
static void
activate (GSimpleAction *action,
@@ -48,6 +49,10 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *combo;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
diff --git a/tests/testselectionmode.c b/tests/testselectionmode.c
index c639bbe8eb..f3b983f912 100644
--- a/tests/testselectionmode.c
+++ b/tests/testselectionmode.c
@@ -1,4 +1,5 @@
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
typedef struct {
GtkListBoxRow parent;
@@ -179,6 +180,10 @@ main (int argc, char *argv[])
GSimpleActionGroup *group;
GSimpleAction *action;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
builder = gtk_builder_new_from_file ("selectionmode.ui");
diff --git a/tests/testsplitheaders.c b/tests/testsplitheaders.c
index 42de06d74f..7d89418886 100644
--- a/tests/testsplitheaders.c
+++ b/tests/testsplitheaders.c
@@ -1,4 +1,5 @@
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
static void
split_decorations (GtkSettings *settings,
@@ -42,6 +43,10 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *header;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
builder = gtk_builder_new_from_file ("testsplitheaders.ui");
diff --git a/tests/teststackedheaders.c b/tests/teststackedheaders.c
index 830e9da761..c342d685ca 100644
--- a/tests/teststackedheaders.c
+++ b/tests/teststackedheaders.c
@@ -1,4 +1,5 @@
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
static GtkWidget *header_stack;
static GtkWidget *page_stack;
@@ -23,6 +24,10 @@ main (int argc, char *argv[])
GtkBuilder *builder;
GtkWidget *win;
+#ifdef GTK_SRCDIR
+ g_chdir (GTK_SRCDIR);
+#endif
+
gtk_init ();
builder = gtk_builder_new ();