mirror of https://github.com/GNOME/gimp.git
app: fix unit tests with GUI.
Run them with the new GApplication logic, otherwise the various new parts (such as actions) are not properly loaded.
This commit is contained in:
parent
6324357051
commit
d4fb4362c9
|
@ -67,8 +67,6 @@ libapp_sources = \
|
||||||
sanity.h \
|
sanity.h \
|
||||||
signals.c \
|
signals.c \
|
||||||
signals.h \
|
signals.h \
|
||||||
tests.c \
|
|
||||||
tests.h \
|
|
||||||
unique.c \
|
unique.c \
|
||||||
unique.h \
|
unique.h \
|
||||||
gimp-debug.c \
|
gimp-debug.c \
|
||||||
|
|
|
@ -41,7 +41,6 @@ libapp_sources = [
|
||||||
'language.c',
|
'language.c',
|
||||||
'sanity.c',
|
'sanity.c',
|
||||||
'signals.c',
|
'signals.c',
|
||||||
'tests.c',
|
|
||||||
'unique.c',
|
'unique.c',
|
||||||
gitversion_h,
|
gitversion_h,
|
||||||
gimpdbusservice_gen,
|
gimpdbusservice_gen,
|
||||||
|
|
|
@ -49,7 +49,9 @@ libgimpapptestutils_a_SOURCES = \
|
||||||
gimp-app-test-utils.c \
|
gimp-app-test-utils.c \
|
||||||
gimp-app-test-utils.h \
|
gimp-app-test-utils.h \
|
||||||
gimp-test-session-utils.c \
|
gimp-test-session-utils.c \
|
||||||
gimp-test-session-utils.h
|
gimp-test-session-utils.h \
|
||||||
|
tests.c \
|
||||||
|
tests.h
|
||||||
|
|
||||||
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
||||||
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
||||||
|
@ -117,11 +119,11 @@ LDADD = \
|
||||||
../paint/libapppaint.a \
|
../paint/libapppaint.a \
|
||||||
../config/libappconfig.a \
|
../config/libappconfig.a \
|
||||||
../libapp.a \
|
../libapp.a \
|
||||||
../gegl/libappgegl.a \
|
|
||||||
../operations/libappoperations.a \
|
../operations/libappoperations.a \
|
||||||
../operations/layer-modes/libapplayermodes.a \
|
../operations/layer-modes/libapplayermodes.a \
|
||||||
../operations/layer-modes-legacy/libapplayermodeslegacy.a \
|
../operations/layer-modes-legacy/libapplayermodeslegacy.a \
|
||||||
libgimpapptestutils.a \
|
libgimpapptestutils.a \
|
||||||
|
../gegl/libappgegl.a \
|
||||||
$(libgimpwidgets) \
|
$(libgimpwidgets) \
|
||||||
$(libgimpconfig) \
|
$(libgimpconfig) \
|
||||||
$(libgimpmath) \
|
$(libgimpmath) \
|
||||||
|
|
|
@ -56,6 +56,7 @@ prio = 1000
|
||||||
foreach test_name : app_tests
|
foreach test_name : app_tests
|
||||||
test_exe = executable(test_name,
|
test_exe = executable(test_name,
|
||||||
'test-@0@.c'.format(test_name),
|
'test-@0@.c'.format(test_name),
|
||||||
|
'tests.c',
|
||||||
dependencies: [ libapp_dep, appstream_glib ],
|
dependencies: [ libapp_dep, appstream_glib ],
|
||||||
link_with: apptests_links,
|
link_with: apptests_links,
|
||||||
)
|
)
|
||||||
|
|
|
@ -62,9 +62,10 @@
|
||||||
#include "display/gimpdisplayshell-transform.h"
|
#include "display/gimpdisplayshell-transform.h"
|
||||||
#include "display/gimpimagewindow.h"
|
#include "display/gimpimagewindow.h"
|
||||||
|
|
||||||
#include "tests.h"
|
#include "gimpcoreapp.h"
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
#include "gimp-app-test-utils.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
|
||||||
#define ADD_TEST(function) \
|
#define ADD_TEST(function) \
|
||||||
|
@ -362,8 +363,6 @@ main(int argc,
|
||||||
gimp_test_bail_if_no_display ();
|
gimp_test_bail_if_no_display ();
|
||||||
gtk_test_init (&argc, &argv, NULL);
|
gtk_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir");
|
|
||||||
gimp_test_utils_setup_menus_path ();
|
gimp_test_utils_setup_menus_path ();
|
||||||
|
|
||||||
/* Start up GIMP */
|
/* Start up GIMP */
|
||||||
|
@ -378,14 +377,11 @@ main(int argc,
|
||||||
ADD_TEST (clear_import_file_after_export);
|
ADD_TEST (clear_import_file_after_export);
|
||||||
|
|
||||||
/* Run the tests and return status */
|
/* Run the tests and return status */
|
||||||
result = g_test_run ();
|
g_application_run (gimp->app, 0, NULL);
|
||||||
|
result = gimp_core_app_get_exit_status (GIMP_CORE_APP (gimp->app));
|
||||||
|
|
||||||
/* Don't write files to the source dir */
|
g_application_quit (G_APPLICATION (gimp->app));
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
g_clear_object (&gimp->app);
|
||||||
"app/tests/gimpdir-output");
|
|
||||||
|
|
||||||
/* Exit properly so we don't break script-fu plug-in wire */
|
|
||||||
gimp_exit (gimp, TRUE);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,10 @@
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
#include "core/gimptooloptions.h"
|
#include "core/gimptooloptions.h"
|
||||||
|
|
||||||
#include "tests.h"
|
#include "gimpcoreapp.h"
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
#include "gimp-app-test-utils.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
|
||||||
#define ADD_TEST(function) \
|
#define ADD_TEST(function) \
|
||||||
|
@ -133,8 +134,6 @@ int main(int argc, char **argv)
|
||||||
gimp_test_bail_if_no_display ();
|
gimp_test_bail_if_no_display ();
|
||||||
gtk_test_init (&argc, &argv, NULL);
|
gtk_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir");
|
|
||||||
gimp_test_utils_setup_menus_path ();
|
gimp_test_utils_setup_menus_path ();
|
||||||
|
|
||||||
/* Launch GIMP in single-window mode */
|
/* Launch GIMP in single-window mode */
|
||||||
|
@ -145,14 +144,12 @@ int main(int argc, char **argv)
|
||||||
ADD_TEST (new_dockable_not_in_new_window);
|
ADD_TEST (new_dockable_not_in_new_window);
|
||||||
|
|
||||||
/* Run the tests and return status */
|
/* Run the tests and return status */
|
||||||
result = g_test_run ();
|
g_application_run (gimp->app, 0, NULL);
|
||||||
|
result = gimp_core_app_get_exit_status (GIMP_CORE_APP (gimp->app));
|
||||||
/* Don't write files to the source dir */
|
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
|
||||||
"app/tests/gimpdir-output");
|
|
||||||
|
|
||||||
/* Exit properly so we don't break script-fu plug-in wire */
|
/* Exit properly so we don't break script-fu plug-in wire */
|
||||||
gimp_exit (gimp, TRUE);
|
g_application_quit (G_APPLICATION (gimp->app));
|
||||||
|
g_clear_object (&gimp->app);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,10 @@
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
#include "core/gimptooloptions.h"
|
#include "core/gimptooloptions.h"
|
||||||
|
|
||||||
#include "tests.h"
|
#include "gimpcoreapp.h"
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
#include "gimp-app-test-utils.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TEST_IMAGE_WIDTH 150
|
#define GIMP_TEST_IMAGE_WIDTH 150
|
||||||
|
@ -444,7 +445,6 @@ crop_set_width_without_pending_rect (GimpTestFixture *fixture,
|
||||||
GimpDisplay *display = gimp_test_get_only_display (gimp);
|
GimpDisplay *display = gimp_test_get_only_display (gimp);
|
||||||
GimpToolInfo *tool_info;
|
GimpToolInfo *tool_info;
|
||||||
GimpRectangleOptions *rectangle_options;
|
GimpRectangleOptions *rectangle_options;
|
||||||
GtkWidget *tool_options_gui;
|
|
||||||
GtkWidget *size_entry;
|
GtkWidget *size_entry;
|
||||||
|
|
||||||
/* Activate crop tool */
|
/* Activate crop tool */
|
||||||
|
@ -452,7 +452,6 @@ crop_set_width_without_pending_rect (GimpTestFixture *fixture,
|
||||||
|
|
||||||
/* Get tool options */
|
/* Get tool options */
|
||||||
tool_info = gimp_get_tool_info (gimp, "gimp-crop-tool");
|
tool_info = gimp_get_tool_info (gimp, "gimp-crop-tool");
|
||||||
tool_options_gui = gimp_tools_get_tool_options_gui (tool_info->tool_options);
|
|
||||||
rectangle_options = GIMP_RECTANGLE_OPTIONS (tool_info->tool_options);
|
rectangle_options = GIMP_RECTANGLE_OPTIONS (tool_info->tool_options);
|
||||||
|
|
||||||
/* Find 'Width' or 'Height' GtkTextEntry in tool options */
|
/* Find 'Width' or 'Height' GtkTextEntry in tool options */
|
||||||
|
@ -474,8 +473,6 @@ int main(int argc, char **argv)
|
||||||
gimp_test_bail_if_no_display ();
|
gimp_test_bail_if_no_display ();
|
||||||
gtk_test_init (&argc, &argv, NULL);
|
gtk_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir");
|
|
||||||
gimp_test_utils_setup_menus_path ();
|
gimp_test_utils_setup_menus_path ();
|
||||||
|
|
||||||
/* Start up GIMP */
|
/* Start up GIMP */
|
||||||
|
@ -487,14 +484,11 @@ int main(int argc, char **argv)
|
||||||
ADD_TEST (crop_set_width_without_pending_rect);
|
ADD_TEST (crop_set_width_without_pending_rect);
|
||||||
|
|
||||||
/* Run the tests and return status */
|
/* Run the tests and return status */
|
||||||
result = g_test_run ();
|
g_application_run (gimp->app, 0, NULL);
|
||||||
|
result = gimp_core_app_get_exit_status (GIMP_CORE_APP (gimp->app));
|
||||||
|
|
||||||
/* Don't write files to the source dir */
|
g_application_quit (G_APPLICATION (gimp->app));
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
g_clear_object (&gimp->app);
|
||||||
"app/tests/gimpdir-output");
|
|
||||||
|
|
||||||
/* Exit properly so we don't break script-fu plug-in wire */
|
|
||||||
gimp_exit (gimp, TRUE);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,10 @@
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
#include "core/gimptooloptions.h"
|
#include "core/gimptooloptions.h"
|
||||||
|
|
||||||
#include "tests.h"
|
#include "gimpcoreapp.h"
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
#include "gimp-app-test-utils.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_UI_WINDOW_POSITION_EPSILON 30
|
#define GIMP_UI_WINDOW_POSITION_EPSILON 30
|
||||||
|
@ -865,8 +866,6 @@ int main(int argc, char **argv)
|
||||||
gimp_test_bail_if_no_display ();
|
gimp_test_bail_if_no_display ();
|
||||||
gtk_test_init (&argc, &argv, NULL);
|
gtk_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir");
|
|
||||||
gimp_test_utils_setup_menus_path ();
|
gimp_test_utils_setup_menus_path ();
|
||||||
|
|
||||||
/* Start up GIMP */
|
/* Start up GIMP */
|
||||||
|
@ -900,14 +899,11 @@ int main(int argc, char **argv)
|
||||||
ADD_TEST (window_roles);
|
ADD_TEST (window_roles);
|
||||||
|
|
||||||
/* Run the tests and return status */
|
/* Run the tests and return status */
|
||||||
result = g_test_run ();
|
g_application_run (gimp->app, 0, NULL);
|
||||||
|
result = gimp_core_app_get_exit_status (GIMP_CORE_APP (gimp->app));
|
||||||
|
|
||||||
/* Don't write files to the source dir */
|
g_application_quit (G_APPLICATION (gimp->app));
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
g_clear_object (&gimp->app);
|
||||||
"app/tests/gimpdir-output");
|
|
||||||
|
|
||||||
/* Exit properly so we don't break script-fu plug-in wire */
|
|
||||||
gimp_exit (gimp, TRUE);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "gegl/gimp-gegl.h"
|
#include "gegl/gimp-gegl.h"
|
||||||
|
|
||||||
#include "gimp-log.h"
|
#include "gimp-log.h"
|
||||||
|
#include "gimpcoreapp.h"
|
||||||
|
|
||||||
|
#include "gimp-app-test-utils.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_QUARTZ
|
#ifdef GDK_WINDOWING_QUARTZ
|
||||||
|
@ -105,12 +108,45 @@ gimp_osx_focus_window (gpointer user_data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_test_app_activate_callback (GimpCoreApp *app,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
Gimp *gimp = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_CORE_APP (app));
|
||||||
|
|
||||||
|
gimp = gimp_core_app_get_gimp (app);
|
||||||
|
|
||||||
|
gimp_core_app_set_exit_status (app, EXIT_SUCCESS);
|
||||||
|
|
||||||
|
gui_init (gimp, TRUE, NULL, g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"));
|
||||||
|
gimp_init_icon_theme_for_testing ();
|
||||||
|
gimp_initialize (gimp, gimp_status_func_dummy);
|
||||||
|
gimp_restore (gimp, gimp_status_func_dummy, NULL);
|
||||||
|
#ifdef GDK_WINDOWING_QUARTZ
|
||||||
|
g_idle_add (gimp_osx_focus_window, NULL);
|
||||||
|
#endif
|
||||||
|
gimp->initialized = TRUE;
|
||||||
|
gimp_core_app_set_exit_status (app, g_test_run ());
|
||||||
|
|
||||||
|
/* Don't write files to the source dir */
|
||||||
|
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
||||||
|
"app/tests/gimpdir-output");
|
||||||
|
|
||||||
|
gimp_exit (gimp, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static Gimp *
|
static Gimp *
|
||||||
gimp_init_for_gui_testing_internal (gboolean show_gui,
|
gimp_init_for_gui_testing_internal (gboolean show_gui,
|
||||||
GFile *gimprc)
|
GFile *gimprc)
|
||||||
{
|
{
|
||||||
Gimp *gimp;
|
Gimp *gimp;
|
||||||
|
|
||||||
|
/* Load configuration from the source dir */
|
||||||
|
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||||
|
"app/tests/gimpdir");
|
||||||
|
|
||||||
#if defined (G_OS_WIN32)
|
#if defined (G_OS_WIN32)
|
||||||
/* g_test_init() sets warnings always fatal, which is a usually a good
|
/* g_test_init() sets warnings always fatal, which is a usually a good
|
||||||
testing default. Nevertheless the Windows platform may have a few
|
testing default. Nevertheless the Windows platform may have a few
|
||||||
|
@ -134,18 +170,15 @@ gimp_init_for_gui_testing_internal (gboolean show_gui,
|
||||||
gimp = gimp_new ("Unit Tested GIMP", NULL, NULL, FALSE, TRUE, TRUE, !show_gui,
|
gimp = gimp_new ("Unit Tested GIMP", NULL, NULL, FALSE, TRUE, TRUE, !show_gui,
|
||||||
FALSE, FALSE, TRUE, FALSE, FALSE,
|
FALSE, FALSE, TRUE, FALSE, FALSE,
|
||||||
GIMP_STACK_TRACE_QUERY, GIMP_PDB_COMPAT_OFF);
|
GIMP_STACK_TRACE_QUERY, GIMP_PDB_COMPAT_OFF);
|
||||||
|
gimp->app = gimp_app_new (gimp, TRUE, FALSE, FALSE, NULL, NULL, NULL);
|
||||||
|
|
||||||
gimp_set_show_gui (gimp, show_gui);
|
gimp_set_show_gui (gimp, show_gui);
|
||||||
gimp_load_config (gimp, gimprc, NULL);
|
gimp_load_config (gimp, gimprc, NULL);
|
||||||
gimp_gegl_init (gimp);
|
gimp_gegl_init (gimp);
|
||||||
gui_init (gimp, TRUE, NULL, g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"));
|
|
||||||
gimp_init_icon_theme_for_testing ();
|
|
||||||
gimp_initialize (gimp, gimp_status_func_dummy);
|
|
||||||
gimp_restore (gimp, gimp_status_func_dummy, NULL);
|
|
||||||
#ifdef GDK_WINDOWING_QUARTZ
|
|
||||||
g_idle_add (gimp_osx_focus_window, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
g_signal_connect (gimp->app, "activate",
|
||||||
|
G_CALLBACK (gimp_test_app_activate_callback),
|
||||||
|
NULL);
|
||||||
return gimp;
|
return gimp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue