[gnome-builder: 135/139] tests: cleanup tests and remove dead code



commit af51067aae7ebcffef5da08ebaa4dacd0c1c2ecf
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:45:36 2019 -0800

    tests: cleanup tests and remove dead code
    
    We want to add a bunch more tests back, but they need to be completely
    re-thought out with the new object model (which will simplify many of
    them or make them irrelevant).

 src/tests/data/project1/.editorconfig              |  10 -
 src/tests/data/project1/.gitignore                 |  19 -
 src/tests/data/project1/.you-dont-git-me           |   0
 src/tests/data/project1/autogen.sh                 |  10 -
 src/tests/data/project1/build-aux/.gitignore       |   1 -
 src/tests/data/project1/build-aux/m4/.keep         |   0
 src/tests/data/project1/configure.ac               |  11 -
 src/tests/data/project1/project1.c                 |   1 -
 src/tests/data/project1/tags                       | 821 ---------------------
 src/tests/data/project2/.you-dont-git-me           |   0
 ...le-commands.json => test-compile-commands.json} |   0
 .../data/{project1/project1.doap => test.doap}     |   0
 src/tests/meson.build                              | 200 ++---
 src/tests/samples/gnome-logo.png                   | Bin 895 -> 0 bytes
 src/tests/samples/markdown test page 2.html        |   7 -
 src/tests/samples/markdown test.md                 | 255 -------
 src/tests/test-backoff.c                           | 113 ---
 src/tests/test-c-parse-helper.c                    |  82 --
 ...-compile-commands.c => test-compile-commands.c} |   4 +-
 src/tests/test-completion-fuzzy.c                  |   4 +-
 src/tests/{test-ide-doap.c => test-doap.c}         |   6 +-
 src/tests/{test-ide-glib.c => test-gfile.c}        |   4 +-
 src/tests/test-hdr-format.c                        |  49 --
 src/tests/test-ide-buffer-manager.c                | 196 -----
 src/tests/test-ide-buffer.c                        | 124 ----
 src/tests/test-ide-build-pipeline.c                | 126 ----
 src/tests/test-ide-configuration.c                 |  99 ---
 src/tests/test-ide-context.c                       | 129 ----
 src/tests/test-ide-ctags.c                         | 110 ---
 src/tests/test-ide-file-settings.c                 | 186 -----
 src/tests/test-ide-indenter.c                      | 185 -----
 src/tests/test-ide-runtime.c                       |  98 ---
 src/tests/test-ide-uri.c                           | 146 ----
 src/tests/test-libide-core.c                       | 297 ++++++++
 src/tests/test-line-reader.c                       |  10 +-
 src/tests/test-snippet-parser.c                    |   4 +-
 ...ocess-launcher.c => test-subprocess-launcher.c} |   6 +-
 src/tests/{test-ide-task.c => test-task.c}         |   4 +-
 src/tests/{test-iter.c => test-text-iter.c}        |  12 +-
 src/tests/{test-ide-vcs-uri.c => test-vcs-uri.c}   |  22 +-
 src/tests/test-vim.c                               | 198 -----
 41 files changed, 384 insertions(+), 3165 deletions(-)
---
diff --git a/src/tests/data/test-ide-compile-commands.json b/src/tests/data/test-compile-commands.json
similarity index 100%
rename from src/tests/data/test-ide-compile-commands.json
rename to src/tests/data/test-compile-commands.json
diff --git a/src/tests/data/project1/project1.doap b/src/tests/data/test.doap
similarity index 100%
rename from src/tests/data/project1/project1.doap
rename to src/tests/data/test.doap
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 901874f8c..0b409f2b3 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -10,7 +10,7 @@ typelib_dirs = [
   join_paths(gsv_libdir, 'girepository-1.0'),
 ]
 
