[gnome-builder: 128/139] testui: add new testui plugin



commit c99b43039fc51f58a1cd7962a9e764550ff1f97a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:40:52 2019 -0800

    testui: add new testui plugin
    
    This extracts the testui code into a new plugin. It also does away with
    the old panel and integrates with the project tree using a new addin.

 src/plugins/testui/gbp-test-path.c       | 181 ++++++++++++++
 src/plugins/testui/gbp-test-path.h       |  37 +++
 src/plugins/testui/gbp-test-tree-addin.c | 394 +++++++++++++++++++++++++++++++
 src/plugins/testui/gbp-test-tree-addin.h |  31 +++
 src/plugins/testui/meson.build           |  13 +
 src/plugins/testui/testui-plugin.c       |  36 +++
 src/plugins/testui/testui.gresource.xml  |   6 +
 src/plugins/testui/testui.plugin         |  11 +
 8 files changed, 709 insertions(+)
---
diff --git a/src/plugins/testui/gbp-test-path.c b/src/plugins/testui/gbp-test-path.c
new file mode 100644
index 000000000..e9d97eb39
--- /dev/null
+++ b/src/plugins/testui/gbp-test-path.c
@@ -0,0 +1,181 @@
+/* gbp-test-path.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
+ */
+
+#define G_LOG_DOMAIN "gbp-test-path"
+
+#include "config.h"
+
+#include "gbp-test-path.h"
+
+struct _GbpTestPath
+{
+  GObject         parent_instance;
+  IdeTestManager *test_manager;
+  gchar          *path;
+  gchar          *name;
+};
+
+enum {
+  PROP_0,
+  PROP_PATH,
+  PROP_TEST_MANAGER,
+  N_PROPS
+};
+
+G_DEFINE_TYPE (GbpTestPath, gbp_test_path, G_TYPE_OBJECT)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_test_path_dispose (GObject *object)
+{
+  GbpTestPath *self = (GbpTestPath *)object;
+
+  g_clear_object (&self->test_manager);
+  g_clear_pointer (&self->path, g_free);
+  g_clear_pointer (&self->name, g_free);
+
+  G_OBJECT_CLASS (gbp_test_path_parent_class)->dispose (object);
+}
+
+static void
+gbp_test_path_get_property (GObject    *object,
+                            guint       prop_id,
+                            GValue     *value,
+                            GParamSpec *pspec)
+{
+  GbpTestPath *self = GBP_TEST_PATH (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      g_value_set_string (value, self->path);
+      break;
+
+    case PROP_TEST_MANAGER:
+      g_value_set_object (value, self->test_manager);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_test_path_set_property (GObject      *object,
+                            guint         prop_id,
+                            const GValue *value,
+                            GParamSpec   *pspec)
+{
+  GbpTestPath *self = GBP_TEST_PATH (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      if ((self->path = g_value_dup_string (value)))
+        self->name = g_path_get_basename (self->path);
+      break;
+
+    case PROP_TEST_MANAGER:
+      self->test_manager = g_value_dup_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_test_path_class_init (GbpTestPathClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = gbp_test_path_dispose;
+  object_class->get_property = gbp_test_path_get_property;
+  object_class->set_property = gbp_test_path_set_property;
+
+  properties [PROP_PATH] =
+    g_param_spec_string ("path", NULL, NULL, NULL,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  properties [PROP_TEST_MANAGER] =
+    g_param_spec_object ("test-manager", NULL, NULL, IDE_TYPE_TEST_MANAGER,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gbp_test_path_init (GbpTestPath *self)
+{
+}
+
+GbpTestPath *
+gbp_test_path_new (IdeTestManager *test_manager,
+                   const gchar    *path)
+{
+  return g_object_new (GBP_TYPE_TEST_PATH,
+                       "test-manager", test_manager,
+                       "path", path,
+                       NULL);
+}
+
+const gchar *
+gbp_test_path_get_name (GbpTestPath *self)
+{
+  g_return_val_if_fail (GBP_IS_TEST_PATH (self), NULL);
+
+  return self->name;
+}
+
+GPtrArray *
+gbp_test_path_get_folders (GbpTestPath *self)
+{
+  GPtrArray *folders;
+  g_auto(GStrv) dirs = NULL;
+
+  g_return_val_if_fail (GBP_IS_TEST_PATH (self), NULL);
+
+  folders = g_ptr_array_new ();
+
+  dirs = ide_test_manager_get_folders (self->test_manager, self->path);
+
+  for (guint i = 0; dirs[i]; i++)
+    {
+      g_autofree gchar *subdir = NULL;
+
+      if (self->path == NULL)
+        subdir = g_strdup (dirs[i]);
+      else
+        subdir = g_strjoin ("/", self->path, dirs[i], NULL);
+
+      g_ptr_array_add (folders, gbp_test_path_new (self->test_manager, subdir));
+    }
+
+  return g_steal_pointer (&folders);
+}
+
+GPtrArray *
+gbp_test_path_get_tests (GbpTestPath *self)
+{
+  g_return_val_if_fail (GBP_IS_TEST_PATH (self), NULL);
+
+  return ide_test_manager_get_tests (self->test_manager, self->path);
+}
diff --git a/src/plugins/testui/gbp-test-path.h b/src/plugins/testui/gbp-test-path.h
new file mode 100644
index 000000000..8e1b24dff
--- /dev/null
+++ b/src/plugins/testui/gbp-test-path.h
@@ -0,0 +1,37 @@
+/* gbp-test-path.h
+ *
+ * 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
+ */
+
+#pragma once
+
+#include <libide-foundry.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_TEST_PATH (gbp_test_path_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpTestPath, gbp_test_path, GBP, TEST_PATH, GObject)
+
+GbpTestPath *gbp_test_path_new         (IdeTestManager *test_manager,
+                                        const gchar    *path);
+const gchar *gbp_test_path_get_name    (GbpTestPath    *self);
+GPtrArray   *gbp_test_path_get_folders (GbpTestPath    *self);
+GPtrArray   *gbp_test_path_get_tests   (GbpTestPath    *self);
+
+G_END_DECLS
diff --git a/src/plugins/testui/gbp-test-tree-addin.c b/src/plugins/testui/gbp-test-tree-addin.c
new file mode 100644
index 000000000..f6a541566
--- /dev/null
+++ b/src/plugins/testui/gbp-test-tree-addin.c
@@ -0,0 +1,394 @@
+/* gbp-test-tree-addin.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
+ */
+
+#define G_LOG_DOMAIN "gbp-test-tree-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <libide-foundry.h>
+#include <libide-gui.h>
+#include <libide-tree.h>
+#include <libide-threading.h>
+
+#include "ide-tree-private.h"
+
+#include "gbp-test-path.h"
+#include "gbp-test-tree-addin.h"
+
+struct _GbpTestTreeAddin
+{
+  GObject       parent_instance;
+  IdeTreeModel *model;
+  IdeTree      *tree;
+};
+
+typedef struct
+{
+  IdeTreeNode     *node;
+  IdeTest         *test;
+  IdeNotification *notif;
+} RunTest;
+
+static void
+run_test_free (RunTest *state)
+{
+  g_clear_object (&state->node);
+  g_clear_object (&state->test);
+  g_clear_object (&state->notif);
+  g_slice_free (RunTest, state);
+}
+
+static void
+gbp_test_tree_addin_build_paths_cb (GObject      *object,
+                                    GAsyncResult *result,
+                                    gpointer      user_data)
+{
+  IdeTestManager *test_manager = (IdeTestManager *)object;
+  g_autoptr(IdeTask) task = user_data;
+  g_autoptr(GPtrArray) dirs = NULL;
+  g_autoptr(GPtrArray) tests = NULL;
+  IdeTreeNode *node;
+  GbpTestPath *path;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_TEST_MANAGER (test_manager));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (IDE_IS_TASK (task));
+
+  ide_test_manager_ensure_loaded_finish (test_manager, result, NULL);
+
+  node = ide_task_get_task_data (task);
+  g_assert (IDE_IS_TREE_NODE (node));
+  g_assert (ide_tree_node_holds (node, GBP_TYPE_TEST_PATH));
+
+  path = ide_tree_node_get_item (node);
+  g_assert (GBP_IS_TEST_PATH (path));
+
+  dirs = gbp_test_path_get_folders (path);
+  tests = gbp_test_path_get_tests (path);
+
+  IDE_PTR_ARRAY_SET_FREE_FUNC (dirs, g_object_unref);
+  IDE_PTR_ARRAY_SET_FREE_FUNC (tests, g_object_unref);
+
+  for (guint i = 0; i < dirs->len; i++)
+    {
+      GbpTestPath *child_path = g_ptr_array_index (dirs, i);
+      g_autoptr(IdeTreeNode) child = NULL;
+
+      child = ide_tree_node_new ();
+      ide_tree_node_set_children_possible (child, TRUE);
+      ide_tree_node_set_display_name (child, gbp_test_path_get_name (child_path));
+      ide_tree_node_set_icon_name (child, "folder-symbolic");
+      ide_tree_node_set_expanded_icon_name (child, "folder-open-symbolic");
+      ide_tree_node_set_item (child, child_path);
+      ide_tree_node_append (node, child);
+    }
+
+  for (guint i = 0; i < tests->len; i++)
+    {
+      IdeTest *test = g_ptr_array_index (tests, i);
+      g_autoptr(IdeTreeNode) child = NULL;
+
+      child = ide_tree_node_new ();
+      ide_tree_node_set_children_possible (child, FALSE);
+      ide_tree_node_set_display_name (child, ide_test_get_display_name (test));
+      ide_tree_node_set_icon_name (child, ide_test_get_icon_name (test));
+      ide_tree_node_set_item (child, test);
+      ide_tree_node_append (node, child);
+    }
+
+  ide_task_return_boolean (task, TRUE);
+}
+
+static void
+gbp_test_tree_addin_build_children_async (IdeTreeAddin        *addin,
+                                          IdeTreeNode         *node,
+                                          GCancellable        *cancellbale,
+                                          GAsyncReadyCallback  callback,
+                                          gpointer             user_data)
+{
+  GbpTestTreeAddin *self = (GbpTestTreeAddin *)addin;
+  g_autoptr(IdeTask) task = NULL;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TEST_TREE_ADDIN (self));
+  g_assert (IDE_IS_TREE_NODE (node));
+  g_assert (!cancellbale || G_IS_CANCELLABLE (cancellbale));
+
+  task = ide_task_new (addin, cancellbale, callback, user_data);
+  ide_task_set_source_tag (task, gbp_test_tree_addin_build_children_async);
+  ide_task_set_task_data (task, g_object_ref (node), g_object_unref);
+
+  if (ide_tree_node_holds (node, IDE_TYPE_CONTEXT))
+    {
+      g_autoptr(IdeTreeNode) child = NULL;
+      g_autoptr(GbpTestPath) path = NULL;
+      IdeTestManager *test_manager;
+      IdeContext *context;
+
+      context = ide_tree_node_get_item (node);
+      test_manager = ide_test_manager_from_context (context);
+      path = gbp_test_path_new (test_manager, NULL);
+
+      child = ide_tree_node_new ();
+      ide_tree_node_set_children_possible (child, TRUE);
+      ide_tree_node_set_display_name (child, _("Unit Tests"));
+      ide_tree_node_set_icon_name (child, "builder-unit-tests-symbolic");
+      ide_tree_node_set_item (child, path);
+      ide_tree_node_prepend (node, child);
+    }
+  else if (ide_tree_node_holds (node, GBP_TYPE_TEST_PATH))
+    {
+      IdeContext *context = ide_widget_get_context (GTK_WIDGET (self->tree));
+      IdeTestManager *test_manager = ide_test_manager_from_context (context);
+
+      ide_test_manager_ensure_loaded_async (test_manager,
+                                            NULL,
+                                            gbp_test_tree_addin_build_paths_cb,
+                                            g_steal_pointer (&task));
+      return;
+    }
+
+  ide_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gbp_test_tree_addin_build_children_finish (IdeTreeAddin  *addin,
+                                           GAsyncResult  *result,
+                                           GError       **error)
+{
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TEST_TREE_ADDIN (addin));
+  g_assert (IDE_IS_TASK (result));
+
+  return ide_task_propagate_boolean (IDE_TASK (result), error);
+}
+
+static IdeTreeNodeVisit
+locate_unit_tests (IdeTreeNode *node,
+                   gpointer     user_data)
+{
+  IdeTreeNode **out_node = user_data;
+
+  if (ide_tree_node_holds (node, GBP_TYPE_TEST_PATH))
+    {
+      *out_node = node;
+      return IDE_TREE_NODE_VISIT_BREAK;
+    }
+
+  return IDE_TREE_NODE_VISIT_CONTINUE;
+}
+
+static void
+gbp_test_tree_addin_notify_loading (GbpTestTreeAddin *self,
+                                    GParamSpec       *pspec,
+                                    IdeTestManager   *test_manager)
+{
+  IdeTreeNode *root;
+  IdeTreeNode *node = NULL;
+  gint64 loading_time;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TEST_TREE_ADDIN (self));
+  g_assert (IDE_IS_TEST_MANAGER (test_manager));
+
+  root = ide_tree_model_get_root (self->model);
+
+  ide_tree_node_traverse (root,
+                          G_PRE_ORDER,
+                          G_TRAVERSE_ALL,
+                          1,
+                          locate_unit_tests,
+                          &node);
+
+  if (node != NULL &&
+      ide_tree_node_expanded (self->tree, node) &&
+      !_ide_tree_node_get_loading (node, &loading_time))
+    {
+      ide_tree_collapse_node (self->tree, node);
+      ide_tree_expand_node (self->tree, node);
+    }
+}
+
+static void
+gbp_test_tree_addin_load (IdeTreeAddin *addin,
+                          IdeTree      *tree,
+                          IdeTreeModel *model)
+{
+  GbpTestTreeAddin *self = (GbpTestTreeAddin *)addin;
+  IdeTestManager *test_manager;
+  IdeContext *context;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_TREE_ADDIN (addin));
+  g_assert (IDE_IS_TREE (tree));
+  g_assert (IDE_IS_TREE_MODEL (model));
+
+  self->tree = tree;
+  self->model = model;
+
+  context = ide_object_get_context (IDE_OBJECT (model));
+  test_manager = ide_test_manager_from_context (context);
+
+  g_signal_connect_object (test_manager,
+                           "notify::loading",
+                           G_CALLBACK (gbp_test_tree_addin_notify_loading),
+                           self,
+                           G_CONNECT_SWAPPED);
+}
+
+static void
+gbp_test_tree_addin_unload (IdeTreeAddin *addin,
+                            IdeTree      *tree,
+                            IdeTreeModel *model)
+{
+  GbpTestTreeAddin *self = (GbpTestTreeAddin *)addin;
+  IdeTestManager *test_manager;
+  IdeContext *context;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_TREE_ADDIN (addin));
+  g_assert (IDE_IS_TREE (tree));
+  g_assert (IDE_IS_TREE_MODEL (model));
+
+  context = ide_object_get_context (IDE_OBJECT (model));
+  test_manager = ide_test_manager_from_context (context);
+  g_signal_handlers_disconnect_by_func (test_manager,
+                                        G_CALLBACK (gbp_test_tree_addin_notify_loading),
+                                        self);
+
+  self->tree = NULL;
+  self->model = NULL;
+}
+
+static void
+gbp_test_tree_addin_run_cb (GObject      *object,
+                            GAsyncResult *result,
+                            gpointer      user_data)
+{
+  IdeTestManager *test_manager = (IdeTestManager *)object;
+  g_autoptr(IdeTask) task = user_data;
+  g_autoptr(GError) error = NULL;
+  const gchar *icon_name = NULL;
+  RunTest *state;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_TEST_MANAGER (test_manager));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (IDE_IS_TASK (task));
+
+  if (!ide_test_manager_run_finish (test_manager, result, &error))
+    {
+      /* TODO: Plumb more errors into test-manager */
+      if (g_error_matches (error, IDE_RUNTIME_ERROR, IDE_RUNTIME_ERROR_BUILD_FAILED) ||
+          error->domain == G_SPAWN_ERROR)
+        icon_name = "dialog-warning-symbolic";
+    }
+
+  state = ide_task_get_task_data (task);
+
+  g_assert (state != NULL);
+  g_assert (IDE_IS_TREE_NODE (state->node));
+  g_assert (IDE_IS_TEST (state->test));
+  g_assert (IDE_IS_NOTIFICATION (state->notif));
+
+  if (icon_name == NULL)
+    icon_name = ide_test_get_icon_name (state->test);
+  ide_tree_node_set_icon_name (state->node, icon_name);
+
+  ide_notification_withdraw_in_seconds (state->notif, 1);
+
+  ide_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gbp_test_tree_addin_node_activated (IdeTreeAddin *addin,
+                                    IdeTree      *tree,
+                                    IdeTreeNode  *node)
+{
+  g_autoptr(IdeTask) task = NULL;
+  g_autofree gchar *title = NULL;
+  IdeTestManager *test_manager;
+  IdeContext *context;
+  RunTest *state;
+  IdeTest *test;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_TEST_TREE_ADDIN (addin));
+  g_assert (IDE_IS_TREE (tree));
+  g_assert (IDE_IS_TREE_NODE (node));
+
+  if (!ide_tree_node_holds (node, IDE_TYPE_TEST))
+    return FALSE;
+
+  context = ide_widget_get_context (GTK_WIDGET (tree));
+  test_manager = ide_test_manager_from_context (context);
+  test = ide_tree_node_get_item (node);
+
+  state = g_slice_new0 (RunTest);
+  state->node = g_object_ref (node);
+  state->test = g_object_ref (test);
+  state->notif = ide_notification_new ();
+
+  /* translators: %s is replaced with the name of the unit test */
+  title = g_strdup_printf (_("Running test “%s”…"),
+                           ide_test_get_display_name (test));
+  ide_notification_set_title (state->notif, title);
+  ide_notification_set_urgent (state->notif, TRUE);
+  ide_notification_attach (state->notif, IDE_OBJECT (context));
+
+  task = ide_task_new (addin, NULL, NULL, NULL);
+  ide_task_set_source_tag (task, gbp_test_tree_addin_node_activated);
+  ide_task_set_task_data (task, state, run_test_free);
+
+  ide_tree_node_set_icon_name (node, "content-loading-symbolic");
+
+  ide_test_manager_run_async (test_manager,
+                              test,
+                              NULL,
+                              gbp_test_tree_addin_run_cb,
+                              g_steal_pointer (&task));
+
+  return TRUE;
+}
+
+static void
+tree_addin_iface_init (IdeTreeAddinInterface *iface)
+{
+  iface->load = gbp_test_tree_addin_load;
+  iface->unload = gbp_test_tree_addin_unload;
+  iface->build_children_async = gbp_test_tree_addin_build_children_async;
+  iface->build_children_finish = gbp_test_tree_addin_build_children_finish;
+  iface->node_activated = gbp_test_tree_addin_node_activated;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GbpTestTreeAddin, gbp_test_tree_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_TREE_ADDIN, tree_addin_iface_init))
+
+static void
+gbp_test_tree_addin_class_init (GbpTestTreeAddinClass *klass)
+{
+}
+
+static void
+gbp_test_tree_addin_init (GbpTestTreeAddin *self)
+{
+}
diff --git a/src/plugins/testui/gbp-test-tree-addin.h b/src/plugins/testui/gbp-test-tree-addin.h
new file mode 100644
index 000000000..af28845ce
--- /dev/null
+++ b/src/plugins/testui/gbp-test-tree-addin.h
@@ -0,0 +1,31 @@
+/* gbp-test-tree-addin.h
+ *
+ * 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
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_TEST_TREE_ADDIN (gbp_test_tree_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpTestTreeAddin, gbp_test_tree_addin, GBP, TEST_TREE_ADDIN, GObject)
+
+G_END_DECLS
diff --git a/src/plugins/testui/meson.build b/src/plugins/testui/meson.build
new file mode 100644
index 000000000..2c4fad914
--- /dev/null
+++ b/src/plugins/testui/meson.build
@@ -0,0 +1,13 @@
+plugins_sources += files([
+  'testui-plugin.c',
+  'gbp-test-path.c',
+  'gbp-test-tree-addin.c',
+])
+
+plugin_testui_resources = gnome.compile_resources(
+  'testui-resources',
+  'testui.gresource.xml',
+  c_name: 'gbp_testui',
+)
+
+plugins_sources += plugin_testui_resources[0]
diff --git a/src/plugins/testui/testui-plugin.c b/src/plugins/testui/testui-plugin.c
new file mode 100644
index 000000000..4b8199fab
--- /dev/null
+++ b/src/plugins/testui/testui-plugin.c
@@ -0,0 +1,36 @@
+/* testui-plugin.c
+ *
+ * Copyright 2017-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
+ */
+
+#define G_LOG_DOMAIN "testui-plugin"
+
+#include "config.h"
+
+#include <libide-tree.h>
+#include <libpeas/peas.h>
+
+#include "gbp-test-tree-addin.h"
+
+_IDE_EXTERN void
+_gbp_testui_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_TREE_ADDIN,
+                                              GBP_TYPE_TEST_TREE_ADDIN);
+}
diff --git a/src/plugins/testui/testui.gresource.xml b/src/plugins/testui/testui.gresource.xml
new file mode 100644
index 000000000..1c245e26e
--- /dev/null
+++ b/src/plugins/testui/testui.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/testui">
+    <file>testui.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/testui/testui.plugin b/src/plugins/testui/testui.plugin
new file mode 100644
index 000000000..967ac6dde
--- /dev/null
+++ b/src/plugins/testui/testui.plugin
@@ -0,0 +1,11 @@
+[Plugin]
+Authors=Christian Hergert <christian hergert me>
+Builtin=true
+Copyright=Copyright © 2017-2018 Christian Hergert
+Depends=editor;
+Description=Unit testing for Builder
+Embedded=_gbp_testui_register_types
+Hidden=true
+Module=testui
+Name=Unit Testing
+X-Tree-Kind=project-tree;


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