Commit 157c987
Test case Testcase results: Overview Passed Font data reader Passed Argument list Passed Glyph ranges Passed Glyph table Passed Active edit point Passed Unicode hex values Passed Reverse path Passed Reverse random paths Passed Coordinates Passed Pen tool Passed Delete edit points Passed Convert to quadratic path Passed Notdef Passed Merge Passed Over path Passed Preview Passed Export Passed Background coordinates Passed Spin button Passed Inkscape import Passed Total 21 test cases executed, 21 passed and 0 failed.
Changed files (10)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/EotWriter.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/GlyphCanvas.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/TestCases.valamodifiedlibbirdfont/TestSupplement.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -801,9 +801,7 @@ public class GlyphCanvasArea : DrawingArea { ug = true; } - if (ug) {- //redraw_area (1, 1, 2, 2);- } else if (unlikely (allocation.width % 2 != 0 || allocation.height % 2 != 0)) {+ if (unlikely (allocation.width % 2 != 0 || allocation.height % 2 != 0)) { warning (@"\nGlyph canvas is not divisible by two.\nWidth: $(allocation.width)\nHeight: $(allocation.height)"); } @@ -54,8 +54,8 @@ class EotWriter : GLib.Object { eot_file = File.new_for_path (eot_file_name); if (eot_file.query_exists ()) {- warning ("File exists in eot export.");- return;+ warning ("EOT file exists in eot export.");+ eot_file.delete (); } os = new DataOutputStream(eot_file.create (FileCreateFlags.REPLACE_DESTINATION));@@ -517,9 +517,9 @@ public class Font : GLib.Object { os.put_string ("<font>\n"); // this a backup of another font- if (backup) {+ if (!backup) { if (unlikely (font_file == null)) {- warning ("No file name is set, can't create backup.");+ warning ("No file name is set, write backup file name to font file."); } else { os.put_string ("\n"); os.put_string (@"<backup>$((!) font_file)</backup>\n"); @@ -46,7 +46,9 @@ public class GlyphCanvas : GLib.Object { g.allocation = allocation; - warn_if_fail (g.allocation.width != 0 && g.allocation.height != 0); + if (g.allocation.width == 0 || g.allocation.height == 0) { + warning ("area is zero in glyph canvas"); + } } current_display = fd; @@ -708,7 +708,6 @@ public class Path { public bool is_over_boundry_precision (double x, double y, double p) { if (unlikely (ymin == double.MAX || ymin == 10000)) {- warning (@"no bounding box. length ($(points.length ()))"); update_region_boundries (); } @@ -1769,11 +1768,19 @@ public class Path { return true; } - public void append_path (Path path)- requires (points.length () > 0 && is_open () && path.is_open ()) {+ public void append_path (Path path) { EditPointHandle handle; EditPoint first; + if (points.length () == 0) {+ warning ("No points");+ return;+ }++ if (!is_open () || !path.is_open ()) {+ warning ("Path is closed.");+ }+ // link points at the other end first = points.first ().data; handle = path.points.first ().data.right_handle;@@ -110,14 +110,8 @@ public class PenTool : Tool { }); key_press_action.connect ((self, keyval) => {- Glyph g = MainWindow.get_current_glyph ();- if (keyval == Key.DEL) {- foreach (EditPoint p in selected_points) {- g.delete_edit_point (p);- }- - g.update_view ();+ delete_selected_points (); } if (is_arrow_key (keyval)) {@@ -138,6 +132,17 @@ public class PenTool : Tool { }); } + void delete_selected_points () {+ Glyph g = MainWindow.get_current_glyph ();+ + foreach (EditPoint p in selected_points) {+ g.delete_edit_point (p);+ }+ + g.update_view ();+ }++ public static void close_all_paths () { Glyph g = MainWindow.get_current_glyph (); foreach (Path p in g.path_list) {@@ -454,7 +459,7 @@ public class PenTool : Tool { glyph = MainWindow.get_current_glyph (); active = (!) active_edit_point; - return_if_fail (is_null (glyph));+ return_if_fail (!is_null (glyph)); px = Glyph.reverse_path_coordinate_x (active.x); py = Glyph.reverse_path_coordinate_y (active.y);@@ -1175,12 +1180,9 @@ public class PenTool : Tool { pen_tool.test_select_action (); - pen_tool.test_click_action (1, 0, 0); // open path- - pen_tool.test_click_action (1, a.x, a.y);- pen_tool.test_click_action (1, b.x, b.y);- pen_tool.test_click_action (1, c.x, c.y);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, a.x, a.y);+ pen_tool.test_click_action (3, b.x, b.y);+ pen_tool.test_click_action (3, c.x, c.y); test_reverse_last (@"Triangle reverse \"$name\" ($(a.x), $(a.y)), ($(b.x), $(b.y)), ($(c.x), $(c.y)) failed."); @@ -1217,60 +1219,61 @@ public class PenTool : Tool { // draw clockwise and check direction y_offset += 160;- pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset);- pen_tool.test_click_action (1, 17 + x_offset, 17 + y_offset);- pen_tool.test_click_action (1, 20 + x_offset, 0 + y_offset);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10 + x_offset, 20 + y_offset);+ pen_tool.test_click_action (3, 17 + x_offset, 17 + y_offset);+ pen_tool.test_click_action (3, 20 + x_offset, 0 + y_offset);+ pen_tool.test_click_action (2, 0, 0); test_last_is_clockwise ("Clockwise triangle 1.2"); // draw paths clockwise / counter clockwise and reverse them - pen_tool.test_click_action (1, 115, 137);- pen_tool.test_click_action (1, 89, 74);- pen_tool.test_click_action (1, 188, 232);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 115, 137);+ pen_tool.test_click_action (3, 89, 74);+ pen_tool.test_click_action (3, 188, 232);+ pen_tool.test_click_action (2, 0, 0); test_reverse_last ("Triangle 0"); // draw incomplete paths y_offset += 20;- pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10 + x_offset, 20 + y_offset); test_reverse_last ("Point");+ pen_tool.test_click_action (2, 0, 0); y_offset += 20;- pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset);- pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10 + x_offset, 20 + y_offset);+ pen_tool.test_click_action (3, 10 + x_offset, 20 + y_offset); test_reverse_last ("Double point");-+ pen_tool.test_click_action (2, 0, 0);+ y_offset += 20;- pen_tool.test_click_action (1, 10 + x_offset, 30 + y_offset);- pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10 + x_offset, 30 + y_offset);+ pen_tool.test_click_action (3, 10 + x_offset, 20 + y_offset); test_reverse_last ("Vertical line");-+ pen_tool.test_click_action (2, 0, 0);+ y_offset += 20; pen_tool.test_click_action (1, 30 + x_offset, 20 + y_offset); pen_tool.test_click_action (1, 10 + x_offset, 20 + y_offset); pen_tool.test_click_action (3, 0, 0); test_reverse_last ("Horisontal line");-+ pen_tool.test_click_action (2, 0, 0);+ // triangle 1 y_offset += 20;- pen_tool.test_click_action (1, 10 + x_offset, -10 + y_offset);- pen_tool.test_click_action (1, 20 + x_offset, 20 + y_offset);- pen_tool.test_click_action (1, 30 + x_offset, 0 + y_offset);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10 + x_offset, -10 + y_offset);+ pen_tool.test_click_action (3, 20 + x_offset, 20 + y_offset);+ pen_tool.test_click_action (3, 30 + x_offset, 0 + y_offset); test_reverse_last ("Triangle reverse 1");-+ pen_tool.test_click_action (2, 0, 0);+ // box y_offset += 20;- pen_tool.test_click_action (1, 100 + x_offset, 150 + y_offset);- pen_tool.test_click_action (1, 150 + x_offset, 150 + y_offset);- pen_tool.test_click_action (1, 150 + x_offset, 100 + y_offset);- pen_tool.test_click_action (1, 100 + x_offset, 100 + y_offset); - pen_tool.test_click_action (3, 0, 0); // close+ pen_tool.test_click_action (3, 100 + x_offset, 150 + y_offset);+ pen_tool.test_click_action (3, 150 + x_offset, 150 + y_offset);+ pen_tool.test_click_action (3, 150 + x_offset, 100 + y_offset);+ pen_tool.test_click_action (3, 100 + x_offset, 100 + y_offset); test_reverse_last ("Box 1");+ pen_tool.test_click_action (2, 0, 0); return true; }@@ -1283,25 +1286,23 @@ public class PenTool : Tool { public bool test_delete_points () { PenTool pen;- Tool delete_tool = MainWindow.get_toolbox ().get_tool ("erase_tool");- + test_open_next_glyph (); pen = (PenTool) select_pen ();- pen.test_click_action (1, 0, 0); // open path // draw a line with ten points for (int i = 1; i <= 10; i++) {- pen.test_click_action (1, 20*i, 20);+ pen.test_click_action (3, 20*i, 20); } // TODO: it would be nice to test if points were created here // delete points- delete_tool.test_select_action (); for (int i = 1; i <= 10; i++) { pen.move (20*i, 20); pen.test_click_action (1, 20*i, 20);+ pen.delete_selected_points (); } return true;@@ -1329,19 +1330,20 @@ public class PenTool : Tool { by = Random.int_range (0, 300); cy = Random.int_range (0, 300); - pen.test_click_action (1, ax, ay);- pen.test_click_action (1, bx, by);- pen.test_click_action (1, cx, cy);- pen.test_click_action (3, 0, 0);- + pen.test_click_action (3, ax, ay);+ pen.test_click_action (3, bx, by);+ pen.test_click_action (3, cx, cy);+ pen.test_click_action (2, 0, 0);+ r = test_reverse_last (@"Random triangle № $(i + 1) ($ax, $ay), ($bx, $by), ($cx, $cy)"); if (!r) { test_open_next_glyph (); pen = select_pen (); - pen.test_click_action (1, ax, ay);- pen.test_click_action (1, bx, by);- pen.test_click_action (1, cx, cy);+ pen.test_click_action (3, ax, ay);+ pen.test_click_action (3, bx, by);+ pen.test_click_action (3, cx, cy);+ pen.test_click_action (2, 0, 0); return false; }@@ -106,16 +106,28 @@ class TestCases { inkscape:connector-curvature="0" /> </svg>"""; try {- File temp_file = Supplement.get_settings_directory ().get_child ("inkscape_test.svg");- FileIOStream? ios = temp_file.create_readwrite (FileCreateFlags.PRIVATE);- FileOutputStream? os = ((!) ios).output_stream as FileOutputStream?;- DataOutputStream d = new DataOutputStream ((!) os);+ File temp_file;+ FileIOStream? ios;+ DataOutputStream d;+ FileOutputStream? os;+ + temp_file = Supplement.get_settings_directory ().get_child ("inkscape_test.svg");+ + if (temp_file.query_exists ()) {+ temp_file.delete ();+ }+ + ios = temp_file.create_readwrite (FileCreateFlags.PRIVATE);+ os = ((!) ios).output_stream as FileOutputStream?;+ d = new DataOutputStream ((!) os); d.put_string (inkscape_data); d.close (); Tool.test_open_next_glyph (); ImportSvg.import_svg ((!) temp_file.get_path ());++ temp_file.delete (); } catch (GLib.Error e) { warning (e.message); }@@ -247,12 +259,14 @@ class TestCases { g = MainWindow.get_current_glyph (); - pen_tool.test_click_action (1, 10, 10);- pen_tool.test_click_action (1, 10, 10);- pen_tool.test_click_action (1, 100, 10);- pen_tool.test_click_action (1, 100, 100);- pen_tool.test_click_action (1, 10, 100);- pen_tool.test_click_action (3, 0, 0);+ pen_tool.test_click_action (3, 10, 10);+ pen_tool.test_click_action (3, 10, 10);+ pen_tool.test_click_action (3, 100, 10);+ pen_tool.test_click_action (3, 100, 100);+ pen_tool.test_click_action (3, 10, 100);+ pen_tool.test_click_action (2, 0, 0);++ g.close_path (); warn_if_fail (g.active_paths.length () == 0); @@ -169,7 +169,7 @@ class TestSupplement : GLib.Object { public void print_result () { stdout.printf ("\n"); - stdout.printf ("Testcase results:\n"); + stdout.printf ("Test case results:\n"); foreach (var t in skipped) { stdout.printf ("%s", t.name); @@ -200,7 +200,8 @@ class TestSupplement : GLib.Object { /** Run tests in main loop. */ public void run_all_tests () { - var idle = new TimeoutSource (20); + TimeoutSource idle = new TimeoutSource (20); + MenuTab.new_file (); idle.set_callback(() => { int s = AtomicInt.get (ref state); @@ -291,7 +291,6 @@ public class Tool : GLib.Object { } public static void test_open_next_glyph () {- Tool.yield (); OverView o = MainWindow.get_overview (); MainWindow.get_tab_bar ().select_overview ();@@ -162,6 +162,11 @@ public class Toolbox : GLib.Object { MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview (); GlyphRange gr = new GlyphRange ();+ + if (!Supplement.get_current_font ().initialised) {+ MenuTab.new_file ();+ }+ gr.use_full_unicode_range (); o.set_glyph_range (gr); MainWindow.get_tab_bar ().select_tab_name ("Overview");@@ -173,6 +178,11 @@ public class Toolbox : GLib.Object { MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview (); GlyphRange gr = new GlyphRange ();++ if (!Supplement.get_current_font ().initialised) {+ MenuTab.new_file ();+ }+ gr.use_default_range (); o.set_glyph_range (gr); MainWindow.get_tab_bar ().select_tab_name ("Overview");@@ -183,6 +193,11 @@ public class Toolbox : GLib.Object { avalilable_characters.select_action.connect ((self) => { MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview ();+ + if (!Supplement.get_current_font ().initialised) {+ MenuTab.new_file ();+ }+ o.display_all_available_glyphs (); MainWindow.get_tab_bar ().select_tab_name ("Overview"); });