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