作図ソフト dia の改良版
Revisão | dce6d44254e1a95f06204ba02e08a78b95bd9348 (tree) |
---|---|
Hora | 2015-01-12 05:11:44 |
Autor | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
[unit test] fix mismatch between PropDescription and PropOffset
Some objects described themselves to be Element, but were indeed OrthConn.
Few of these issues were originally found by visual inspection of
"Object Types.dia" (from otypes.py). But with the new test more mismatches
were found and fixed.
@@ -145,6 +145,7 @@ static PropOffset stdpath_offsets[] = { | ||
145 | 145 | { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(StdPath, line_width) }, |
146 | 146 | { "line_colour", PROP_TYPE_COLOUR, offsetof(StdPath, line_color) }, |
147 | 147 | { "line_style", PROP_TYPE_LINESTYLE, offsetof(StdPath, line_style), offsetof(StdPath, dashlength) }, |
148 | + { "line_join", PROP_TYPE_ENUM, offsetof(StdPath, line_join) }, | |
148 | 149 | { "line_caps", PROP_TYPE_ENUM, offsetof(StdPath, line_caps) }, |
149 | 150 | { "fill_colour", PROP_TYPE_COLOUR, offsetof(StdPath, fill_color) }, |
150 | 151 | { "show_background", PROP_TYPE_BOOL, offsetof(StdPath, show_background) }, |
@@ -162,7 +162,7 @@ static PropEnumData prop_orthflow_type_data[] = { | ||
162 | 162 | }; |
163 | 163 | |
164 | 164 | static PropDescription orthflow_props[] = { |
165 | - ELEMENT_COMMON_PROPERTIES, | |
165 | + ORTHCONN_COMMON_PROPERTIES, | |
166 | 166 | { "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE, |
167 | 167 | N_("Type:"), NULL, prop_orthflow_type_data }, |
168 | 168 | { "text", PROP_TYPE_TEXT, 0, NULL, NULL }, |
@@ -184,7 +184,7 @@ orthflow_describe_props(Orthflow *mes) | ||
184 | 184 | } |
185 | 185 | |
186 | 186 | static PropOffset orthflow_offsets[] = { |
187 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
187 | + ORTHCONN_COMMON_PROPERTIES_OFFSETS, | |
188 | 188 | { "type", PROP_TYPE_ENUM, offsetof(Orthflow, type) }, |
189 | 189 | { "text", PROP_TYPE_TEXT, offsetof (Orthflow, text) }, |
190 | 190 | { "text_alignment", PROP_TYPE_ENUM, offsetof(Orthflow,text),offsetof(Text,alignment) }, |
@@ -139,7 +139,7 @@ static PropEnumData prop_flow_type_data[] = { | ||
139 | 139 | }; |
140 | 140 | |
141 | 141 | static PropDescription flow_props[] = { |
142 | - OBJECT_COMMON_PROPERTIES, | |
142 | + CONNECTION_COMMON_PROPERTIES, | |
143 | 143 | { "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE, |
144 | 144 | N_("Type:"), NULL, prop_flow_type_data }, |
145 | 145 | { "text", PROP_TYPE_TEXT, 0, NULL, NULL }, |
@@ -161,7 +161,7 @@ flow_describe_props(Flow *mes) | ||
161 | 161 | } |
162 | 162 | |
163 | 163 | static PropOffset flow_offsets[] = { |
164 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
164 | + CONNECTION_COMMON_PROPERTIES_OFFSETS, | |
165 | 165 | { "type", PROP_TYPE_ENUM, offsetof(Flow, type) }, |
166 | 166 | { "text", PROP_TYPE_TEXT, offsetof (Flow, text) }, |
167 | 167 | { "text_alignment", PROP_TYPE_ENUM, offsetof(Flow,text),offsetof(Text,alignment) }, |
@@ -158,7 +158,7 @@ function_describe_props(Function *mes) | ||
158 | 158 | } |
159 | 159 | |
160 | 160 | static PropOffset function_offsets[] = { |
161 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
161 | + ELEMENT_COMMON_PROPERTIES_OFFSETS, | |
162 | 162 | { "wish function", PROP_TYPE_BOOL, offsetof(Function, is_wish) }, |
163 | 163 | { "user function", PROP_TYPE_BOOL, offsetof(Function, is_user) }, |
164 | 164 | { "text", PROP_TYPE_TEXT, offsetof (Function, text) }, |
@@ -149,6 +149,7 @@ implements_describe_props(Implements *implements) | ||
149 | 149 | static PropOffset implements_offsets[] = { |
150 | 150 | CONNECTION_COMMON_PROPERTIES_OFFSETS, |
151 | 151 | { "text", PROP_TYPE_STRING, offsetof(Implements, text) }, |
152 | + { "name", PROP_TYPE_STRING, offsetof(Implements, text) }, | |
152 | 153 | { "text_font", PROP_TYPE_FONT, offsetof(Implements, font) }, |
153 | 154 | { PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT, offsetof(Implements, font_height) }, |
154 | 155 | { "text_colour",PROP_TYPE_COLOUR,offsetof(Implements, text_color) }, |
@@ -132,7 +132,7 @@ static ObjectOps bus_ops = { | ||
132 | 132 | }; |
133 | 133 | |
134 | 134 | static PropDescription bus_props[] = { |
135 | - OBJECT_COMMON_PROPERTIES, | |
135 | + CONNECTION_COMMON_PROPERTIES, | |
136 | 136 | PROP_STD_LINE_COLOUR, |
137 | 137 | PROP_DESC_END |
138 | 138 | }; |
@@ -146,7 +146,7 @@ bus_describe_props(Bus *bus) | ||
146 | 146 | } |
147 | 147 | |
148 | 148 | static PropOffset bus_offsets[] = { |
149 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
149 | + CONNECTION_COMMON_PROPERTIES_OFFSETS, | |
150 | 150 | { "line_colour", PROP_TYPE_COLOUR, offsetof(Bus, line_color) }, |
151 | 151 | { NULL, 0, 0 } |
152 | 152 | }; |
@@ -114,7 +114,7 @@ DiaObjectType wanlink_type = | ||
114 | 114 | }; |
115 | 115 | |
116 | 116 | static PropDescription wanlink_props[] = { |
117 | - OBJECT_COMMON_PROPERTIES, | |
117 | + CONNECTION_COMMON_PROPERTIES, | |
118 | 118 | { "width", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, |
119 | 119 | N_("Width"), NULL, NULL }, |
120 | 120 | PROP_STD_LINE_COLOUR, |
@@ -131,7 +131,7 @@ wanlink_describe_props(WanLink *wanlink) | ||
131 | 131 | } |
132 | 132 | |
133 | 133 | static PropOffset wanlink_offsets[] = { |
134 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
134 | + CONNECTION_COMMON_PROPERTIES_OFFSETS, | |
135 | 135 | { "width", PROP_TYPE_REAL, offsetof(WanLink, width) }, |
136 | 136 | { "line_colour", PROP_TYPE_COLOUR, offsetof(WanLink, line_color) }, |
137 | 137 | { "fill_colour", PROP_TYPE_COLOUR, offsetof(WanLink, fill_color) }, |
@@ -69,10 +69,31 @@ _test_creation (gconstpointer user_data) | ||
69 | 69 | { |
70 | 70 | const PropDescription *pdesc = o->ops->describe_props (o); |
71 | 71 | /* get all properties */ |
72 | - GPtrArray *plist = prop_list_from_descs (pdesc, pdtpp_true); | |
73 | - | |
74 | - g_assert (plist != NULL); | |
75 | - prop_list_free(plist); | |
72 | + GPtrArray *props = prop_list_from_descs (pdesc, pdtpp_true); | |
73 | + int num_described = props->len; | |
74 | + int num_used = 0; | |
75 | + | |
76 | + /* Indirect check of object's private PropDescription and PropOffset array. | |
77 | + * Both arrays should be same length (reference the same properties). | |
78 | + * But the latter is only visible as parameter to object_get_props_from_offsets(), | |
79 | + * at least for objects not intialzing DiaObjectType::prop_offsets | |
80 | + */ | |
81 | + o->ops->get_props (o, props); | |
82 | + for (i = 0; i < num_described; ++i) { | |
83 | + Property *prop = (Property*)g_ptr_array_index(props,i); | |
84 | + if ((prop->experience & PXP_NOTSET) == 0) | |
85 | + ++num_used; | |
86 | + else if ((prop->descr->flags & PROP_FLAG_WIDGET_ONLY) != 0) | |
87 | + ++num_used; /* ... but not expected to be set */ | |
88 | + else if (strcmp (prop->descr->type, PROP_TYPE_STATIC) == 0) | |
89 | + ++num_used; /* also not to be set */ | |
90 | + else | |
91 | + g_print ("Not set '%s'\n", prop->descr->name); | |
92 | + } | |
93 | + g_assert_cmpint (num_used, ==, num_described); | |
94 | + | |
95 | + g_assert (props != NULL); | |
96 | + prop_list_free(props); | |
76 | 97 | } |
77 | 98 | /* not implemented anywhere */ |
78 | 99 | g_assert (o->ops->edit_text == NULL); |