|
Packit Service |
2781ba |
/*
|
|
Packit Service |
2781ba |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
2781ba |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
2781ba |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
2781ba |
* (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
2781ba |
* GNU General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
2781ba |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright (C) 2011 Martin Nordholts <martinn@src.gnome.org>
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <gegl.h>
|
|
Packit Service |
2781ba |
#include <gegl-buffer-backend.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define ADD_TEST(function) g_test_add_func ("/gegl-tile/" #function, function);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
unlock_callback (GeglTile *tile,
|
|
Packit Service |
2781ba |
gpointer user_data)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gboolean *callback_called = user_data;
|
|
Packit Service |
2781ba |
*callback_called = TRUE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
free_callback (gpointer user_data)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gboolean *callback_called = user_data;
|
|
Packit Service |
2781ba |
*callback_called = TRUE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* Tests that gegl_tile_set_unlock_notify() can be used to set a
|
|
Packit Service |
2781ba |
* callback that is called in gegl_tile_unlock().
|
|
Packit Service |
2781ba |
**/
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
set_unlock_notify (void)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTile *tile = gegl_tile_new (1);
|
|
Packit Service |
2781ba |
gboolean callback_called = FALSE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_tile_set_unlock_notify (tile, unlock_callback, &callback_called);
|
|
Packit Service |
2781ba |
g_assert (! callback_called);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_tile_lock (tile);
|
|
Packit Service |
2781ba |
g_assert (! callback_called);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_tile_unlock(tile);
|
|
Packit Service |
2781ba |
g_assert (callback_called);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* Tests that gegl_tile_set_data_full() results in a callback when the
|
|
Packit Service |
2781ba |
* tile is freed.
|
|
Packit Service |
2781ba |
**/
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
set_data_full (void)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTile *tile = gegl_tile_new (1);
|
|
Packit Service |
2781ba |
gboolean callback_called = FALSE;
|
|
Packit Service |
2781ba |
guchar data = 42;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_tile_set_data_full (tile, &data, 1, free_callback, &callback_called);
|
|
Packit Service |
2781ba |
g_assert (! callback_called);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_tile_unref (tile);
|
|
Packit Service |
2781ba |
g_assert (callback_called);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
int
|
|
Packit Service |
2781ba |
main (int argc,
|
|
Packit Service |
2781ba |
char **argv)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_type_init ();
|
|
Packit Service |
2781ba |
gegl_init (&argc, &argv);
|
|
Packit Service |
2781ba |
g_test_init (&argc, &argv, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
ADD_TEST (set_unlock_notify);
|
|
Packit Service |
2781ba |
ADD_TEST (set_data_full);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return g_test_run ();
|
|
Packit Service |
2781ba |
}
|