app/tests: Merge some tests
Remove two GIMP initializations by putting "gimp-window-management/window_roles" into "gimp-ui" and removing "gimp-layer-groups/add_layer" which we already have in "gimp-layers". And we can have layer group tests there too.
This commit is contained in:
@ -11,11 +11,9 @@ TESTS_ENVIRONMENT = \
|
|||||||
GIMP_TESTING_ABS_TOP_BUILDDIR=@abs_top_builddir@
|
GIMP_TESTING_ABS_TOP_BUILDDIR=@abs_top_builddir@
|
||||||
|
|
||||||
TESTS = \
|
TESTS = \
|
||||||
test-layer-grouping \
|
|
||||||
test-layers \
|
test-layers \
|
||||||
test-session-management \
|
test-session-management \
|
||||||
test-ui \
|
test-ui \
|
||||||
test-window-management \
|
|
||||||
test-xcf
|
test-xcf
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 2009 Martin Nordholts
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gegl.h>
|
|
||||||
|
|
||||||
#include "core/core-types.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
|
||||||
#include "core/gimpimage.h"
|
|
||||||
#include "core/gimplayer.h"
|
|
||||||
|
|
||||||
#include "tests.h"
|
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TEST_IMAGE_SIZE 100
|
|
||||||
|
|
||||||
#define ADD_TEST(function) \
|
|
||||||
g_test_add ("/gimp-layer-grouping/" #function, \
|
|
||||||
GimpTestFixture, \
|
|
||||||
gimp, \
|
|
||||||
gimp_test_image_setup, \
|
|
||||||
function, \
|
|
||||||
gimp_test_image_teardown);
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GimpImage *image;
|
|
||||||
} GimpTestFixture;
|
|
||||||
|
|
||||||
|
|
||||||
static void gimp_test_image_setup (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data);
|
|
||||||
static void gimp_test_image_teardown (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data);
|
|
||||||
|
|
||||||
|
|
||||||
static Gimp *gimp = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_test_image_setup:
|
|
||||||
* @fixture:
|
|
||||||
* @data:
|
|
||||||
*
|
|
||||||
* Test fixture setup for a single image.
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
gimp_test_image_setup (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data)
|
|
||||||
{
|
|
||||||
fixture->image = gimp_image_new (gimp,
|
|
||||||
GIMP_TEST_IMAGE_SIZE,
|
|
||||||
GIMP_TEST_IMAGE_SIZE,
|
|
||||||
GIMP_RGB);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_test_image_teardown:
|
|
||||||
* @fixture:
|
|
||||||
* @data:
|
|
||||||
*
|
|
||||||
* Test fixture teardown for a single image.
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
gimp_test_image_teardown (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data)
|
|
||||||
{
|
|
||||||
g_object_unref (fixture->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add_layer:
|
|
||||||
* @fixture:
|
|
||||||
* @data:
|
|
||||||
*
|
|
||||||
* Super basic test that makes sure we can add a layer.
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
add_layer (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data)
|
|
||||||
{
|
|
||||||
GimpImage *image = fixture->image;
|
|
||||||
GimpLayer *layer = gimp_layer_new (image,
|
|
||||||
GIMP_TEST_IMAGE_SIZE,
|
|
||||||
GIMP_TEST_IMAGE_SIZE,
|
|
||||||
GIMP_RGBA_IMAGE,
|
|
||||||
"Test Layer",
|
|
||||||
1.0,
|
|
||||||
GIMP_NORMAL_MODE);
|
|
||||||
|
|
||||||
g_assert_cmpint (gimp_image_get_n_layers (image), ==, 0);
|
|
||||||
|
|
||||||
gimp_image_add_layer (image,
|
|
||||||
layer,
|
|
||||||
GIMP_IMAGE_ACTIVE_PARENT,
|
|
||||||
0,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
g_assert_cmpint (gimp_image_get_n_layers (image), ==, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc,
|
|
||||||
char **argv)
|
|
||||||
{
|
|
||||||
g_thread_init (NULL);
|
|
||||||
g_type_init ();
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
|
|
||||||
gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir");
|
|
||||||
|
|
||||||
/* We share the same application instance across all tests */
|
|
||||||
gimp = gimp_init_for_testing (TRUE);
|
|
||||||
|
|
||||||
/* Add tests */
|
|
||||||
ADD_TEST (add_layer);
|
|
||||||
|
|
||||||
/* Run the tests and return status */
|
|
||||||
return g_test_run ();
|
|
||||||
}
|
|
@ -35,6 +35,7 @@
|
|||||||
#include "display/gimpimagewindow.h"
|
#include "display/gimpimagewindow.h"
|
||||||
|
|
||||||
#include "widgets/gimpdialogfactory.h"
|
#include "widgets/gimpdialogfactory.h"
|
||||||
|
#include "widgets/gimpdock.h"
|
||||||
#include "widgets/gimpdockable.h"
|
#include "widgets/gimpdockable.h"
|
||||||
#include "widgets/gimpdockbook.h"
|
#include "widgets/gimpdockbook.h"
|
||||||
#include "widgets/gimpdocked.h"
|
#include "widgets/gimpdocked.h"
|
||||||
@ -44,6 +45,7 @@
|
|||||||
#include "widgets/gimptoolbox.h"
|
#include "widgets/gimptoolbox.h"
|
||||||
#include "widgets/gimptooloptionseditor.h"
|
#include "widgets/gimptooloptionseditor.h"
|
||||||
#include "widgets/gimpuimanager.h"
|
#include "widgets/gimpuimanager.h"
|
||||||
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpchannel.h"
|
#include "core/gimpchannel.h"
|
||||||
@ -593,6 +595,44 @@ switch_back_to_multi_window_mode (GimpTestFixture *fixture,
|
|||||||
gimp_test_run_mainloop_until_idle ();
|
gimp_test_run_mainloop_until_idle ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* window_roles:
|
||||||
|
* @fixture:
|
||||||
|
* @data:
|
||||||
|
*
|
||||||
|
* Makes sure that different windows have the right roles specified.
|
||||||
|
**/
|
||||||
|
static void
|
||||||
|
window_roles (GimpTestFixture *fixture,
|
||||||
|
gconstpointer data)
|
||||||
|
{
|
||||||
|
GtkWidget *dock = NULL;
|
||||||
|
GtkWidget *toolbox = NULL;
|
||||||
|
GimpDockWindow *dock_window = NULL;
|
||||||
|
GimpDockWindow *toolbox_window = NULL;
|
||||||
|
|
||||||
|
dock = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
|
||||||
|
gdk_screen_get_default (),
|
||||||
|
FALSE /*toolbox*/);
|
||||||
|
toolbox = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
|
||||||
|
gdk_screen_get_default (),
|
||||||
|
TRUE /*toolbox*/);
|
||||||
|
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (dock));
|
||||||
|
toolbox_window = gimp_dock_window_from_dock (GIMP_DOCK (toolbox));
|
||||||
|
|
||||||
|
g_assert_cmpstr (gtk_window_get_role (GTK_WINDOW (dock_window)), ==,
|
||||||
|
"gimp-dock");
|
||||||
|
g_assert_cmpstr (gtk_window_get_role (GTK_WINDOW (toolbox_window)), ==,
|
||||||
|
"gimp-toolbox");
|
||||||
|
|
||||||
|
/* When we get here we have a ref count of one, but the signals we
|
||||||
|
* emit cause the reference count to become less than zero for some
|
||||||
|
* reason. So we're lazy and simply ignore to unref these
|
||||||
|
g_object_unref (toolbox);
|
||||||
|
g_object_unref (dock);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
static GimpUIManager *
|
static GimpUIManager *
|
||||||
gimp_ui_get_ui_manager (Gimp *gimp)
|
gimp_ui_get_ui_manager (Gimp *gimp)
|
||||||
{
|
{
|
||||||
@ -763,6 +803,7 @@ int main(int argc, char **argv)
|
|||||||
ADD_TEST (hide_docks_in_single_window_mode);
|
ADD_TEST (hide_docks_in_single_window_mode);
|
||||||
ADD_TEST (show_docks_in_single_window_mode);
|
ADD_TEST (show_docks_in_single_window_mode);
|
||||||
ADD_TEST (switch_back_to_multi_window_mode);
|
ADD_TEST (switch_back_to_multi_window_mode);
|
||||||
|
ADD_TEST (window_roles);
|
||||||
|
|
||||||
/* Run the tests and return status */
|
/* Run the tests and return status */
|
||||||
result = g_test_run ();
|
result = g_test_run ();
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 2009 Martin Nordholts
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gegl.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include "dialogs/dialogs-types.h"
|
|
||||||
|
|
||||||
#include "widgets/gimpdialogfactory.h"
|
|
||||||
#include "widgets/gimpdock.h"
|
|
||||||
#include "widgets/gimpdockwindow.h"
|
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
|
||||||
#include "core/gimpcontext.h"
|
|
||||||
|
|
||||||
#include "tests.h"
|
|
||||||
|
|
||||||
#include "gimp-app-test-utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define ADD_TEST(function) \
|
|
||||||
g_test_add ("/gimp-window-management/" #function, \
|
|
||||||
GimpTestFixture, \
|
|
||||||
NULL, \
|
|
||||||
NULL, \
|
|
||||||
function, \
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int dummy;
|
|
||||||
} GimpTestFixture;
|
|
||||||
|
|
||||||
|
|
||||||
static Gimp *gimp = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* window_roles:
|
|
||||||
* @fixture:
|
|
||||||
* @data:
|
|
||||||
*
|
|
||||||
* Makes sure that different windows have the right roles specified.
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
window_roles (GimpTestFixture *fixture,
|
|
||||||
gconstpointer data)
|
|
||||||
{
|
|
||||||
GtkWidget *dock = NULL;
|
|
||||||
GtkWidget *toolbox = NULL;
|
|
||||||
GimpDockWindow *dock_window = NULL;
|
|
||||||
GimpDockWindow *toolbox_window = NULL;
|
|
||||||
|
|
||||||
dock = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
|
|
||||||
gdk_screen_get_default (),
|
|
||||||
FALSE /*toolbox*/);
|
|
||||||
toolbox = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
|
|
||||||
gdk_screen_get_default (),
|
|
||||||
TRUE /*toolbox*/);
|
|
||||||
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (dock));
|
|
||||||
toolbox_window = gimp_dock_window_from_dock (GIMP_DOCK (toolbox));
|
|
||||||
|
|
||||||
g_assert_cmpstr (gtk_window_get_role (GTK_WINDOW (dock_window)), ==,
|
|
||||||
"gimp-dock");
|
|
||||||
g_assert_cmpstr (gtk_window_get_role (GTK_WINDOW (toolbox_window)), ==,
|
|
||||||
"gimp-toolbox");
|
|
||||||
|
|
||||||
/* When we get here we have a ref count of one, but the signals we
|
|
||||||
* emit cause the reference count to become less than zero for some
|
|
||||||
* reason. So we're lazy and simply ignore to unref these
|
|
||||||
g_object_unref (toolbox);
|
|
||||||
g_object_unref (dock);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int test_result;
|
|
||||||
|
|
||||||
g_type_init ();
|
|
||||||
gtk_init (&argc, &argv);
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
|
|
||||||
gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
|
||||||
"app/tests/gimpdir-empty");
|
|
||||||
|
|
||||||
/* We share the same application instance across all tests */
|
|
||||||
gimp = gimp_init_for_gui_testing (FALSE, FALSE);
|
|
||||||
|
|
||||||
/* Add tests */
|
|
||||||
ADD_TEST (window_roles);
|
|
||||||
|
|
||||||
/* Run the tests and return status */
|
|
||||||
test_result = g_test_run ();
|
|
||||||
|
|
||||||
/* Don't write files to the source dir */
|
|
||||||
gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
|
|
||||||
"app/tests/gimpdir-output");
|
|
||||||
|
|
||||||
/* Exit somewhat properly to avoid annoying warnings */
|
|
||||||
gimp_exit (gimp, TRUE);
|
|
||||||
|
|
||||||
return test_result;
|
|
||||||
}
|
|
Reference in New Issue
Block a user