Hi,

please find attached some updated unit tests for the fixes

-- 
Peter Marschall
[email protected]
From 866d9b1f8807b43dc7cc9b2b1002d12cb791d146 Mon Sep 17 00:00:00 2001
From: Peter Marschall <[email protected]>
Date: Sun, 18 Apr 2021 14:06:34 +0200
Subject: [PATCH 3/3] t/7_Canvas.t: make tests for rotation work again

Do tests for rotation of bbox's texts before deletion of the bboxes.

Simplify rotation cheks by using 'get_simple_transform()' method that
corresponds to the 'set_simple_transformation()' method used for scaling
and rotating, and call it on the correct object to provide meaningful
results.

Signed-off-by: Peter Marschall <[email protected]>
---
 t/7_Canvas.t | 46 +++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/t/7_Canvas.t b/t/7_Canvas.t
index 9cc6b206..43e9893c 100644
--- a/t/7_Canvas.t
+++ b/t/7_Canvas.t
@@ -1,7 +1,7 @@
 use warnings;
 use strict;
 use IPC::System::Simple qw(system);
-use Test::More tests => 37;
+use Test::More tests => 36;
 use Glib 1.220 qw(TRUE FALSE);    # To get TRUE and FALSE
 use Gscan2pdf::Page;
 use Gtk3 -init;
@@ -324,6 +324,30 @@ is( $canvas->hocr, $expected, 'updated hocr with extended hOCR properties' );
 
 #########################
 
+$group = $canvas->get_root_item;
+# get page 'page_1'
+$group = $group->get_child(0);
+# get column/carea 'block_1'
+$group = $group->get_child(1);
+# get line 'line_1_2'
+$group = $group->get_child(2);
+# get word 'word_1_3'
+$bbox  = $group->get_child(1);
+
+isa_ok($bbox, 'Gscan2pdf::Canvas::Bbox');
+is($bbox->{textangle}, 0, "word_1_3's textangle is 0");
+is($bbox->{transformation}->[0], 90, "word_1_3's (inherited) rotation is 90");
+
+my $textwidget   = $bbox->get_text_widget;
+
+isa_ok($textwidget, 'GooCanvas2::CanvasText');
+
+my @transform = $textwidget->get_simple_transform();
+
+is($transform[-1], 270, "word_1_3's text widget rotation matches the 90° rotation");
+
+#########################
+
 $bbox = $canvas->get_first_bbox;
 $bbox->delete_box;
 $bbox = $canvas->get_next_bbox;
@@ -336,26 +360,6 @@ is $canvas->get_last_bbox, undef, 'get_last_bbox() returns undef if no boxes';
 
 #########################
 
-SKIP: {
-    skip 'GooCanvas2::Canvas::get_transform() returns undef', 6;
-    $group = $canvas->get_root_item;
-    $group = $group->get_child(0);
-    $group = $group->get_child(1);
-    $group = $group->get_child(1);
-    $group = $group->get_child(2);
-    $bbox  = $group->get_child(1);
-    my $matrix = $bbox->get_transform;
-
-    is( $matrix->x0, -103.251044000815, 'rotated text x0' );
-    is( $matrix->y0, -42.1731768180892, 'rotated text y0' );
-    is( $matrix->xx, 2.86820126298635,  'rotated text xx' );
-    is( $matrix->xy, 0,                 'rotated text xy' );
-    is( $matrix->yx, 0,                 'rotated text yx' );
-    is( $matrix->yy, 2.86820126298635,  'rotated text yy' );
-}
-
-#########################
-
 $page = Gscan2pdf::Page->new(
     filename   => 'test.pnm',
     format     => 'Portable anymap',
-- 
2.30.2

Reply via email to