From a1129813f76b08515522af2be3e93a9994d47dfc Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 26 Sep 2013 13:32:58 -0700 Subject: 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] --- test/run-tests.c | 16 +++++++++++++++- test/run-tests.h | 3 ++- test/test-application.c | 11 ----------- 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 /* For PRIi64 */ #include #include #include @@ -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 -#include /* For PRIi64 */ #include /* For file mode constants */ #include #include @@ -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) -- cgit v1.2.3