comparison libinterp/corefcn/graphics.cc @ 18926:2420a4f22998

Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554) * graphics.cc: split tests for "paperpositionmode" property and increase tolerance to allow small conversion errors
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 27 May 2014 21:31:45 +0200
parents 284f7fa221e9
children df972b9d080a
comparison
equal deleted inserted replaced
18925:284f7fa221e9 18926:2420a4f22998
3998 return pos; 3998 return pos;
3999 } 3999 }
4000 4000
4001 /* 4001 /*
4002 %!test 4002 %!test
4003 %! hf = figure ("visible", "off"); 4003 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
4004 %! in_pos = [0 0 4 5];
4005 %! tol = 20 * eps ();
4004 %! unwind_protect 4006 %! unwind_protect
4005 %! ## paperpositionmode "auto" converts figure size to paper units 4007 %! ## paperpositionmode "auto" converts figure size to paper units
4006 %! set (hf, "units", "inches"); 4008 %! set (hf, "units", "inches");
4007 %! set (hf, "position", [0 0 4 5]); 4009 %! set (hf, "position", in_pos);
4008 %! set (hf, "paperunits", "centimeters"); 4010 %! set (hf, "paperunits", "centimeters");
4009 %! psz = get (hf, "papersize"); 4011 %! psz = get (hf, "papersize");
4010 %! fsz = [10.16 12.7]; 4012 %! fsz = in_pos(3:4) * 2.54;
4011 %! pos = [(psz/2 .- fsz/2) fsz]; 4013 %! pos = [(psz/2 .- fsz/2) fsz];
4012 %! set (hf, "paperpositionmode", "auto"); 4014 %! set (hf, "paperpositionmode", "auto");
4013 %! assert (get (hf, "paperposition"), pos) 4015 %! assert (get (hf, "paperposition"), pos, tol)
4014 %! 4016 %! unwind_protect_cleanup
4017 %! close (hf);
4018 %! end_unwind_protect
4019
4020 %!test
4021 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
4022 %! in_pos = [0 0 4 5];
4023 %! tol = 20 * eps ();
4024 %! unwind_protect
4015 %! ## likewise with normalized units 4025 %! ## likewise with normalized units
4026 %! set (hf, "units", "inches");
4027 %! set (hf, "position", in_pos);
4028 %! psz = get (hf, "papersize");
4016 %! set (hf, "paperunits", "normalized"); 4029 %! set (hf, "paperunits", "normalized");
4017 %! fsz = [10.16 12.7]./psz; 4030 %! fsz = in_pos(3:4) ./ psz;
4018 %! pos = [([0.5 0.5] .- fsz/2) fsz]; 4031 %! pos = [([0.5 0.5] .- fsz/2) fsz];
4019 %! assert (get (hf, "paperposition"), pos) 4032 %! assert (get (hf, "paperposition"), pos, tol)
4020 %! 4033 %! unwind_protect_cleanup
4034 %! close (hf);
4035 %! end_unwind_protect
4036
4037 %!test
4038 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
4039 %! in_pos = [0 0 4 5];
4040 %! tol = 20 * eps ();
4041 %! unwind_protect
4021 %! ## changing papertype updates paperposition 4042 %! ## changing papertype updates paperposition
4022 %! set (hf, "paperunits", "centimeters"); 4043 %! set (hf, "units", "inches");
4044 %! set (hf, "position", in_pos);
4023 %! set (hf, "papertype", "a4"); 4045 %! set (hf, "papertype", "a4");
4024 %! psz = get (hf, "papersize"); 4046 %! psz = get (hf, "papersize");
4025 %! fsz = [10.16 12.7]; 4047 %! fsz = in_pos(3:4);
4026 %! pos = [(psz/2 .- fsz/2) fsz]; 4048 %! pos = [(psz/2 .- fsz/2) fsz];
4027 %! assert (get (hf, "paperposition"), pos) 4049 %! assert (get (hf, "paperposition"), pos, tol)
4028 %! 4050 %! unwind_protect_cleanup
4051 %! close (hf);
4052 %! end_unwind_protect
4053
4054 %!test
4055 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
4056 %! in_pos = [0 0 4 5];
4057 %! tol = 20 * eps ();
4058 %! unwind_protect
4029 %! ## lanscape updates paperposition 4059 %! ## lanscape updates paperposition
4060 %! set (hf, "units", "inches");
4061 %! set (hf, "position", in_pos);
4030 %! set (hf, "paperorientation", "landscape"); 4062 %! set (hf, "paperorientation", "landscape");
4031 %! psz = get (hf, "papersize"); 4063 %! psz = get (hf, "papersize");
4032 %! fsz = [10.16 12.7]; 4064 %! fsz = in_pos(3:4);
4033 %! pos = [(psz/2 .- fsz/2) fsz]; 4065 %! pos = [(psz/2 .- fsz/2) fsz];
4034 %! assert (get (hf, "paperposition"), pos) 4066 %! assert (get (hf, "paperposition"), pos, tol)
4035 %! 4067 %! unwind_protect_cleanup
4068 %! close (hf);
4069 %! end_unwind_protect
4070
4071 %!test
4072 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
4073 %! in_pos = [0 0 4 5];
4074 %! unwind_protect
4036 %! ## back to manual mode 4075 %! ## back to manual mode
4037 %! set (hf, "paperposition", pos+eps) 4076 %! set (hf, "paperposition", in_pos * 1.1)
4038 %! assert (get (hf, "paperpositionmode"), "manual") 4077 %! assert (get (hf, "paperpositionmode"), "manual")
4039 %! assert (get (hf, "paperposition"), pos + eps) 4078 %! assert (get (hf, "paperposition"), in_pos * 1.1)
4040 %! unwind_protect_cleanup 4079 %! unwind_protect_cleanup
4041 %! close (hf); 4080 %! close (hf);
4042 %! end_unwind_protect 4081 %! end_unwind_protect
4043 */ 4082 */
4044 4083