Commit d32e1ed3 authored by Martin Nordholts's avatar Martin Nordholts

app/tests: Simplify

Use g_test_add_func() and g_test_add_data_func().
parent 16aae588
......@@ -37,18 +37,7 @@
#define ADD_TEST(function) \
g_test_add ("/gimptilebackendtilemanager/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
gint avoid_sizeof_zero;
} GimpTestFixture;
g_test_add_func ("/gimptilebackendtilemanager/" #function, function);
/**
......@@ -59,8 +48,7 @@ typedef struct
* Test basic usage.
**/
static void
basic_usage (GimpTestFixture *fixture,
gconstpointer data)
basic_usage (void)
{
GeglRectangle rect = { 0, 0, 10, 10 };
GeglRectangle pixel_rect = { 5, 5, 1, 1 };
......
......@@ -68,35 +68,20 @@
#define ADD_TEST(function) \
g_test_add ("/gimp-save-and-export/" #function, \
GimpTestFixture, \
gimp, \
NULL, \
function, \
NULL);
g_test_add_data_func ("/gimp-save-and-export/" #function, gimp, function);
typedef gboolean (*GimpUiTestFunc) (GObject *object);
typedef struct
{
int avoid_sizeof_zero;
} GimpTestFixture;
/**
* new_file_has_no_uris:
* @fixture:
* @data:
*
* Tests that the URIs are correct for a newly created image.
**/
static void
new_file_has_no_uris (GimpTestFixture *fixture,
gconstpointer data)
new_file_has_no_uris (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image = gimp_test_utils_create_image_from_dalog (gimp);
......@@ -108,15 +93,13 @@ new_file_has_no_uris (GimpTestFixture *fixture,
/**
* opened_xcf_file_uris:
* @fixture:
* @data:
*
* Tests that GimpImage URIs are correct for an XCF file that has just
* been opened.
**/
static void
opened_xcf_file_uris (GimpTestFixture *fixture,
gconstpointer data)
opened_xcf_file_uris (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image;
......@@ -150,14 +133,12 @@ opened_xcf_file_uris (GimpTestFixture *fixture,
/**
* imported_file_uris:
* @fixture:
* @data:
*
* Tests that URIs are correct for an imported image.
**/
static void
imported_file_uris (GimpTestFixture *fixture,
gconstpointer data)
imported_file_uris (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image;
......@@ -190,15 +171,13 @@ imported_file_uris (GimpTestFixture *fixture,
/**
* saved_imported_file_uris:
* @fixture:
* @data:
*
* Tests that the URIs are correct for an image that has been imported
* and then saved.
**/
static void
saved_imported_file_uris (GimpTestFixture *fixture,
gconstpointer data)
saved_imported_file_uris (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image;
......@@ -253,15 +232,13 @@ saved_imported_file_uris (GimpTestFixture *fixture,
/**
* new_file_has_no_uris:
* @fixture:
* @data:
*
* Tests that the URIs for an exported, newly created file are
* correct.
**/
static void
exported_file_uris (GimpTestFixture *fixture,
gconstpointer data)
exported_file_uris (gconstpointer data)
{
gchar *save_uri;
gchar *save_filename;
......@@ -294,7 +271,6 @@ exported_file_uris (GimpTestFixture *fixture,
/**
* clear_import_uri_after_export:
* @fixture:
* @data:
*
* Tests that after a XCF file that was imported has been exported,
......@@ -302,8 +278,7 @@ exported_file_uris (GimpTestFixture *fixture,
* imported and exported at the same time.
**/
static void
clear_import_uri_after_export (GimpTestFixture *fixture,
gconstpointer data)
clear_import_uri_after_export (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image;
......
......@@ -28,18 +28,7 @@
#define ADD_TEST(function) \
g_test_add ("/gimp-session-2-6-compatibility/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
int dummy;
} GimpTestFixture;
g_test_add_func ("/gimp-session-2-6-compatibility/" #function, function);
/**
......@@ -47,8 +36,7 @@ typedef struct
* written (thus also interpreted) like we expect.
**/
static void
read_and_write_session_files (GimpTestFixture *fixture,
gconstpointer data)
read_and_write_session_files (void)
{
gimp_test_session_load_and_write_session_files ("sessionrc-2-6",
"dockrc-2-6",
......
......@@ -28,18 +28,8 @@
#define ADD_TEST(function) \
g_test_add ("/gimp-session-2-8-compatibility-multi-window/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
int dummy;
} GimpTestFixture;
g_test_add_func ("/gimp-session-2-8-compatibility-multi-window/" #function, \
function);
/**
......@@ -47,8 +37,7 @@ typedef struct
* and written (thus also interpreted) like we expect.
**/
static void
read_and_write_session_files (GimpTestFixture *fixture,
gconstpointer data)
read_and_write_session_files (void)
{
gimp_test_session_load_and_write_session_files ("sessionrc-2-8-multi-window",
"dockrc-2-8",
......
......@@ -28,18 +28,8 @@
#define ADD_TEST(function) \
g_test_add ("/gimp-session-2-8-compatibility-single-window/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
int dummy;
} GimpTestFixture;
g_test_add_func ("/gimp-session-2-8-compatibility-single-window/" #function, \
function);
/**
......@@ -47,8 +37,7 @@ typedef struct
* and written (thus also interpreted) like we expect.
**/
static void
read_and_write_session_files (GimpTestFixture *fixture,
gconstpointer data)
read_and_write_session_files (void)
{
gimp_test_session_load_and_write_session_files ("sessionrc-2-8-single-window",
"dockrc-2-8",
......
......@@ -65,12 +65,8 @@
#define ADD_TEST(function) \
g_test_add ("/gimp-single-window-mode/" #function, \
GimpTestFixture, \
gimp, \
NULL, \
function, \
NULL);
g_test_add_data_func ("/gimp-single-window-mode/" #function, gimp, function);
/* Put this in the code below when you want the test to pause so you
* can do measurements of widgets on the screen for example
......@@ -78,23 +74,15 @@
#define GIMP_PAUSE (g_usleep (20 * 1000 * 1000))
typedef struct
{
int avoid_sizeof_zero;
} GimpTestFixture;
/**
* new_dockable_not_in_new_window:
* @fixture:
* @data:
*
* Test that in single-window mode, new dockables are not put in new
* windows (they should end up in the single image window).
**/
static void
new_dockable_not_in_new_window (GimpTestFixture *fixture,
gconstpointer data)
new_dockable_not_in_new_window (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpDialogFactory *factory = gimp_dialog_factory_get_singleton ();
......
......@@ -66,12 +66,8 @@
#define GIMP_UI_ZOOM_EPSILON 0.01
#define ADD_TEST(function) \
g_test_add ("/gimp-ui/" #function, \
GimpTestFixture, \
gimp, \
NULL, \
function, \
NULL);
g_test_add_data_func ("/gimp-ui/" #function, gimp, function);
/* Put this in the code below when you want the test to pause so you
* can do measurements of widgets on the screen for example
......@@ -82,12 +78,6 @@
typedef gboolean (*GimpUiTestFunc) (GObject *object);
typedef struct
{
int avoid_sizeof_zero;
} GimpTestFixture;
static void gimp_ui_synthesize_delete_event (GtkWidget *widget);
static gboolean gimp_ui_synthesize_click (GtkWidget *widget,
gint x,
......@@ -104,15 +94,13 @@ static void gimp_ui_switch_window_mode (Gimp
/**
* tool_options_editor_updates:
* @fixture:
* @data:
*
* Makes sure that the tool options editor is updated when the tool
* changes.
**/
static void
tool_options_editor_updates (GimpTestFixture *fixture,
gconstpointer data)
tool_options_editor_updates (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
......@@ -177,8 +165,7 @@ gimp_ui_get_dialog (const gchar *identifier)
}
static void
automatic_tab_style (GimpTestFixture *fixture,
gconstpointer data)
automatic_tab_style (gconstpointer data)
{
GtkWidget *channel_dockable = gimp_ui_get_dialog ("gimp-channel-list");
GimpDockable *dockable;
......@@ -230,8 +217,7 @@ automatic_tab_style (GimpTestFixture *fixture,
}
static void
create_new_image_via_dialog (GimpTestFixture *fixture,
gconstpointer data)
create_new_image_via_dialog (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image;
......@@ -253,8 +239,7 @@ create_new_image_via_dialog (GimpTestFixture *fixture,
}
static void
keyboard_zoom_focus (GimpTestFixture *fixture,
gconstpointer data)
keyboard_zoom_focus (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpDisplay *display = GIMP_DISPLAY (gimp_get_display_iter (gimp)->data);
......@@ -322,7 +307,6 @@ keyboard_zoom_focus (GimpTestFixture *fixture,
/**
* alt_click_is_layer_to_selection:
* @fixture:
* @data:
*
* Makes sure that we can alt-click on a layer to do
......@@ -330,8 +314,7 @@ keyboard_zoom_focus (GimpTestFixture *fixture,
* not set as the active layer.
**/
static void
alt_click_is_layer_to_selection (GimpTestFixture *fixture,
gconstpointer data)
alt_click_is_layer_to_selection (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image = GIMP_IMAGE (gimp_get_image_iter (gimp)->data);
......@@ -407,8 +390,7 @@ alt_click_is_layer_to_selection (GimpTestFixture *fixture,
}
static void
restore_recently_closed_multi_column_dock (GimpTestFixture *fixture,
gconstpointer data)
restore_recently_closed_multi_column_dock (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GtkWidget *dock_window = NULL;
......@@ -454,7 +436,6 @@ restore_recently_closed_multi_column_dock (GimpTestFixture *fixture,
/**
* tab_toggle_dont_change_dock_window_position:
* @fixture:
* @data:
*
* Makes sure that when dock windows are hidden with Tab and shown
......@@ -462,8 +443,7 @@ restore_recently_closed_multi_column_dock (GimpTestFixture *fixture,
* use Tab though, we only simulate its effect.
**/
static void
tab_toggle_dont_change_dock_window_position (GimpTestFixture *fixture,
gconstpointer data)
tab_toggle_dont_change_dock_window_position (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GtkWidget *dock_window = NULL;
......@@ -521,8 +501,7 @@ tab_toggle_dont_change_dock_window_position (GimpTestFixture *fixture,
}
static void
switch_to_single_window_mode (GimpTestFixture *fixture,
gconstpointer data)
switch_to_single_window_mode (gconstpointer data)
{
Gimp *gimp = GIMP (data);
......@@ -578,24 +557,21 @@ gimp_ui_toggle_docks_in_single_window_mode (Gimp *gimp)
}
static void
hide_docks_in_single_window_mode (GimpTestFixture *fixture,
gconstpointer data)
hide_docks_in_single_window_mode (gconstpointer data)
{
Gimp *gimp = GIMP (data);
gimp_ui_toggle_docks_in_single_window_mode (gimp);
}
static void
show_docks_in_single_window_mode (GimpTestFixture *fixture,
gconstpointer data)
show_docks_in_single_window_mode (gconstpointer data)
{
Gimp *gimp = GIMP (data);
gimp_ui_toggle_docks_in_single_window_mode (gimp);
}
static void
switch_back_to_multi_window_mode (GimpTestFixture *fixture,
gconstpointer data)
switch_back_to_multi_window_mode (gconstpointer data)
{
Gimp *gimp = GIMP (data);
......@@ -606,8 +582,7 @@ switch_back_to_multi_window_mode (GimpTestFixture *fixture,
}
static void
close_image (GimpTestFixture *fixture,
gconstpointer data)
close_image (gconstpointer data)
{
Gimp *gimp = GIMP (data);
int undo_count = 4;
......@@ -635,15 +610,13 @@ close_image (GimpTestFixture *fixture,
/**
* repeatedly_switch_window_mode:
* @fixture:
* @data:
*
* Makes sure that the size of the image window is properly handled
* when repeatedly switching between window modes.
**/
static void
repeatedly_switch_window_mode (GimpTestFixture *fixture,
gconstpointer data)
repeatedly_switch_window_mode (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
......@@ -703,14 +676,12 @@ repeatedly_switch_window_mode (GimpTestFixture *fixture,
/**
* window_roles:
* @fixture:
* @data:
*
* Makes sure that different windows have the right roles specified.
**/
static void
window_roles (GimpTestFixture *fixture,
gconstpointer data)
window_roles (gconstpointer data)
{
GtkWidget *dock = NULL;
GtkWidget *toolbox = NULL;
......@@ -740,8 +711,7 @@ window_roles (GimpTestFixture *fixture,
}
static void
paintbrush_is_standard_tool (GimpTestFixture *fixture,
gconstpointer data)
paintbrush_is_standard_tool (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpContext *user_context = gimp_get_user_context (gimp);
......
......@@ -136,18 +136,7 @@
{ 931.0, 932.0, /* pad zeroes */ }, }
#define ADD_TEST(function) \
g_test_add ("/gimp-xcf/" #function, \
GimpTestFixture, \
gimp, \
NULL, \
function, \
NULL);
typedef struct
{
gint avoid_sizeof_zero;
} GimpTestFixture;
g_test_add_data_func ("/gimp-xcf/" #function, gimp, function);
GimpImage * gimp_test_load_image (Gimp *gimp,
......@@ -168,15 +157,13 @@ static void gimp_assert_mainimage (GimpImage
/**
* write_and_read_gimp_2_6_format:
* @fixture:
* @data:
*
* Do a write and read test on a file that could as well be
* constructed with GIMP 2.6.
**/
static void
write_and_read_gimp_2_6_format (GimpTestFixture *fixture,
gconstpointer data)
write_and_read_gimp_2_6_format (gconstpointer data)
{
Gimp *gimp = GIMP (data);
......@@ -188,7 +175,6 @@ write_and_read_gimp_2_6_format (GimpTestFixture *fixture,
/**
* write_and_read_gimp_2_6_format_unusual:
* @fixture:
* @data:
*
* Do a write and read test on a file that could as well be
......@@ -196,8 +182,7 @@ write_and_read_gimp_2_6_format (GimpTestFixture *fixture,
* vectors and with a floating selection.
**/
static void
write_and_read_gimp_2_6_format_unusual (GimpTestFixture *fixture,
gconstpointer data)
write_and_read_gimp_2_6_format_unusual (gconstpointer data)
{
Gimp *gimp = GIMP (data);
......@@ -209,15 +194,13 @@ write_and_read_gimp_2_6_format_unusual (GimpTestFixture *fixture,
/**
* load_gimp_2_6_file:
* @fixture:
* @data:
*
* Loads a file created with GIMP 2.6 and makes sure it loaded as
* expected.
**/
static void
load_gimp_2_6_file (GimpTestFixture *fixture,
gconstpointer data)
load_gimp_2_6_file (gconstpointer data)
{
Gimp *gimp = GIMP (data);
GimpImage *image = NULL;
......@@ -243,7 +226,6 @@ load_gimp_2_6_file (GimpTestFixture *fixture,
/**
* write_and_read_gimp_2_8_format:
* @fixture:
* @data:
*
* Writes an XCF file that uses GIMP 2.8 features such as layer
......@@ -251,8 +233,7 @@ load_gimp_2_6_file (GimpTestFixture *fixture,
* was lost.
**/
static void
write_and_read_gimp_2_8_format (GimpTestFixture *fixture,
gconstpointer data)
write_and_read_gimp_2_8_format (gconstpointer data)
{
Gimp *gimp = GIMP (data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment