Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / docs / random / omega / testing / framework
1 Construction
2 Validation
3 Testing
4
5 Construction will generate some state
6 Validation will ensure that everything is kosher
7 Tests use combinations of the above to check things
8
9 ##### Example:
10 parent = gst_object_get_parent(object);
11
12 setup:
13         create: new object
14                 action: object = gst_object_new();
15                 validation: object != NULL, object->parent == NULL, etc
16                 [cleanup: gst_object_destroy(object);]
17         create: new parent
18                 action: parent = gst_object_new();
19                 validation: parent != NULL, parent->parent == NULL, etc
20                 [cleanup: gst_object_destroy(parent);]
21         create: set object's parent
22                 precondition: object->parent == NULL
23                 action: gst_object_set_parent(object,parent);
24                 validation: object->parent = parent
25 preconditions:
26         nothing
27 action:
28         curparent = gst_element_get_parent(object);
29 validation:
30         curparent == object->parent
31         curparent == parent
32 cleanup:
33         nothing
34
35
36 ##### Resulting code:
37
38 ///// setup
39 // new object
40 object = gst_object_new();
41 ASSERT(object != NULL);
42 ASSERT(object->parent == NULL);
43 // new object
44 parent = gst_object_new();
45 ASSERT(parent != NULL);
46 ASSERT(parent->parent == NULL);
47 // set object parent
48 ASSERT(object->parent == NULL);
49 gst_object_set_parent(object,parent);
50 ASSERT(object->parent != NULL);
51
52 ///// preconditions
53
54 ///// action
55 curparent = gst_element_get_parent(object);
56
57 ///// validation
58 ASSERT(object->parent == parent);
59
60 ///// cleanup
61 gst_object_destroy(parent);
62 gst_object_destroy(object);
63
64
65
66 ##### XML descriptions
67
68 <construct name="new object">
69   <variable>
70     GstObject *object;
71   </variabls>
72   <action>
73     object = gst_object_new();
74   </action>
75   <validation>
76     <assert>
77       object != NULL
78     </assert>
79     <assert>
80       GST_IS_OBJECT(object)
81     <assert>
82       object->parent == NULL
83     </assert>
84   </validation>
85   <cleanup>
86     <validation>
87       <assert>
88         object != NULL
89       </assert>
90       <assert>
91         GST_IS_OBJECT(object)
92       </assert>
93     </validation>
94     <action>
95       gst_object_destroy(object);
96     </action>
97   </cleanup>
98 </construct>
99
100 <construct name="set object parent">
101   <variable>
102     GstObject *object;
103   </variable>
104   <variable>
105     GstObject *object;
106   </variable>
107   <precondition>
108     <assert>
109       object->parent == NULL
110     </assert>
111   </precondition>
112   <action>
113     gst_object_set_parent(object,parent);
114   </action>
115   <validation>
116     <assert>
117       object->parent == parent
118     </assert>
119   </validation>
120 </construct>
121
122 <test name="set object parent">
123   <variable>
124     GstObject *object;
125   <variable>
126   </variable>
127     GstObject *parent;
128   <variable>
129   </variable>
130     GstObject *curparent;
131   </variable>
132   <setup>
133     object = gst_object_new();
134     parent = gst_object_new();
135     gst_object_set_parent(object,parent);
136   </setup>
137   <action>
138     curparent = gst_element_get_parent(object);
139   </action>
140   <validation>
141     curparent == object->parent
142     curparent == parent
143   </validation>
144 </test>