2003-06-29 14:05:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
|
|
|
*
|
|
|
|
* category.c: test the categories
|
|
|
|
*
|
|
|
|
* This library 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 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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 library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY (cat);
|
|
|
|
#define GST_CAT_DEFAULT cat
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (cat_static);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
GSList *before, *after;
|
|
|
|
|
|
|
|
unsetenv ("GST_DEBUG");
|
|
|
|
gst_init (&argc, &argv);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
before = gst_debug_get_all_categories ();
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
|
|
|
|
"default category for this test");
|
|
|
|
GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
|
|
|
|
"static category for this test");
|
2003-06-29 14:05:49 +00:00
|
|
|
after = gst_debug_get_all_categories ();
|
|
|
|
|
|
|
|
g_print ("removing default log function\n");
|
2004-04-05 04:31:00 +00:00
|
|
|
#ifdef GST_DISABLE_GST_DEBUG
|
|
|
|
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 0);
|
|
|
|
#else
|
|
|
|
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print
|
|
|
|
("checking, if the two new categories are put into the category list correctly...\n");
|
2004-04-05 04:31:00 +00:00
|
|
|
g_assert (g_slist_length (after) - g_slist_length (before) == 2);
|
2003-06-29 14:05:49 +00:00
|
|
|
/* check the _get stuff */
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print
|
|
|
|
("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
|
2003-06-29 14:05:49 +00:00
|
|
|
g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
|
|
|
|
g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (strcmp (gst_debug_category_get_description (cat),
|
2004-03-15 19:27:17 +00:00
|
|
|
"default category for this test") == 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (gst_debug_category_get_threshold (cat) ==
|
|
|
|
gst_debug_get_default_threshold ());
|
|
|
|
g_assert (strcmp (gst_debug_category_get_name (cat_static),
|
2004-03-15 19:27:17 +00:00
|
|
|
"cat_static") == 0);
|
2003-06-29 14:05:49 +00:00
|
|
|
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
|
|
|
|
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
|
|
|
|
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (strcmp (gst_debug_category_get_description (cat_static),
|
2004-03-15 19:27:17 +00:00
|
|
|
"static category for this test") == 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (gst_debug_category_get_threshold (cat_static) ==
|
|
|
|
gst_debug_get_default_threshold ());
|
2003-06-29 14:05:49 +00:00
|
|
|
/* check if setting levels for names work */
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print
|
|
|
|
("checking if changing threshold for names affects existing categories...\n");
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
|
|
|
|
g_assert (gst_debug_category_get_threshold (cat_static) ==
|
|
|
|
gst_debug_get_default_threshold ());
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
|
|
|
|
g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
|
|
|
|
g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
|
2004-04-03 04:16:24 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
g_print ("everything ok.\n");
|
|
|
|
return 0;
|
|
|
|
}
|