libgimp: new unit tests around GimpImage and item API.
Right now, it only tests a few API, such as creating an image, then a text layer, then inserting it in the image. This is a test to avoid regression bug after having fixed #9923 in a previous commit.
This commit is contained in:
@ -8,6 +8,7 @@ endif
|
||||
|
||||
tests = [
|
||||
'color-parser',
|
||||
'image',
|
||||
'palette',
|
||||
'selection-float',
|
||||
'unit',
|
||||
|
39
libgimp/tests/test-image.c
Normal file
39
libgimp/tests/test-image.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* Sometimes odd dimensions may create weird situations. It's usually a
|
||||
* good idea to test both even and odd dimensions.
|
||||
*/
|
||||
#define NEW_IMAGE_WIDTH 1920
|
||||
#define NEW_IMAGE_HEIGHT 2001
|
||||
|
||||
static GimpValueArray *
|
||||
gimp_c_test_run (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
gint n_drawables,
|
||||
GimpDrawable **drawables,
|
||||
GimpProcedureConfig *config,
|
||||
gpointer run_data)
|
||||
{
|
||||
GimpImage **images;
|
||||
GimpImage *new_image;
|
||||
GimpTextLayer *text_layer;
|
||||
gint n_images;
|
||||
|
||||
GIMP_TEST_START("gimp_image_new()");
|
||||
new_image = gimp_image_new (NEW_IMAGE_WIDTH, NEW_IMAGE_HEIGHT, GIMP_RGB);
|
||||
GIMP_TEST_END(GIMP_IS_IMAGE (new_image));
|
||||
|
||||
GIMP_TEST_START("gimp_get_images()");
|
||||
images = gimp_get_images (&n_images);
|
||||
GIMP_TEST_END(n_images == 1 && images[0] == new_image);
|
||||
g_free (images);
|
||||
|
||||
GIMP_TEST_START("gimp_text_layer_new()");
|
||||
text_layer = gimp_text_layer_new (new_image, "hello world", gimp_context_get_font (),
|
||||
20, gimp_unit_point ());
|
||||
GIMP_TEST_END(GIMP_IS_TEXT_LAYER (text_layer));
|
||||
|
||||
GIMP_TEST_START("gimp_image_insert_layer()");
|
||||
GIMP_TEST_END(gimp_image_insert_layer (new_image, GIMP_LAYER (text_layer), NULL, 0));
|
||||
|
||||
GIMP_TEST_RETURN
|
||||
}
|
15
libgimp/tests/test-image.py
Normal file
15
libgimp/tests/test-image.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
NEW_IMAGE_WIDTH=1920
|
||||
NEW_IMAGE_HEIGHT=2001
|
||||
|
||||
image = Gimp.Image.new(NEW_IMAGE_WIDTH, NEW_IMAGE_HEIGHT, Gimp.ImageBaseType.RGB)
|
||||
gimp_assert('Gimp.Image.new()', type(image) == Gimp.Image)
|
||||
|
||||
images = Gimp.get_images()
|
||||
gimp_assert('Gimp.get_images()', len(images) == 1 and images[0] == image)
|
||||
|
||||
text_layer = Gimp.TextLayer.new(image, "hello world", Gimp.context_get_font(), 20, Gimp.Unit.point())
|
||||
gimp_assert('Gimp.TextLayer.new()', type(text_layer) == Gimp.TextLayer)
|
||||
|
||||
gimp_assert('Gimp.Image.InsertLayer()', image.insert_layer(text_layer, None, 0))
|
Reference in New Issue
Block a user