[graphics] fix tests
[scilab.git] / scilab / modules / graphics / tests / unit_tests / plot_demo.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2011 - DIGITEO - Bruno JOFRET
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 //
8 // <-- TEST WITH GRAPHIC -->
9 // <-- NO CHECK REF -->
10 //
11 // test plot()
12
13 // Check each default property
14 plot();
15 f = gcf();
16 a1 = f.children(1);
17 a2 = f.children(2);
18 c1 = a1.children(1);
19 c2 = a2.children(1);
20 p1 = c1.children;
21 p2 = c2.children;
22
23 // Check figure
24 //assert_checkequal(f.figure_position, [200,200]);
25 //assert_checkequal(f.figure_size, [614,568]);
26 //assert_checkequal(f.axes_size, [610, 460]);
27 assert_checkequal(f.auto_resize, "on");
28 assert_checkequal(f.viewport, [0,0]);
29 assert_checkequal(f.figure_name, gettext("Graphic window number %d"));
30 assert_checkequal(f.figure_id, 0);
31 assert_checkequal(f.pixel_drawing_mode, "copy");
32 assert_checkequal(f.anti_aliasing, "off");
33 assert_checkequal(f.immediate_drawing, "on");
34 assert_checkequal(f.background, -2);
35 assert_checkequal(f.visible, "on");
36 assert_checkequal(f.rotation_style, "unary");
37 assert_checkequal(f.event_handler, "");
38 assert_checkequal(f.event_handler_enable, "off");
39 assert_checkequal(f.user_data, []);
40 assert_checkequal(f.tag, "");
41 assert_checkequal(f.info_message, "");
42 handMadeColorMap = [0,0,0;
43 0,0,1;
44 0,1,0;
45 0,1,1;
46 1,0,0;
47 1,0,1;
48 1,1,0;
49 1,1,1;
50 0,0,0.5647058823529411686337;
51 0,0,0.6901960784313725394412;
52 0,0,0.8156862745098039102487;
53 0.5294117647058823594719,0.8078431372549019773288,1;
54 0,0.5647058823529411686337,0;
55 0,0.6901960784313725394412,0;
56 0,0.8156862745098039102487,0;
57 0,0.5647058823529411686337,0.5647058823529411686337;
58 0,0.6901960784313725394412,0.6901960784313725394412;
59 0,0.8156862745098039102487,0.8156862745098039102487;
60 0.5647058823529411686337,0,0;
61 0.6901960784313725394412,0,0;
62 0.8156862745098039102487,0,0;
63 0.5647058823529411686337,0,0.5647058823529411686337;
64 0.6901960784313725394412,0,0.6901960784313725394412;
65 0.8156862745098039102487,0,0.8156862745098039102487;
66 0.5019607843137254832300,0.1882352941176470562112,0;
67 0.6274509803921568540375,0.2509803921568627416150,0;
68 0.7529411764705882248450,0.3764705882352941124225,0;
69 1,0.5019607843137254832300,0.5019607843137254832300;
70 1,0.6274509803921568540375,0.6274509803921568540375;
71 1,0.7529411764705882248450,0.7529411764705882248450;
72 1,0.8784313725490195956525,0.8784313725490195956525;
73 1,0.8431372549019607864906,0;
74 0,0.5,0;
75 0,0.75,0.75;
76 0.75,0,0.75;
77 0.75,0.75,0;
78 0.25,0.25,0.25];
79 assert_checkequal(f.color_map, handMadeColorMap);
80
81
82 // Check Axes 1
83 assert_checkequal(a1.visible, "on");
84 assert_checkequal(a1.axes_visible, ["on" "on" "on"]);
85 assert_checkequal(a1.axes_reverse, ["off" "off" "off"]);
86 assert_checkequal(a1.grid, [-1 -1]);
87 assert_checkequal(a1.grid_position, "background");
88 assert_checkequal(a1.x_location, "bottom");
89 assert_checkequal(a1.y_location, "left");
90 assert_checkequal(a1.auto_ticks, ["on" "on" "on"]);
91 //assert_checkequal(a1.x_ticks.locations, [0:0.1:1]');
92 //assert_checkequal(a1.y_ticks.locations, [0:0.1:1]');
93 //assert_checkequal(a1.z_ticks.locations, []);
94 assert_checkequal(a1.box, "on");
95 assert_checkequal(a1.filled, "on");
96 assert_checkequal(a1.sub_ticks, [1, 4]);
97 assert_checkequal(a1.font_style, 6);
98 assert_checkequal(a1.font_size, 1);
99 assert_checkequal(a1.font_color, -1);
100 assert_checkequal(a1.fractional_font, "off");
101 assert_checkequal(a1.isoview, "off");
102 assert_checkequal(a1.cube_scaling, "off");
103 assert_checkequal(a1.view, "2d");
104 assert_checkequal(a1.rotation_angles, [0, 270]);
105 assert_checkequal(a1.log_flags, "nnn");
106 assert_checkequal(a1.tight_limits, ["off", "off", "off"]);
107 assert_checkequal(a1.data_bounds, [1, -1 ; 2, 1]);
108 assert_checkequal(a1.zoom_box, []);
109 assert_checkequal(a1.margins, [0.125, 0.125, 0.125, 0.125]);
110 assert_checkequal(a1.axes_bounds, [0, 0.5, 1, 0.5]);
111 assert_checkequal(a1.auto_clear, "off");
112 assert_checkequal(a1.auto_scale, "on");
113 assert_checkequal(a1.hidden_axis_color, 4);
114 assert_checkequal(a1.hiddencolor, 4);
115 assert_checkequal(a1.line_mode, "on");
116 assert_checkequal(a1.line_style, 1);
117 assert_checkequal(a1.thickness, 1);
118 assert_checkequal(a1.mark_mode, "off");
119 assert_checkequal(a1.mark_style, 0);
120 assert_checkequal(a1.mark_size_unit, "tabulated");
121 assert_checkequal(a1.mark_size, 0);
122 assert_checkequal(a1.mark_foreground, -1);
123 assert_checkequal(a1.mark_background, -2);
124 assert_checkequal(a1.foreground, -1);
125 assert_checkequal(a1.background, -2);
126 assert_checkequal(a1.arc_drawing_method, "lines");
127 assert_checkequal(a1.clip_state, "clipgrf");
128 assert_checkequal(a1.clip_box, []);
129 assert_checkequal(a1.user_data, []);
130
131 // Check Axes 2
132 assert_checkequal(a2.visible, "on");
133 assert_checkequal(a2.axes_visible, ["on" "on" "on"]);
134 assert_checkequal(a2.axes_reverse, ["off" "off" "off"]);
135 assert_checkequal(a2.grid, [-1 -1]);
136 assert_checkequal(a2.grid_position, "background");
137 assert_checkequal(a2.x_location, "bottom");
138 assert_checkequal(a2.y_location, "left");
139 assert_checkequal(a2.auto_ticks, ["on" "on" "on"]);
140 //assert_checkequal(a2.x_ticks.locations, [0:0.1:1]');
141 //assert_checkequal(a2.y_ticks.locations, [0:0.1:1]');
142 //assert_checkequal(a2.z_ticks.locations, []);
143 assert_checkequal(a2.box, "on");
144 assert_checkequal(a2.filled, "on");
145 assert_checkequal(a2.sub_ticks, [0, 4]);
146 assert_checkequal(a2.font_style, 6);
147 assert_checkequal(a2.font_size, 1);
148 assert_checkequal(a2.font_color, -1);
149 assert_checkequal(a2.fractional_font, "off");
150 assert_checkequal(a2.isoview, "off");
151 assert_checkequal(a2.cube_scaling, "off");
152 assert_checkequal(a2.view, "2d");
153 assert_checkequal(a2.rotation_angles, [0, 270]);
154 assert_checkequal(a2.log_flags, "nnn");
155 assert_checkequal(a2.tight_limits, ["off", "off", "off"]);
156 assert_checkequal(a2.data_bounds, [0, -1 ; 2 * %pi, 1]);
157 assert_checkequal(a2.zoom_box, []);
158 assert_checkequal(a2.margins, [0.125, 0.125, 0.125, 0.125]);
159 assert_checkequal(a2.axes_bounds, [0, 0, 1, 0.5]);
160 assert_checkequal(a2.auto_clear, "off");
161 assert_checkequal(a2.auto_scale, "on");
162 assert_checkequal(a2.hidden_axis_color, 4);
163 assert_checkequal(a2.hiddencolor, 4);
164 assert_checkequal(a2.line_mode, "on");
165 assert_checkequal(a2.line_style, 1);
166 assert_checkequal(a2.thickness, 1);
167 assert_checkequal(a2.mark_mode, "off");
168 assert_checkequal(a2.mark_style, 0);
169 assert_checkequal(a2.mark_size_unit, "tabulated");
170 assert_checkequal(a2.mark_size, 0);
171 assert_checkequal(a2.mark_foreground, -1);
172 assert_checkequal(a2.mark_background, -2);
173 assert_checkequal(a2.foreground, -1);
174 assert_checkequal(a2.background, -2);
175 assert_checkequal(a2.arc_drawing_method, "lines");
176 assert_checkequal(a2.clip_state, "clipgrf");
177 assert_checkequal(a2.clip_box, []);
178 assert_checkequal(a2.user_data, []);
179
180 // Compound 1
181 assert_checkequal(c1.parent.type, "Axes");
182 assert_checkequal(c1.children(:).type, emptystr(41,1) + "Polyline");
183 assert_checkequal(c1.visible, "on");
184 assert_checkequal(c1.user_data, []);
185
186 // Compount 2
187 assert_checkequal(c2.parent.type, "Axes");
188 assert_checkequal(c2.children(:).type, emptystr(3,1) + "Polyline");
189 assert_checkequal(c2.visible, "on");
190 assert_checkequal(c2.user_data, []);
191
192 // Check Polylines in Compound 1
193 assert_checkequal(p1(:).parent.type, emptystr(41,1) + "Compound");
194 assert_checkequal(p1(:).children, []);
195 assert_checkequal(p1(:).visible, emptystr(41,1) + "on");
196 // Don't know how to check those data's
197 //assert_checkequal(p1.data, [demoData, sin(3 * demoData)]);
198 assert_checkequal(p1(:).closed, emptystr(41,1) + "off");
199 assert_checkequal(p1(:).line_mode, emptystr(41,1) + "on");
200 assert_checkequal(p1(:).fill_mode, emptystr(41,1) + "off");
201 assert_checkequal(p1(:).line_style, ones(41,1));
202 assert_checkequal(p1(:).thickness, ones(41,1));
203 assert_checkequal(p1(:).arrow_size_factor, ones(41,1));
204 assert_checkequal(p1(:).polyline_style, ones(41,1));
205 fg_colors = [36 , 35 , 34 , 5 , 33 , 2 , 37 , 36 , 35 , 34 , 5 , 33 ,...
206 2 , 37 , 36 , 35 , 34 , 5 , 33 , 2 , 37 , 36 , 35 , 34 ,...
207 5 , 33 , 2 , 37 , 36 , 35 , 34 , 5 , 33 , 2 , 37 , 36 ,...
208 35 , 34 , 5 , 33 , 2]';
209 assert_checkequal(p1(:).foreground, fg_colors);
210 assert_checkequal(p1(:).background, -2 * ones(41,1));
211 assert_checkequal(p1(:).interp_color_vector, []);
212 assert_checkequal(p1(:).interp_color_mode, emptystr(41,1) + "off");
213 assert_checkequal(p1(:).mark_mode, emptystr(41,1) + "off");
214 assert_checkequal(p1(:).mark_style, zeros(41,1));
215 assert_checkequal(p1(:).mark_size_unit, emptystr(41,1) + "point");
216 assert_checkequal(p1(:).mark_size, zeros(41,1));
217 assert_checkequal(p1(:).mark_foreground, -1 * ones(41,1));
218 assert_checkequal(p1(:).mark_background, -2 * ones(41,1));
219 assert_checkequal(p1(:).x_shift, []);
220 assert_checkequal(p1(:).y_shift, []);
221 assert_checkequal(p1(:).z_shift, []);
222 assert_checkequal(p1(:).bar_width, zeros(41,1));
223 assert_checkequal(p1(:).clip_state, emptystr(41,1) + "clipgrf");
224 assert_checkequal(p1(:).clip_box, []);
225 assert_checkequal(p1(:).user_data, []);
226
227 // Check Polylines in Compound 2
228 demoData = [0:%pi/20:2*%pi]';
229 assert_checkequal(p2(:).parent.type, emptystr(3,1) + "Compound");
230 assert_checkequal(p2(:).children, []);
231 assert_checkequal(p2(:).visible, emptystr(3,1) + "on");
232 assert_checkequal(p2(1).data, [demoData, abs(sin(demoData))]);
233 assert_checkequal(p2(2).data, [demoData, cos(demoData)]);
234 assert_checkequal(p2(3).data, [demoData, sin(demoData)]);
235 assert_checkequal(p2(:).closed, emptystr(3,1) + "off");
236 assert_checkequal(p2(:).line_mode, ["on" ; "off" ; "on"]);
237 assert_checkequal(p2(:).fill_mode, emptystr(3,1) + "off");
238 assert_checkequal(p2(:).line_style, [2 ; 1 ; 4]);
239 assert_checkequal(p2(:).thickness, ones(3,1));
240 assert_checkequal(p2(:).arrow_size_factor, ones(3,1));
241 assert_checkequal(p2(:).polyline_style, ones(3,1));
242 assert_checkequal(p2(:).foreground, [6 ; 1 ; 5]);
243 assert_checkequal(p2(:).background, -2 * ones(3,1));
244 assert_checkequal(p2(:).interp_color_vector, []);
245 assert_checkequal(p2(:).interp_color_mode, emptystr(3,1) + "off");
246 assert_checkequal(p2(:).mark_mode, emptystr(3,1) + "on");
247 assert_checkequal(p2(:).mark_style, [9 ; 1 ; 9]);
248 assert_checkequal(p2(:).mark_size_unit, emptystr(3,1) + "point");
249 assert_checkequal(p2(:).mark_size, 6 * ones(3,1));
250 assert_checkequal(p2(:).mark_foreground, [6 ; 4 ; 5]);
251 assert_checkequal(p2(:).mark_background, -2 * ones(3,1));
252 assert_checkequal(p2(:).x_shift, []);
253 assert_checkequal(p2(:).y_shift, []);
254 assert_checkequal(p2(:).z_shift, []);
255 assert_checkequal(p2(:).bar_width, zeros(3,1));
256 assert_checkequal(p2(:).clip_state, emptystr(3,1) + "clipgrf");
257 assert_checkequal(p2(:).clip_box, []);
258 assert_checkequal(p2(:).user_data, []);