1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include <stdlib.h>
#include <check.h>
#include <stdio.h>
#include <compiz.h>
#include "../src/switcher-util.h"
WindowTree *tree;
WindowList *list;
CompWindow *a, *b, *c, *d;
void setup ()
{
list = newWindowList ();
tree = newWindowTree ();
a = 0x5;
b = 0x4;
c = 0x4;
d = 0x4;
}
void teardown ()
{
}
static Bool testCompare (CompWindow *a, CompWindow *b)
{
printf("In testCompare\n");
return a == 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,
"Window array not allocated successfully");
fail_unless (list->windowsSize == 32,
"Window array size set incorrectly");
}
END_TEST
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)
{
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)
{
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);
suite_add_tcase (s, tc_addToList);
return s;
}
int
main (void)
{
int number_failed;
Suite *s = switcher_util_suite ();
SRunner *sr = srunner_create (s);
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|