summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-25 16:46:22 +1000
committerChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-25 16:46:22 +1000
commit58404abe843ef07ebfe251aafa25ed18c51601cc (patch)
tree861ac182102c2b80a4ca98e58cacb2378ff9de04
parente3f85e9012984ab837c566d75c7fbd0898b0ffcc (diff)
downloadradial-switcher-58404abe843ef07ebfe251aafa25ed18c51601cc.tar.gz
radial-switcher-58404abe843ef07ebfe251aafa25ed18c51601cc.tar.bz2
Make destroyWindowTree build. Start adding addWindowToList tests
-rw-r--r--src/switcher-util.c2
-rw-r--r--tests/check_switcher-util.c63
2 files changed, 47 insertions, 18 deletions
diff --git a/src/switcher-util.c b/src/switcher-util.c
index 82afa32..2cf6d10 100644
--- a/src/switcher-util.c
+++ b/src/switcher-util.c
@@ -101,7 +101,7 @@ void
destroyWindowTree (WindowTree *node)
{
destroyWindowList (node->windows);
- for (int i = 0; i < childrenSize; ++i)
+ for (int i = 0; i < node->childrenSize; ++i)
{
destroyWindowTree (node->children[i]);
}
diff --git a/tests/check_switcher-util.c b/tests/check_switcher-util.c
index 1e37fb1..e37f8e4 100644
--- a/tests/check_switcher-util.c
+++ b/tests/check_switcher-util.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <check.h>
+#include <stdio.h>
#include <compiz.h>
@@ -8,35 +9,64 @@
WindowTree *tree;
WindowList *list;
-void
-setup (void)
-{
- tree = newWindowTree();
- list = newWindowList();
-}
+CompWindow *a, *b, *c, *d;
-void
-teardown (void)
+static Bool testCompare (CompWindow *a, CompWindow *b)
{
+ printf("In testCompare\n");
+ return a == b;
}
-START_TEST (test_list_create)
+START_TEST (test_listCreate)
{
+ list = newWindowList ();
fail_unless (list->nWindows == 0,
"Window list count not set correctly on creation");
fail_unless (list->w != NULL,
"Window array not allocated successfully");
+ fail_unless (list->windowsSize == 32,
+ "Window array size set incorrectly");
}
END_TEST
-START_TEST (test_tree_create)
+START_TEST (test_treeCreate)
{
fail_unless (tree->windows->nWindows == 0 && tree->windows->w != NULL,
"Failed to initialise WindowList on WindowTree creation");
fail_unless (tree->children != NULL,
"Children array not allocated on creation of WindowTree");
+ fail_unless (tree->childrenSize == 4,
+ "Size of childrenArray not set correctly");
+}
+END_TEST
+
+START_TEST (test_addToList)
+{
+ list = newWindowList ();
+
+ fail_unless (addWindowToList (list, a),
+ "addWindowToList returned FALSE");
+
+ fail_unless (list->nWindows == 1,
+ "Window list size not updated correctly");
+ fail_unless (list->w[0] == a,
+ "Wrong window added to list");
+}
+END_TEST
+
+/*
+START_TEST (test_addToTree)
+{
+ fail_unless (addWindowToTree (tree, a, testCompare),
+ "addWindowToTree returned FALSE");
+
+ fail_unless (tree->windows->nWindows == 1,
+ "Window not added to tree");
+ fail_unless (tree->windows->w[0] == a,
+ "Incorrect window added to tree");
}
END_TEST
+*/
Suite *
switcher_util_suite (void)
@@ -46,15 +76,14 @@ switcher_util_suite (void)
/* Core test case */
TCase *tc_core = tcase_create ("Core");
tcase_add_checked_fixture (tc_core, setup, teardown);
- tcase_add_test (tc_core, test_list_create);
- tcase_add_test (tc_core, test_tree_create);
+ tcase_add_test (tc_core, test_listCreate);
+ tcase_add_test (tc_core, test_treeCreate);
suite_add_tcase (s, tc_core);
- /* Limits test case */
-// TCase *tc_limits = tcase_create ("Limits");
-// tcase_add_test (tc_limits, test_money_create_neg);
-// tcase_add_test (tc_limits, test_money_create_zero);
-// suite_add_tcase (s, tc_limits);
+ /* Add windows to tree test cases */
+ TCase *tc_addToList = tcase_create ("Add To List");
+ tcase_add_test (tc_addToList, test_addToList);
+ suite_add_tcase (s, tc_addToList);
return s;
}