app/tests: Test loading of an XCF file created with GIMP 2.6

Do a basic regression test on being able to load XCF files created
with GIMP 2.6. To add things to this file, add things to
gimp_write_and_read_file() and run the code in GIMP 2.6.

Also add a file-local helper function gimp_test_load_image().
This commit is contained in:
Martin Nordholts
2010-01-02 23:16:55 +01:00
parent f86f9e2adf
commit 19183f81b2
2 changed files with 70 additions and 16 deletions

Binary file not shown.

View File

@ -131,6 +131,10 @@ static void gimp_write_and_read_gimp_2_6_format (GimpTestFixture
gconstpointer data); gconstpointer data);
static void gimp_write_and_read_gimp_2_6_format_unusual (GimpTestFixture *fixture, static void gimp_write_and_read_gimp_2_6_format_unusual (GimpTestFixture *fixture,
gconstpointer data); gconstpointer data);
static void gimp_load_gimp_2_6_file (GimpTestFixture *fixture,
gconstpointer data);
GimpImage * gimp_test_load_image (Gimp *gimp,
const gchar *uri);
static void gimp_write_and_read_file (gboolean with_unusual_stuff, static void gimp_write_and_read_file (gboolean with_unusual_stuff,
gboolean compat_paths); gboolean compat_paths);
static GimpImage * gimp_create_mainimage (gboolean with_unusual_stuff, static GimpImage * gimp_create_mainimage (gboolean with_unusual_stuff,
@ -176,6 +180,64 @@ gimp_write_and_read_gimp_2_6_format_unusual (GimpTestFixture *fixture,
TRUE /*compat_paths*/); TRUE /*compat_paths*/);
} }
/**
* gimp_load_gimp_2_6_file:
* @fixture:
* @data:
*
* Loads a file created with GIMP 2.6 and makes sure it loaded as
* expected.
**/
static void
gimp_load_gimp_2_6_file (GimpTestFixture *fixture,
gconstpointer data)
{
GimpImage *image = NULL;
gchar *uri = NULL;
uri = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
"app/tests/files/gimp-2-6-file.xcf",
NULL);
image = gimp_test_load_image (gimp, uri);
/* The image file was constructed by running
* gimp_write_and_read_file (FALSE, FALSE) in GIMP 2.6 by
* copy-pasting the code to GIMP 2.6 and adapting it to changes in
* the core API, so we can use gimp_assert_mainimage() to make sure
* the file was loaded successfully.
*/
gimp_assert_mainimage (image,
FALSE /*with_unusual_stuff*/,
FALSE /*compat_paths*/);
}
GimpImage *
gimp_test_load_image (Gimp *gimp,
const gchar *uri)
{
GimpPlugInProcedure *proc = NULL;
GimpImage *image = NULL;
GimpPDBStatusType not_used = 0;
proc = file_procedure_find (gimp->plug_in_manager->load_procs,
uri,
NULL /*error*/);
image = file_open_image (gimp,
gimp_get_user_context (gimp),
NULL /*progress*/,
uri,
"irrelevant" /*entered_filename*/,
FALSE /*as_new*/,
proc,
GIMP_RUN_NONINTERACTIVE,
&not_used /*status*/,
NULL /*mime_type*/,
NULL /*error*/);
return image;
}
/** /**
* gimp_write_and_read_file: * gimp_write_and_read_file:
* *
@ -192,7 +254,6 @@ gimp_write_and_read_file (gboolean with_unusual_stuff,
GimpImage *loaded_image = NULL; GimpImage *loaded_image = NULL;
GimpPlugInProcedure *proc = NULL; GimpPlugInProcedure *proc = NULL;
gchar *uri = NULL; gchar *uri = NULL;
GimpPDBStatusType status = 0;
/* Create the image */ /* Create the image */
image = gimp_create_mainimage (with_unusual_stuff, image = gimp_create_mainimage (with_unusual_stuff,
@ -219,20 +280,7 @@ gimp_write_and_read_file (gboolean with_unusual_stuff,
NULL /*error*/); NULL /*error*/);
/* Load from file */ /* Load from file */
proc = file_procedure_find (image->gimp->plug_in_manager->load_procs, loaded_image = gimp_test_load_image (image->gimp, uri);
uri,
NULL /*error*/);
loaded_image = file_open_image (gimp,
gimp_get_user_context (gimp),
NULL /*progress*/,
uri,
"irrelevant" /*entered_filename*/,
FALSE /*as_new*/,
proc,
GIMP_RUN_NONINTERACTIVE,
&status,
NULL /*mime_type*/,
NULL /*error*/);
g_free (uri); g_free (uri);
/* Assert on the loaded file. If success, it means that there is no /* Assert on the loaded file. If success, it means that there is no
@ -767,7 +815,7 @@ gimp_assert_mainimage (GimpImage *image,
* @argc: * @argc:
* @argv: * @argv:
* *
* These tests, when done, will * These tests intend to
* *
* - Make sure that we are backwards compatible with files created by * - Make sure that we are backwards compatible with files created by
* older version of GIMP, i.e. that we can load files from earlier * older version of GIMP, i.e. that we can load files from earlier
@ -804,6 +852,12 @@ main (int argc,
NULL, NULL,
gimp_write_and_read_gimp_2_6_format_unusual, gimp_write_and_read_gimp_2_6_format_unusual,
NULL); NULL);
g_test_add ("/gimp-xcf/load-gimp-2-6-file",
GimpTestFixture,
NULL,
NULL,
gimp_load_gimp_2_6_file,
NULL);
/* Exit so we don't break script-fu plug-in wire */ /* Exit so we don't break script-fu plug-in wire */
gimp_exit (gimp, TRUE); gimp_exit (gimp, TRUE);