-ide_test_env = [
+test_env = [
   'GI_TYPELIB_PATH="@0@:$(GI_TYPELIB_PATH)"'.format(':'.join(typelib_dirs)),
   'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
   'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
@@ -19,194 +19,86 @@ ide_test_env = [
   'GSETTINGS_SCHEMA_DIR=@0@/data/gsettings'.format(meson.build_root()),
   'PYTHONDONTWRITEBYTECODE=yes',
   'MALLOC_CHECK_=2',
-#  'MALLOC_PERTURB_=$((${RANDOM:-256} % 256))',
 ]
-ide_test_cflags = [
+
+test_cflags = [
   '-DTEST_DATA_DIR="@0@/data/"'.format(meson.current_source_dir()),
   '-I' + join_paths(meson.source_root(), 'src'),
 ]
 
-ide_test_deps = [
-  libide_dep,
-  libpeas_dep,
-  gnome_builder_plugins_dep,
-]
-
-
-ide_compile_commands = executable('test-ide-compile-commands', 'test-ide-compile-commands.c',
-        c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
-)
-test('test-ide-compile-commands', ide_compile_commands, env: ide_test_env)
-
-
-ide_context = executable('test-ide-context', 'test-ide-context.c',
-        c_args: ide_test_cflags,
-  dependencies: [ide_test_deps]
-)
-test('test-ide-context', ide_context, env: ide_test_env)
-
-
-ide_runtime = executable('test-ide-runtime', 'test-ide-runtime.c',
-        c_args: ide_test_cflags,
-  dependencies: [ide_test_deps]
-)
-test('test-ide-runtime', ide_runtime, env: ide_test_env)
-
-
-ide_buffer_manager = executable('test-ide-buffer-manager',
-  'test-ide-buffer-manager.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-buffer-manager', ide_buffer_manager,
-  env: ide_test_env,
-)
-
-
-ide_buffer = executable('test-ide-buffer',
-  'test-ide-buffer.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-buffer', ide_buffer,
-  env: ide_test_env,
-)
-
 
-ide_doap = executable('test-ide-doap',
-  'test-ide-doap.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-doap', ide_doap,
-  env: ide_test_env,
+test_libide_core = executable('test-libide-core', 'test-libide-core.c',
+        c_args: test_cflags,
+  dependencies: [ libide_core_dep ],
 )
+test('test-libide-core', test_libide_core, env: test_env)
 
 
-ide_file_settings = executable('test-ide-file-settings',
-  'test-ide-file-settings.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-file-settings', ide_file_settings,
-  env: ide_test_env,
+test_snippet_parser = executable('test-snippet-parser', 'test-snippet-parser.c',
+        c_args: test_cflags,
+  dependencies: [ libide_sourceview_dep ],
 )
+test('test-snippet-parser', test_snippet_parser, env: test_env)
 
 
-ide_indenter = executable('test-ide-indenter',
-  'test-ide-indenter.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-#test('test-ide-indenter', ide_indenter,
-  #env: ide_test_env,
-#)
-
-
-ide_vcs_uri = executable('test-ide-vcs-uri',
-  'test-ide-vcs-uri.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-vcs-uri', ide_vcs_uri,
-  env: ide_test_env,
-)
-
-
-ide_uri = executable('test-ide-uri',
-  'test-ide-uri.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
-)
-test('test-ide-uri', ide_uri,
-  env: ide_test_env,
+test_line_reader = executable('test-line-reader', 'test-line-reader.c',
+        c_args: test_cflags,
+  dependencies: [ libide_io_dep ],
 )
+test('test-line-reader', test_line_reader, env: test_env)
 
 
-test_vim = executable('test-vim',
-  'test-vim.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
+test_text_iter = executable('test-text-iter', 'test-text-iter.c',
+        c_args: test_cflags,
+  dependencies: [ libide_sourceview_dep ],
 )
-#test('test-vim', test_vim,
-#  env: ide_test_env,
-#)
+test('test-text-iter', test_text_iter, env: test_env)
 
 
-test_snippet_parser = executable('test-snippet-parser',
-  'test-snippet-parser.c',
-  c_args: ide_test_cflags,
-  dependencies: [
-    ide_test_deps,
-  ],
+test_vcs_uri = executable('test-vcs-uri', 'test-vcs-uri.c',
+        c_args: test_cflags,
+  dependencies: [ libide_vcs_dep ],
 )
-#test('test-snippet-parser', test_snippet_parser,
-#  env: ide_test_env,
-#)
+test('test-vcs-uri', test_vcs_uri, env: test_env)
 
 
-test_ide_glib = executable('test-ide-glib', 'test-ide-glib.c',
-  c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+test_task = executable('test-task', 'test-task.c',
+        c_args: test_cflags,
+  dependencies: [ libide_threading_dep ],
 )
-test('test-ide-glib', test_ide_glib, env: ide_test_env)
+test('test-task', test_task, env: test_env)
 
 
-test_line_reader = executable('test-line-reader', 'test-line-reader.c',
-  c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+test_subprocess_launcher = executable('test-subprocess-launcher', 'test-subprocess-launcher.c',
+        c_args: test_cflags,
+  dependencies: [ libide_threading_dep ],
 )
-test('test-line-reader', test_line_reader, env: ide_test_env)
+test('test-subprocess-launcher', test_subprocess_launcher, env: test_env)
 
 
-test_ide_task = executable('test-ide-task', 'test-ide-task.c',
-  c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+test_gfile = executable('test-gfile', 'test-gfile.c',
+        c_args: test_cflags,
+  dependencies: [ libide_io_dep ],
 )
-test('test-ide-task', test_ide_task, env: ide_test_env)
+test('test-gfile', test_gfile, env: test_env)
 
 
-test_iter = executable('test-iter', 'test-iter.c',
-  c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+test_doap = executable('test-doap', 'test-doap.c',
+        c_args: test_cflags,
+  dependencies: [ libide_projects_dep ],
 )
-test('test-iter', test_iter, env: ide_test_env)
+test('test-doap', test_doap, env: test_env)
 
 
-test_backoff = executable('test-backoff', 'test-backoff.c',
-  c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+test_compile_commands = executable('test-compile-commands', 'test-compile-commands.c',
+        c_args: test_cflags,
+  dependencies: [ libide_foundry_dep ],
 )
-test('test-backoff', test_backoff, env: ide_test_env)
+test('test-compile-commands', test_compile_commands, env: test_env)
 
 
-test_hdr_format = executable('test-hdr-format', [
-  'test-hdr-format.c',
-  '../plugins/c-pack/c-parse-helper.c',
-],
-        c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
-)
-
 test_completion_fuzzy = executable('test-completion-fuzzy', 'test-completion-fuzzy.c',
-        c_args: ide_test_cflags,
-  dependencies: [ ide_test_deps ],
+        c_args: test_cflags,
+  dependencies: [ libide_sourceview_dep ],
 )
-test('test-completion-fuzzy', test_completion_fuzzy, env: ide_test_env)
+test('test-completion-fuzzy', test_completion_fuzzy, env: test_env)
diff --git a/src/tests/test-ide-compile-commands.c b/src/tests/test-compile-commands.c
similarity index 96%
rename from src/tests/test-ide-compile-commands.c
rename to src/tests/test-compile-commands.c
index 3ac37e792..2c50f2a0d 100644
--- a/src/tests/test-ide-compile-commands.c
+++ b/src/tests/test-compile-commands.c
@@ -18,7 +18,7 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
+#include <libide-foundry.h>
 
 static void
 test_compile_commands_basic (void)
@@ -42,7 +42,7 @@ test_compile_commands_basic (void)
   g_assert (NULL == ide_compile_commands_lookup (commands, missing, NULL, NULL, NULL));
 
   /* Now load our test file */
-  data_path = g_build_filename (TEST_DATA_DIR, "test-ide-compile-commands.json", NULL);
+  data_path = g_build_filename (TEST_DATA_DIR, "test-compile-commands.json", NULL);
   data_file = g_file_new_for_path (data_path);
   r = ide_compile_commands_load (commands, data_file, NULL, &error);
   g_assert_no_error (error);
diff --git a/src/tests/test-completion-fuzzy.c b/src/tests/test-completion-fuzzy.c
index f077e6f42..61a0088b5 100644
--- a/src/tests/test-completion-fuzzy.c
+++ b/src/tests/test-completion-fuzzy.c
@@ -1,6 +1,6 @@
 /* test-completion-fuzzy.c
  *
- * Copyright 2018-2019 Christian Hergert <chergert redhat com>
+ * Copyright 2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
+#include <libide-sourceview.h>
 
 static void
 test_fuzzy_match (void)
diff --git a/src/tests/test-ide-doap.c b/src/tests/test-doap.c
similarity index 95%
rename from src/tests/test-ide-doap.c
rename to src/tests/test-doap.c
index 27fb5f269..71765a146 100644
--- a/src/tests/test-ide-doap.c
+++ b/src/tests/test-doap.c
@@ -1,4 +1,4 @@
-/* test-ide-doap.c
+/* test-doap.c
  *
  * Copyright 2015-2019 Christian Hergert <christian hergert me>
  *
@@ -18,7 +18,7 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
+#include <libide-projects.h>
 
 static void
 test_load_from_file (void)
@@ -34,7 +34,7 @@ test_load_from_file (void)
   doap = ide_doap_new ();
   g_object_add_weak_pointer (G_OBJECT (doap), (gpointer *)&doap);
 
-  file = g_file_new_for_path (TEST_DATA_DIR"/project1/project1.doap");
+  file = g_file_new_for_path (TEST_DATA_DIR"/test.doap");
 
   ret = ide_doap_load_from_file (doap, file, NULL, &error);
   g_assert_no_error (error);
diff --git a/src/tests/test-ide-glib.c b/src/tests/test-gfile.c
similarity index 97%
rename from src/tests/test-ide-glib.c
rename to src/tests/test-gfile.c
index 5c9517072..0bfe78ba8 100644
--- a/src/tests/test-ide-glib.c
+++ b/src/tests/test-gfile.c
@@ -1,6 +1,4 @@
-#include <ide.h>
-
-#include "util/ide-glib.h"
+#include <libide-io.h>
 
 static void
 test_uncanonical_file (void)
diff --git a/src/tests/test-libide-core.c b/src/tests/test-libide-core.c
new file mode 100644
index 000000000..703a3fc9e
--- /dev/null
+++ b/src/tests/test-libide-core.c
@@ -0,0 +1,297 @@
+/* test-libide-core.c
+ *
+ * Copyright 2018-2019 Christian Hergert <chergert redhat com>
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <libide-core.h>
+
+#if 0
+static void
+dump_tree_foreach_cb (gpointer data,
+                      gpointer user_data)
+{
+  guint *depth = user_data;
+  g_autofree gchar *str = g_strnfill (*depth * 2, ' ');
+
+  g_assert (IDE_IS_OBJECT (data));
+  g_assert (depth != NULL);
+
+  (*depth)++;
+  g_printerr ("%s<%s at %p>\n", str, G_OBJECT_TYPE_NAME (data), data);
+  ide_object_foreach (data, dump_tree_foreach_cb, depth);
+  (*depth)--;
+}
+
+static void
+dump_tree (IdeObject *root)
+{
+  guint depth = 1;
+  g_printerr ("\n");
+  g_printerr ("<%s at %p>\n", G_OBJECT_TYPE_NAME (root), root);
+  ide_object_foreach (root, dump_tree_foreach_cb, &depth);
+}
+#endif
+
+static void
+test_ide_object_basic (void)
+{
+  IdeObject *root = ide_object_new (IDE_TYPE_OBJECT, NULL);
+  IdeObject *child1 = ide_object_new (IDE_TYPE_OBJECT, root);
+  IdeObject *child2 = ide_object_new (IDE_TYPE_OBJECT, root);
+  IdeObject *child3 = ide_object_new (IDE_TYPE_OBJECT, root);
+  IdeObject *toplevel = ide_object_ref_root (child3);
+  GCancellable *cancel1 = ide_object_ref_cancellable (child1);
+
+  g_object_add_weak_pointer (G_OBJECT (root), (gpointer *)&root);
+  g_object_add_weak_pointer (G_OBJECT (child1), (gpointer *)&child1);
+  g_object_add_weak_pointer (G_OBJECT (child2), (gpointer *)&child2);
+  g_object_add_weak_pointer (G_OBJECT (child3), (gpointer *)&child3);
+
+  g_assert (toplevel == root);
+  g_object_unref (toplevel);
+
+  g_object_unref (child1);
+  g_object_unref (child2);
+  g_object_unref (child3);
+
+  g_assert_false (g_cancellable_is_cancelled (cancel1));
+
+  g_assert_nonnull (root);
+  g_assert_nonnull (child1);
+  g_assert_nonnull (child2);
+  g_assert_nonnull (child3);
+
+  g_object_unref (root);
+
+  g_assert_null (root);
+  g_assert_null (child1);
+  g_assert_null (child2);
+  g_assert_null (child3);
+
+  g_assert_true (g_cancellable_is_cancelled (cancel1));
+
+  g_object_unref (cancel1);
+}
+
+static void
+test_ide_object_readd (void)
+{
+  g_autoptr(IdeObject) a = ide_object_new (IDE_TYPE_OBJECT, NULL);
+  g_autoptr(IdeObject) b = ide_object_new (IDE_TYPE_OBJECT, a);
+  g_autoptr(IdeObject) p = ide_object_ref_parent (b);
+
+  g_assert_nonnull (a);
+  g_assert_nonnull (b);
+  g_assert_nonnull (p);
+  g_assert (a == p);
+
+  g_clear_object (&p);
+
+  ide_object_remove (a, b);
+  p = ide_object_ref_parent (b);
+
+  g_assert_nonnull (a);
+  g_assert_nonnull (b);
+  g_assert_null (p);
+
+  g_clear_object (&p);
+
+  ide_object_append (a, b);
+  p = ide_object_ref_parent (b);
+
+  g_assert_nonnull (a);
+  g_assert_nonnull (b);
+  g_assert_nonnull (p);
+  g_assert (a == p);
+
+  g_clear_object (&p);
+
+  ide_object_destroy (a);
+  p = ide_object_ref_parent (b);
+
+  g_assert_nonnull (a);
+  g_assert_nonnull (b);
+  g_assert_null (p);
+}
+
+static void
+destroyed_cb (IdeObject *object,
+              guint     *location)
+{
+  g_assert (IDE_IS_OBJECT (object));
+  (*location)--;
+}
+
+static void
+test_ide_notification_basic (void)
+{
+  IdeObject *root = ide_object_new (IDE_TYPE_OBJECT, NULL);
+  IdeNotifications *messages = ide_object_new (IDE_TYPE_NOTIFICATIONS, root);
+  IdeNotification *message = ide_notification_new ();
+  GIcon *icon = g_icon_new_for_string ("system-run-symbolic", NULL);
+  g_autofree gchar *copy = NULL;
+  gint clear1 = 1;
+  gint clear2 = 1;
+  gint clear3 = 1;
+
+  ide_notifications_add_notification (messages, message);
+
+  g_signal_connect (root, "destroy", G_CALLBACK (destroyed_cb), &clear1);
+  g_signal_connect (messages, "destroy", G_CALLBACK (destroyed_cb), &clear2);
+  g_signal_connect (message, "destroy", G_CALLBACK (destroyed_cb), &clear3);
+
+  g_assert_cmpint (1, ==, G_OBJECT (root)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (messages)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (message)->ref_count);
+
+  g_object_add_weak_pointer (G_OBJECT (root), (gpointer *)&root);
+  g_object_add_weak_pointer (G_OBJECT (icon), (gpointer *)&icon);
+
+  g_assert_true (ide_object_is_root (IDE_OBJECT (root)));
+  g_assert_false (ide_object_is_root (IDE_OBJECT (messages)));
+  g_assert_false (ide_object_is_root (IDE_OBJECT (message)));
+
+  g_assert_null (ide_object_get_parent (root));
+  g_assert (ide_object_get_parent (IDE_OBJECT (messages)) == (gpointer)root);
+  g_assert (ide_object_get_parent (IDE_OBJECT (message)) == (gpointer)messages);
+
+  g_assert_cmpint (1, ==, G_OBJECT (root)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (messages)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (message)->ref_count);
+
+  ide_notification_set_title (message, "Foo");
+  copy = ide_notification_dup_title (message);
+  g_assert_cmpstr (copy, ==, "Foo");
+
+  g_assert_cmpint (1, ==, G_OBJECT (icon)->ref_count);
+  ide_notification_set_icon (message, icon);
+  g_assert_cmpint (2, ==, G_OBJECT (icon)->ref_count);
+  g_object_unref (icon);
+  g_assert_nonnull (icon);
+  g_assert_cmpint (1, ==, G_OBJECT (icon)->ref_count);
+
+  g_assert_cmpint (1, ==, G_OBJECT (root)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (messages)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (message)->ref_count);
+
+  g_object_unref (root);
+  g_assert_null (root);
+
+  g_assert_cmpint (1, ==, G_OBJECT (messages)->ref_count);
+  g_assert_cmpint (1, ==, G_OBJECT (message)->ref_count);
+
+  /* Make sure destruction propagated down the tree */
+  g_assert (ide_object_get_parent (IDE_OBJECT (messages)) == NULL);
+  g_assert (ide_object_get_parent (IDE_OBJECT (message)) == NULL);
+
+  g_assert_true (ide_object_is_root (IDE_OBJECT (messages)));
+  g_assert_true (ide_object_is_root (IDE_OBJECT (message)));
+
+  g_assert_cmpint (clear1, ==, 0);
+  g_assert_cmpint (clear2, ==, 0);
+  g_assert_cmpint (clear3, ==, 0);
+
+  g_object_add_weak_pointer (G_OBJECT (messages), (gpointer *)&messages);
+  g_object_unref (messages);
+  g_assert_null (messages);
+
+  g_assert_cmpint (1, ==, G_OBJECT (message)->ref_count);
+  g_assert (ide_object_get_parent (IDE_OBJECT (message)) == NULL);
+  g_assert_true (ide_object_is_root (IDE_OBJECT (message)));
+
+  g_object_add_weak_pointer (G_OBJECT (message), (gpointer *)&message);
+  g_object_unref (message);
+  g_assert_null (message);
+  g_assert_null (icon);
+
+  g_assert_cmpint (clear1, ==, 0);
+  g_assert_cmpint (clear2, ==, 0);
+  g_assert_cmpint (clear3, ==, 0);
+}
+
+static void
+test_ide_notification_destroy (void)
+{
+  IdeObject *root = ide_object_new (IDE_TYPE_OBJECT, NULL);
+  IdeNotifications *messages = ide_object_new (IDE_TYPE_NOTIFICATIONS, root);
+  IdeNotification *message = ide_notification_new ();
+  IdeObject *root_copy = root;
+  gint clear1 = 1;
+  gint clear2 = 1;
+  gint clear3 = 1;
+
+  ide_notifications_add_notification (messages, message);
+
+  g_signal_connect (root, "destroy", G_CALLBACK (destroyed_cb), &clear1);
+  g_signal_connect (messages, "destroy", G_CALLBACK (destroyed_cb), &clear2);
+  g_signal_connect (message, "destroy", G_CALLBACK (destroyed_cb), &clear3);
+
+  g_assert_cmpint (1, ==, G_OBJECT (root)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (messages)->ref_count);
+  g_assert_cmpint (2, ==, G_OBJECT (message)->ref_count);
+
+  g_object_add_weak_pointer (G_OBJECT (root), (gpointer *)&root);
+  g_object_add_weak_pointer (G_OBJECT (message), (gpointer *)&message);
+
+  g_assert_cmpint (1, ==, ide_object_get_n_children (root));
+  g_assert_cmpint (0, <, ide_object_get_n_children (IDE_OBJECT (messages)));
+
+  g_object_unref (message);
+
+  g_assert_cmpint (clear1, ==, 1);
+  g_assert_cmpint (clear2, ==, 1);
+  g_assert_cmpint (clear3, ==, 1);
+
+  ide_object_destroy (root);
+
+  g_assert_cmpint (0, ==, ide_object_get_n_children (root_copy));
+  g_assert_cmpint (0, ==, ide_object_get_n_children (IDE_OBJECT (messages)));
+
+  /* destroy should have caused this to dispose, thereby clearing
+   * any weak pointers.
+   */
+  g_assert_null (message);
+
+  g_object_add_weak_pointer (G_OBJECT (messages), (gpointer *)&messages);
+  g_object_unref (messages);
+
+  g_assert_cmpint (clear1, ==, 0);
+  g_assert_cmpint (clear2, ==, 0);
+  g_assert_cmpint (clear3, ==, 0);
+
+  g_assert_null (root); /* weak cleared from dispose */
+  g_assert_null (messages);
+  g_assert_null (message);
+
+  g_assert_cmpint (G_OBJECT (root_copy)->ref_count, ==, 1);
+  g_object_add_weak_pointer (G_OBJECT (root_copy), (gpointer *)&root_copy);
+  g_object_unref (root_copy);
+  g_assert_null (root_copy);
+}
+
+gint
+main (gint argc,
+      gchar *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+  g_test_add_func ("/libide-core/IdeObject/basic", test_ide_object_basic);
+  g_test_add_func ("/libide-core/IdeObject/re-add", test_ide_object_readd);
+  g_test_add_func ("/libide-core/IdeNotification/basic", test_ide_notification_basic);
+  g_test_add_func ("/libide-core/IdeNotification/destroy", test_ide_notification_destroy);
+  return g_test_run ();
+}
diff --git a/src/tests/test-line-reader.c b/src/tests/test-line-reader.c
index 4363d156c..df19f5ff7 100644
--- a/src/tests/test-line-reader.c
+++ b/src/tests/test-line-reader.c
@@ -1,6 +1,6 @@
 /* test-line-reader.c
  *
- * Copyright 2018-2019 Christian Hergert <chergert redhat com>
+ * Copyright 2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,15 +14,9 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#ifdef G_DISABLE_ASSERT
-# undef G_DISABLE_ASSERT
-#endif
-
-#include <ide.h>
+#include <libide-io.h>
 #include <string.h>
 
 static void
diff --git a/src/tests/test-snippet-parser.c b/src/tests/test-snippet-parser.c
index 53412dba5..93dfd605e 100644
--- a/src/tests/test-snippet-parser.c
+++ b/src/tests/test-snippet-parser.c
@@ -1,8 +1,6 @@
-#include <ide.h>
+#include <libide-sourceview.h>
 #include <stdlib.h>
 
-#include "snippets/ide-snippet-parser.h"
-
 gint
 main (gint   argc,
       gchar *argv[])
diff --git a/src/tests/test-ide-subprocess-launcher.c b/src/tests/test-subprocess-launcher.c
similarity index 98%
rename from src/tests/test-ide-subprocess-launcher.c
rename to src/tests/test-subprocess-launcher.c
index 8d9daba50..c1cfe0413 100644
--- a/src/tests/test-ide-subprocess-launcher.c
+++ b/src/tests/test-subprocess-launcher.c
@@ -1,4 +1,4 @@
-/* test-ide-subprocess-launcher.c
+/* test-subprocess-launcher.c
  *
  * Copyright 2016-2019 Christian Hergert <chergert redhat com>
  *
@@ -20,7 +20,7 @@
 
 #include <fcntl.h>
 #include <glib/gstdio.h>
-#include <ide.h>
+#include <libide-threading.h>
 #include <unistd.h>
 
 static void
@@ -107,7 +107,7 @@ test_stdout_fd (void)
 
 static int
 check_args (IdeSubprocessLauncher *launcher,
-            gchar *argv0,
+            const gchar *argv0,
             ...)
 {
   va_list args;
diff --git a/src/tests/test-ide-task.c b/src/tests/test-task.c
similarity index 99%
rename from src/tests/test-ide-task.c
rename to src/tests/test-task.c
index ffedfeea1..881052efe 100644
--- a/src/tests/test-ide-task.c
+++ b/src/tests/test-task.c
@@ -1,4 +1,4 @@
-/* test-ide-task.c
+/* test-task.c
  *
  * Copyright 2018-2019 Christian Hergert <chergert redhat com>
  *
@@ -18,7 +18,7 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
+#include <libide-threading.h>
 
 static gboolean
 complete_int (gpointer data)
diff --git a/src/tests/test-iter.c b/src/tests/test-text-iter.c
similarity index 90%
rename from src/tests/test-iter.c
rename to src/tests/test-text-iter.c
index d3b2a010a..24d6f7b2c 100644
--- a/src/tests/test-iter.c
+++ b/src/tests/test-text-iter.c
@@ -1,6 +1,6 @@
-/* test-iter.c
+/* test-text-iter.c
  *
- * Copyright 2018-2019 Christian Hergert <chergert redhat com>
+ * Copyright © 2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,13 +14,9 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
-
-#include "sourceview/ide-text-iter.h"
+#include <libide-sourceview.h>
 
 static void
 test_current_symbol (void)
@@ -54,7 +50,7 @@ test_current_symbol (void)
       GtkTextIter iter;
 
       gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 0, i);
-      word = _ide_text_iter_current_symbol (&iter, NULL);
+      word = ide_text_iter_current_symbol (&iter, NULL);
 
       g_assert_cmpstr (word, ==, expected[i]);
     }
diff --git a/src/tests/test-ide-vcs-uri.c b/src/tests/test-vcs-uri.c
similarity index 86%
rename from src/tests/test-ide-vcs-uri.c
rename to src/tests/test-vcs-uri.c
index 8639c5504..85a1a56aa 100644
--- a/src/tests/test-ide-vcs-uri.c
+++ b/src/tests/test-vcs-uri.c
@@ -1,4 +1,24 @@
-#include <ide.h>
+/* test-vcs-uri.c
+ *
+ * Copyright 2015-2019 Christian Hergert <chergert redhat com>
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <libide-vcs.h>
 
 typedef struct
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]