File: refcount.c

package info (click to toggle)
glade 3.40.0-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,336 kB
  • sloc: ansic: 75,618; xml: 5,397; sh: 48; makefile: 26; python: 13; javascript: 10
file content (51 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (3)
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
#include <glib.h>
#include <glib-object.h>

#include <gladeui/glade-app.h>
#include <gladeui/glade-project.h>

static void
check_finalized (gpointer data,
                 GObject *where_the_object_was)
{
  gboolean *did_finalize = (gboolean *)data;

  *did_finalize = TRUE;
}

static void
test_project (gconstpointer data)
{
  gboolean project_finalized = FALSE;
  GObject *project = NULL;

  project = G_OBJECT (glade_project_new ());
  g_assert_true (GLADE_IS_PROJECT (project));

  g_object_weak_ref (project,  check_finalized, &project_finalized);

  /* A newly created project should always have a refcout of 1 */
  g_assert_cmpint (project->ref_count, ==, 1);

  /* TODO: create toplevels and check gtk_window_list_toplevels() is empty */

  /* This should dispose project */
  g_object_unref (project);

  /* Now check if it was finalized */
  g_assert_true (project_finalized);
}

int
main (int argc, char *argv[])
{
  gtk_test_init (&argc, &argv, NULL);

  glade_init ();
  glade_app_get ();

  g_test_add_data_func ("/RefCount/Project", NULL, test_project);

  return g_test_run ();
}