# HG changeset patch # User Pantxo Diribarne # Date 1401219105 -7200 # Node ID 2420a4f22998f60a63b0adbfcc88bd24a3f9cac8 # Parent 284f7fa221e908fd87b1d686021d71c45edfdbe1 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554) * graphics.cc: split tests for "paperpositionmode" property and increase tolerance to allow small conversion errors diff -r 284f7fa221e9 -r 2420a4f22998 libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Mon Jun 30 22:34:07 2014 +0200 +++ b/libinterp/corefcn/graphics.cc Tue May 27 21:31:45 2014 +0200 @@ -4000,43 +4000,82 @@ /* %!test -%! hf = figure ("visible", "off"); +%! hf = figure ("visible", "off", "paperpositionmode", "auto"); +%! in_pos = [0 0 4 5]; +%! tol = 20 * eps (); %! unwind_protect %! ## paperpositionmode "auto" converts figure size to paper units %! set (hf, "units", "inches"); -%! set (hf, "position", [0 0 4 5]); +%! set (hf, "position", in_pos); %! set (hf, "paperunits", "centimeters"); %! psz = get (hf, "papersize"); -%! fsz = [10.16 12.7]; +%! fsz = in_pos(3:4) * 2.54; %! pos = [(psz/2 .- fsz/2) fsz]; %! set (hf, "paperpositionmode", "auto"); -%! assert (get (hf, "paperposition"), pos) -%! +%! assert (get (hf, "paperposition"), pos, tol) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure ("visible", "off", "paperpositionmode", "auto"); +%! in_pos = [0 0 4 5]; +%! tol = 20 * eps (); +%! unwind_protect %! ## likewise with normalized units +%! set (hf, "units", "inches"); +%! set (hf, "position", in_pos); +%! psz = get (hf, "papersize"); %! set (hf, "paperunits", "normalized"); -%! fsz = [10.16 12.7]./psz; +%! fsz = in_pos(3:4) ./ psz; %! pos = [([0.5 0.5] .- fsz/2) fsz]; -%! assert (get (hf, "paperposition"), pos) -%! +%! assert (get (hf, "paperposition"), pos, tol) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure ("visible", "off", "paperpositionmode", "auto"); +%! in_pos = [0 0 4 5]; +%! tol = 20 * eps (); +%! unwind_protect %! ## changing papertype updates paperposition -%! set (hf, "paperunits", "centimeters"); +%! set (hf, "units", "inches"); +%! set (hf, "position", in_pos); %! set (hf, "papertype", "a4"); %! psz = get (hf, "papersize"); -%! fsz = [10.16 12.7]; +%! fsz = in_pos(3:4); %! pos = [(psz/2 .- fsz/2) fsz]; -%! assert (get (hf, "paperposition"), pos) -%! +%! assert (get (hf, "paperposition"), pos, tol) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure ("visible", "off", "paperpositionmode", "auto"); +%! in_pos = [0 0 4 5]; +%! tol = 20 * eps (); +%! unwind_protect %! ## lanscape updates paperposition +%! set (hf, "units", "inches"); +%! set (hf, "position", in_pos); %! set (hf, "paperorientation", "landscape"); %! psz = get (hf, "papersize"); -%! fsz = [10.16 12.7]; +%! fsz = in_pos(3:4); %! pos = [(psz/2 .- fsz/2) fsz]; -%! assert (get (hf, "paperposition"), pos) -%! +%! assert (get (hf, "paperposition"), pos, tol) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure ("visible", "off", "paperpositionmode", "auto"); +%! in_pos = [0 0 4 5]; +%! unwind_protect %! ## back to manual mode -%! set (hf, "paperposition", pos+eps) +%! set (hf, "paperposition", in_pos * 1.1) %! assert (get (hf, "paperpositionmode"), "manual") -%! assert (get (hf, "paperposition"), pos + eps) +%! assert (get (hf, "paperposition"), in_pos * 1.1) %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect