summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2013-09-26 13:32:58 -0700
committerPhilip Chimento <philip@endlessm.com>2013-09-26 14:32:23 -0700
commita1129813f76b08515522af2be3e93a9994d47dfc (patch)
treeaa817b9b4fd182fe00d5f00415199c04064e5e71
parenta8d9e4a761edcd714642fc59539430c7f15f23fa (diff)
Run all tests with unique application ID
Running tests with the same application ID causes DBus collisions. Apparently this did not cause problems until now. [endlessm/eos-sdk#303]
-rw-r--r--test/run-tests.c16
-rw-r--r--test/run-tests.h3
-rw-r--r--test/test-application.c11
3 files changed, 17 insertions, 13 deletions
diff --git a/test/run-tests.c b/test/run-tests.c
index b73d520..016744d 100644
--- a/test/run-tests.c
+++ b/test/run-tests.c
@@ -1,5 +1,6 @@
/* Copyright 2013 Endless Mobile, Inc. */
+#include <inttypes.h> /* For PRIi64 */
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
@@ -7,12 +8,25 @@
#include "run-tests.h"
+#define APPLICATION_TEST_ID_BASE "com.endlessm.eosapplication.test"
+
+/* App ID based on timestamp so that test applications don't collide */
+gchar *
+generate_unique_app_id (void)
+{
+ return g_strdup_printf ("%s%" PRIi64,
+ APPLICATION_TEST_ID_BASE,
+ g_get_real_time ());
+}
+
/* Test fixture for running a test from an EosApplication's "startup" handler */
void
app_window_test_fixture_setup (AppWindowTestFixture *fixture,
gconstpointer callback)
{
- fixture->app = eos_application_new (TEST_APPLICATION_ID, 0);
+ gchar *app_id = generate_unique_app_id ();
+ fixture->app = eos_application_new (app_id, 0);
+ g_free (app_id);
g_signal_connect(fixture->app, "startup", G_CALLBACK (callback),
NULL);
}
diff --git a/test/run-tests.h b/test/run-tests.h
index 88a57d5..8947a5a 100644
--- a/test/run-tests.h
+++ b/test/run-tests.h
@@ -4,7 +4,6 @@
#define RUN_TESTS_H
#define TEST_LOG_DOMAIN "EndlessSDK"
-#define TEST_APPLICATION_ID "com.endlessm.example.test"
#define ADD_APP_WINDOW_TEST(path, test_func) \
g_test_add ((path), AppWindowTestFixture, (test_func), \
@@ -17,6 +16,8 @@ typedef struct
EosApplication *app;
} AppWindowTestFixture;
+gchar *generate_unique_app_id (void);
+
void app_window_test_fixture_setup (AppWindowTestFixture *fixture,
gconstpointer callback);
diff --git a/test/test-application.c b/test/test-application.c
index f417b5a..74b9c49 100644
--- a/test/test-application.c
+++ b/test/test-application.c
@@ -1,7 +1,6 @@
/* Copyright 2013 Endless Mobile, Inc. */
#include <stdlib.h>
-#include <inttypes.h> /* For PRIi64 */
#include <sys/stat.h> /* For file mode constants */
#include <gtk/gtk.h>
#include <endless/endless.h>
@@ -11,8 +10,6 @@
#define EXPECTED_TWO_WINDOW_ERRMSG "*You should not add more than one application window*"
#define EXPECTED_CONFIG_NOT_WRITABLE_ERRMSG "*Your user config directory*is not writable*"
-#define APPLICATION_TEST_ID_BASE "com.endlessm.eosapplication.test"
-
typedef struct
{
gchar *unique_id;
@@ -38,14 +35,6 @@ test_two_windows (EosApplication *app)
gtk_widget_destroy (win1);
}
-static gchar *
-generate_unique_app_id (void)
-{
- return g_strdup_printf ("%s%" PRIi64,
- APPLICATION_TEST_ID_BASE,
- g_get_real_time ());
-}
-
static void
config_dir_setup (ConfigDirFixture *fixture,
gconstpointer unused)