summaryrefslogtreecommitdiff
path: root/testsuite/debug/category.c
blob: edc43227bffec344a953eb48938937bf0291d894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * 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.
 */

#include <gst/gst.h>
#include <string.h>

GST_DEBUG_CATEGORY (cat);
#define GST_CAT_DEFAULT cat
GST_DEBUG_CATEGORY_STATIC (cat_static);

gint
main (gint argc, gchar * argv[])
{
  GSList *before, *after;

  unsetenv ("GST_DEBUG");
  gst_init (&argc, &argv);

  before = gst_debug_get_all_categories ();
  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");
  after = gst_debug_get_all_categories ();

  g_print ("removing default log function\n");
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
  g_print
      ("checking, if the two new categories are put into the category list correctly...\n");
  g_assert (g_slist_length (after) - g_slist_length (before) == 2);
  /* check the _get stuff */
  g_print
      ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
  g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
  g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
  g_assert (strcmp (gst_debug_category_get_description (cat),
	  "default category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat) ==
      gst_debug_get_default_threshold ());
  g_assert (strcmp (gst_debug_category_get_name (cat_static),
	  "cat_static") == 0);
  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);
  g_assert (strcmp (gst_debug_category_get_description (cat_static),
	  "static category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat_static) ==
      gst_debug_get_default_threshold ());
  /* check if setting levels for names work */
  g_print
      ("checking if changing threshold for names affects existing categories...\n");
  gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
  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 ());
  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);

  g_print ("everything ok.\n");
  return 0;
}