[gnome-todo] tests: Rewrite task list tests
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] tests: Rewrite task list tests
- Date: Mon, 3 May 2021 19:42:06 +0000 (UTC)
commit 7890154e8c394880a992aac3ee4d19ed49363e53
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon May 3 16:39:35 2021 -0300
tests: Rewrite task list tests
The essence of the tests is preserved, and they test the same
stuff they used to, but now with the correct expectations and
no subtasks. Plus some variables were renamed.
tests/dummy-provider.c | 2 +-
tests/test-task-list.c | 48 ++++++++++++++++++++++++------------------------
2 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/tests/dummy-provider.c b/tests/dummy-provider.c
index e87a8c8e..729b38e6 100644
--- a/tests/dummy-provider.c
+++ b/tests/dummy-provider.c
@@ -359,7 +359,7 @@ dummy_provider_generate_task_list (DummyProvider *self)
n_generated_tasks = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 10; i++)
{
g_autoptr (GtdTask) task = NULL;
g_autofree gchar *title = NULL;
diff --git a/tests/test-task-list.c b/tests/test-task-list.c
index e56b8039..325ee3a6 100644
--- a/tests/test-task-list.c
+++ b/tests/test-task-list.c
@@ -29,8 +29,8 @@ static void
test_move (void)
{
g_autoptr (DummyProvider) dummy_provider = NULL;
- g_autoptr (GtdTask) first_root_task = NULL;
- g_autoptr (GtdTask) last_root_task = NULL;
+ g_autoptr (GtdTask) first_task = NULL;
+ g_autoptr (GtdTask) last_task = NULL;
g_autoptr (GList) lists = NULL;
GtdTaskList *list = NULL;
GListModel *model;
@@ -51,37 +51,37 @@ test_move (void)
g_assert_nonnull (list);
g_assert_cmpstr (gtd_task_list_get_name (list), ==, "List");
- first_root_task = g_list_model_get_item (model, 0);
- g_assert_nonnull (first_root_task);
- g_assert_cmpint (gtd_task_get_position (first_root_task), ==, 0);
- g_assert_true (g_list_model_get_item (model, 0) == first_root_task);
+ first_task = g_list_model_get_item (model, 0);
+ g_assert_nonnull (first_task);
+ g_assert_cmpint (gtd_task_get_position (first_task), ==, 0);
+ g_assert_true (g_list_model_get_item (model, 0) == first_task);
- last_root_task = g_list_model_get_item (model, 6);
- g_assert_nonnull (last_root_task);
- g_assert_cmpint (gtd_task_get_position (last_root_task), ==, 6);
- g_assert_true (g_list_model_get_item (model, 6) == last_root_task);
+ last_task = g_list_model_get_item (model, 9);
+ g_assert_nonnull (last_task);
+ g_assert_cmpint (gtd_task_get_position (last_task), ==, 9);
+ g_assert_true (g_list_model_get_item (model, 9) == last_task);
/* Move the task to 0 */
- gtd_task_list_move_task_to_position (list, last_root_task, 0);
+ gtd_task_list_move_task_to_position (list, last_task, 0);
- g_assert_cmpint (gtd_task_get_position (last_root_task), ==, 0);
- g_assert_cmpint (gtd_task_get_position (first_root_task), ==, 4);
- g_assert_true (g_list_model_get_item (model, 0) == last_root_task);
- g_assert_true (g_list_model_get_item (model, 4) == first_root_task);
+ g_assert_cmpint (gtd_task_get_position (last_task), ==, 0);
+ g_assert_cmpint (gtd_task_get_position (first_task), ==, 1);
+ g_assert_true (g_list_model_get_item (model, 0) == last_task);
+ g_assert_true (g_list_model_get_item (model, 1) == first_task);
/* Move the task to 1 */
- gtd_task_list_move_task_to_position (list, last_root_task, 5);
+ gtd_task_list_move_task_to_position (list, last_task, 1);
- g_assert_cmpint (gtd_task_get_position (last_root_task), ==, 1);
- g_assert_cmpint (gtd_task_get_position (first_root_task), ==, 0);
- g_assert_true (g_list_model_get_item (model, 0) == first_root_task);
- g_assert_true (g_list_model_get_item (model, 1) == last_root_task);
+ g_assert_cmpint (gtd_task_get_position (last_task), ==, 1);
+ g_assert_cmpint (gtd_task_get_position (first_task), ==, 0);
+ g_assert_true (g_list_model_get_item (model, 0) == first_task);
+ g_assert_true (g_list_model_get_item (model, 1) == last_task);
- /* Move the task to 10 */
- gtd_task_list_move_task_to_position (list, last_root_task, 10);
+ /* Move the task to 9 */
+ gtd_task_list_move_task_to_position (list, last_task, 9);
- g_assert_cmpint (gtd_task_get_position (last_root_task), ==, 6);
- g_assert_true (g_list_model_get_item (model, 6) == last_root_task);
+ g_assert_cmpint (gtd_task_get_position (last_task), ==, 9);
+ g_assert_true (g_list_model_get_item (model, 9) == last_task);
}
gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]