Bug 8375: (follow-up) final adjustment to t/Creators.t
authorGalen Charlton <gmc@esilibrary.com>
Wed, 7 May 2014 01:00:34 +0000 (01:00 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 7 May 2014 01:00:34 +0000 (01:00 +0000)
This patch adjusts the test so that it can pass successfully
without a valid context (in which case C4::Creators::PDF defaults
to the built-in fonts) or with one (in which case it uses the
TrueType fonts).

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

t/Creators.t

index 899ff33..646aef5 100755 (executable)
@@ -34,11 +34,21 @@ $pdf_creator->FontSize(); # Reset font size before testing text width etc below
 
 ok($pdf_creator->Page(), "testing Page() works");
 
-is($pdf_creator->StrWidth("test", "H", 12), '23.044921875', "testing StrWidth() returns correct point width");
+my $expected_width;
+my $expected_offset;
+if (C4::Context->config('ttf')) {
+    $expected_width  = '23.044921875';
+    $expected_offset = '33.044921875';
+} else {
+    $expected_width  = '19.344';
+    $expected_offset = '29.344';
+}
+
+is($pdf_creator->StrWidth("test", "H", 12), $expected_width, "testing StrWidth() returns correct point width");
 
 @result = $pdf_creator->Text(10, 10, "test");
 is($result[0], '10', "testing Text() writes from a given x-value");
-is($result[1], '33.044921875', "testing Text() writes to the correct x-value");
+is($result[1], $expected_offset, "testing Text() writes to the correct x-value");
 
 open(my $fh, '>', 'test.pdf');
 select $fh;