summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-26 11:49:37 +1000
committerChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-26 11:49:37 +1000
commit773d44ecbc0dd5953b6941e366074cccaaa5cf25 (patch)
tree824e74dcb91da45a84f67e70c76fa1de637224c3
parentbb9b6f4ef947ddc646959ba792c134850a854649 (diff)
downloadradial-switcher-773d44ecbc0dd5953b6941e366074cccaaa5cf25.tar.gz
radial-switcher-773d44ecbc0dd5953b6941e366074cccaaa5cf25.tar.bz2
Reindent testcases, add first addWindowToTree testcase.
-rw-r--r--src/switcher-util.c25
-rw-r--r--src/switcher-util.h4
-rw-r--r--tests/check_switcher-util.c51
3 files changed, 34 insertions, 46 deletions
diff --git a/src/switcher-util.c b/src/switcher-util.c
index f2d6e4f..88f8770 100644
--- a/src/switcher-util.c
+++ b/src/switcher-util.c
@@ -119,28 +119,11 @@ destroyWindowTree (WindowTree *node)
* @return: True on success
**/
Bool
-addWindowToTree (WindowTree *node,
- CompWindow *w,
- WindowCmpProc isSameGroup)
+addWindowToTree (WindowTree *node,
+ CompWindow *w,
+ WindowCmpProc isSameGroup)
{
- for (int i = 0; i < node->windows->nWindows; ++i)
- {
- if (isSameGroup (node->windows->w[i], w))
- {
- if (!node->children[i])
- node->children[i] = newWindowTree();
- return addWindowToTree (node->children[i], w, isSameGroup);
- }
- }
- if (node->childrenSize <= node->windows->nWindows)
- node->children = realloc (node->children,
- sizeof(WindowTree *) * \
- (node->childrenSize + 32));
- if (!node->children)
- return FALSE;
- node->childrenSize += 32;
-
- return addWindowToList (node->windows, w);
+ return addWindowToList(node->windows, w);
}
/**
diff --git a/src/switcher-util.h b/src/switcher-util.h
index e6538c3..303fa7e 100644
--- a/src/switcher-util.h
+++ b/src/switcher-util.h
@@ -84,8 +84,8 @@ void destroyWindowTree (WindowTree *node);
* @return: True on success
**/
Bool addWindowToTree (WindowTree *node,
- CompWindow *w,
- WindowCmpProc isSameGroup);
+ CompWindow *w,
+ WindowCmpProc isSameGroup);
/**
* Create a WindowTree from a list of windows.
diff --git a/tests/check_switcher-util.c b/tests/check_switcher-util.c
index a74bc3d..7d01c3f 100644
--- a/tests/check_switcher-util.c
+++ b/tests/check_switcher-util.c
@@ -24,7 +24,6 @@ void setup ()
void teardown ()
{
destroyWindowList (list);
- destroyWindowTree (tree);
}
static Bool testCompare (CompWindow *a, CompWindow *b)
@@ -34,7 +33,6 @@ static Bool testCompare (CompWindow *a, CompWindow *b)
START_TEST (test_listCreate)
{
- list = newWindowList ();
fail_unless (list->nWindows == 0,
"Window list count not set correctly on creation");
fail_unless (list->w != NULL,
@@ -46,7 +44,8 @@ END_TEST
START_TEST (test_treeCreate)
{
- fail_unless (tree->windows->nWindows == 0 && tree->windows->w != NULL,
+ fail_unless (tree->windows->nWindows == 0 && tree->windows->w != NULL && \
+ tree->windows->windowsSize == 32,
"Failed to initialise WindowList on WindowTree creation");
fail_unless (tree->children != NULL,
"Children array not allocated on creation of WindowTree");
@@ -88,10 +87,10 @@ START_TEST (test_addMultipleToList)
}
END_TEST
-/*
+
START_TEST (test_addToTree)
{
- fail_unless (addWindowToTree (tree, a, testCompare),
+ fail_unless (addWindowToTree (tree, a, &testCompare),
"addWindowToTree returned FALSE");
fail_unless (tree->windows->nWindows == 1,
@@ -100,28 +99,34 @@ START_TEST (test_addToTree)
"Incorrect window added to tree");
}
END_TEST
-*/
+
Suite *
switcher_util_suite (void)
{
- Suite *s = suite_create ("Switcher Util");
-
- /* Core test case */
- TCase *tc_core = tcase_create ("Core");
- tcase_add_checked_fixture (tc_core, setup, teardown);
- tcase_add_test (tc_core, test_listCreate);
- tcase_add_test (tc_core, test_treeCreate);
- suite_add_tcase (s, tc_core);
-
- /* Add windows to tree test cases */
- TCase *tc_addToList = tcase_create ("Add To List");
- tcase_add_checked_fixture (tc_addToList, setup, teardown);
- tcase_add_test (tc_addToList, test_addToList);
- tcase_add_test (tc_addToList, test_addMultipleToList);
- suite_add_tcase (s, tc_addToList);
-
- return s;
+ Suite *s = suite_create ("Switcher Util");
+
+ /* Core test case */
+ TCase *tc_core = tcase_create ("Core");
+ tcase_add_checked_fixture (tc_core, setup, teardown);
+ tcase_add_test (tc_core, test_listCreate);
+ tcase_add_test (tc_core, test_treeCreate);
+ suite_add_tcase (s, tc_core);
+
+ /* Add windows to tree List cases */
+ TCase *tc_addToList = tcase_create ("Add To List");
+ tcase_add_checked_fixture (tc_addToList, setup, teardown);
+ tcase_add_test (tc_addToList, test_addToList);
+ tcase_add_test (tc_addToList, test_addMultipleToList);
+ suite_add_tcase (s, tc_addToList);
+
+ /* Add windows to tree test cases */
+ TCase *tc_addToTree = tcase_create ("Add To Tree");
+ tcase_add_checked_fixture (tc_addToTree, setup, teardown);
+ tcase_add_test (tc_addToTree, test_addToTree);
+ suite_add_tcase (s, tc_addToTree);
+
+ return s;
}
int