[gnome-todo] tests: Extend DummyProvider
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] tests: Extend DummyProvider
- Date: Thu, 7 Feb 2019 11:17:08 +0000 (UTC)
commit 31af660976978640ef568fc0218e4918f64b23fa
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Feb 6 19:40:50 2019 -0200
tests: Extend DummyProvider
Add a new function to generate a single task list with
a well known task layout. This will be used to test
moving tasks.
tests/dummy-provider.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/dummy-provider.h | 2 ++
2 files changed, 70 insertions(+)
---
diff --git a/tests/dummy-provider.c b/tests/dummy-provider.c
index 355000e..184163c 100644
--- a/tests/dummy-provider.c
+++ b/tests/dummy-provider.c
@@ -321,6 +321,74 @@ dummy_provider_new (void)
return g_object_new (DUMMY_TYPE_PROVIDER, NULL);
}
+guint
+dummy_provider_generate_task_list (DummyProvider *self)
+{
+ GSequenceIter *iter;
+ GtdTaskList *list;
+ guint n_generated_tasks;
+ gint i;
+
+ /*
+ * This generates a task list with the following layout:
+ *
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ * - Task
+ */
+
+ gtd_provider_create_task_list (GTD_PROVIDER (self), "List");
+ iter = g_sequence_iter_prev (g_sequence_get_end_iter (self->lists));
+ list = g_sequence_get (iter);
+
+ n_generated_tasks = 0;
+
+ for (i = 0; i < 4; i++)
+ {
+ g_autoptr (GtdTask) task = NULL;
+ g_autofree gchar *title = NULL;
+ g_autofree gchar *uuid = NULL;
+ gint n_subtasks;
+ gint j;
+
+ n_subtasks = i;
+ uuid = g_uuid_string_random ();
+ title = g_strdup_printf ("%d", i);
+
+ task = gtd_task_new ();
+ gtd_object_set_uid (GTD_OBJECT (task), uuid);
+ gtd_task_set_title (task, title);
+ gtd_task_set_position (task, n_generated_tasks++);
+ gtd_task_list_add_task (list, task);
+
+ for (j = 0; j < n_subtasks; j++)
+ {
+ g_autoptr (GtdTask) subtask = NULL;
+ g_autofree gchar *subtask_title = NULL;
+ g_autofree gchar *subtask_uuid = NULL;
+
+ subtask_uuid = g_uuid_string_random ();
+ subtask_title = g_strdup_printf ("%d:%d", i, j);
+
+ subtask = gtd_task_new ();
+ gtd_object_set_uid (GTD_OBJECT (subtask), subtask_uuid);
+ gtd_task_set_title (subtask, subtask_title);
+ gtd_task_set_position (subtask, n_generated_tasks++);
+ gtd_task_add_subtask (task, subtask);
+ gtd_task_list_add_task (list, g_steal_pointer (&subtask));
+ }
+ }
+
+ return n_generated_tasks;
+}
+
guint
dummy_provider_generate_task_lists (DummyProvider *self)
{
diff --git a/tests/dummy-provider.h b/tests/dummy-provider.h
index c3e2c9a..6520c06 100644
--- a/tests/dummy-provider.h
+++ b/tests/dummy-provider.h
@@ -30,6 +30,8 @@ G_DECLARE_FINAL_TYPE (DummyProvider, dummy_provider, DUMMY, PROVIDER, GtdObject)
DummyProvider* dummy_provider_new (void);
+guint dummy_provider_generate_task_list (DummyProvider *self);
+
guint dummy_provider_generate_task_lists (DummyProvider *self);
void dummy_provider_schedule_remove_task (DummyProvider *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]