Browse Source

New freeze.t test

Alessandro Ranellucci 11 years ago
parent
commit
f26f084064
3 changed files with 38 additions and 2 deletions
  1. 1 0
      MANIFEST
  2. 8 2
      lib/Slic3r/Test.pm
  3. 29 0
      t/freeze.t

+ 1 - 0
MANIFEST

@@ -71,6 +71,7 @@ t/cooling.t
 t/custom_gcode.t
 t/dynamic.t
 t/fill.t
+t/freeze.t
 t/gcode.t
 t/geometry.t
 t/layers.t

+ 8 - 2
lib/Slic3r/Test.pm

@@ -57,9 +57,15 @@ sub model {
         ],
     }
     
+    my $mesh = Slic3r::TriangleMesh->new(
+        vertices    => $vertices,
+        facets      => $facets,
+    );
+    $mesh->scale($params{scale}) if $params{scale};
+    
     my $model = Slic3r::Model->new;
-    my $object = $model->add_object(vertices => $vertices);
-    $object->add_volume(facets => $facets);
+    my $object = $model->add_object(vertices => $mesh->vertices);
+    $object->add_volume(facets => $mesh->facets);
     $object->add_instance(
         offset      => [0,0],
         rotation    => $params{rotation} // 0,

+ 29 - 0
t/freeze.t

@@ -0,0 +1,29 @@
+use Test::More tests => 1;
+use strict;
+use warnings;
+
+BEGIN {
+    use FindBin;
+    use lib "$FindBin::Bin/../lib";
+}
+
+use Slic3r;
+use Slic3r::Test;
+use Storable qw(nstore retrieve);
+use Time::HiRes qw(gettimeofday tv_interval);
+
+{
+    my $t0 = [gettimeofday];
+    my $print = Slic3r::Test::init_print('20mm_cube', scale => 2);
+    my $gcode = Slic3r::Test::gcode($print);
+    diag sprintf 'Slicing took %s seconds', tv_interval($t0);
+    
+    my $t1 = [gettimeofday];
+    nstore $print, 'print.dat';
+    $print = retrieve 'print.dat';
+    diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1);
+    
+    isa_ok $print, 'Slic3r::Print', 'restored Print object';
+}
+
+__END__