mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Failing test for broken command line scaling. #1889
This commit is contained in:
		
							parent
							
								
									fc4ac5ded4
								
							
						
					
					
						commit
						e9e23119fc
					
				
					 2 changed files with 53 additions and 35 deletions
				
			
		
							
								
								
									
										86
									
								
								t/layers.t
									
										
									
									
									
								
							
							
						
						
									
										86
									
								
								t/layers.t
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
use Test::More tests => 4;
 | 
			
		||||
use Test::More tests => 5;
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -11,49 +11,67 @@ use List::Util qw(first);
 | 
			
		|||
use Slic3r;
 | 
			
		||||
use Slic3r::Test qw(_eq);
 | 
			
		||||
 | 
			
		||||
my $config = Slic3r::Config->new_from_defaults;
 | 
			
		||||
{
 | 
			
		||||
    my $config = Slic3r::Config->new_from_defaults;
 | 
			
		||||
 | 
			
		||||
my $test = sub {
 | 
			
		||||
    my ($conf) = @_;
 | 
			
		||||
    $conf ||= $config;
 | 
			
		||||
    my $test = sub {
 | 
			
		||||
        my ($conf) = @_;
 | 
			
		||||
        $conf ||= $config;
 | 
			
		||||
    
 | 
			
		||||
    my $print = Slic3r::Test::init_print('20mm_cube', config => $conf);
 | 
			
		||||
        my $print = Slic3r::Test::init_print('20mm_cube', config => $conf);
 | 
			
		||||
    
 | 
			
		||||
        my @z = ();
 | 
			
		||||
        my @increments = ();
 | 
			
		||||
        Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
 | 
			
		||||
            my ($self, $cmd, $args, $info) = @_;
 | 
			
		||||
        
 | 
			
		||||
            if ($info->{dist_Z}) {
 | 
			
		||||
                push @z, 1*$args->{Z};
 | 
			
		||||
                push @increments, $info->{dist_Z};
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    
 | 
			
		||||
        fail 'wrong first layer height'
 | 
			
		||||
            if $z[0] ne $config->get_value('first_layer_height') + $config->z_offset;
 | 
			
		||||
    
 | 
			
		||||
        fail 'wrong second layer height'
 | 
			
		||||
            if $z[1] ne $config->get_value('first_layer_height') + $config->get_value('layer_height') + $config->z_offset;
 | 
			
		||||
    
 | 
			
		||||
        fail 'wrong layer height'
 | 
			
		||||
            if first { !_eq($_, $config->layer_height) } @increments[1..$#increments];
 | 
			
		||||
    
 | 
			
		||||
        1;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    $config->set('start_gcode',             '');  # to avoid dealing with the nozzle lift in start G-code
 | 
			
		||||
    $config->set('layer_height', 0.3);
 | 
			
		||||
    $config->set('first_layer_height', 0.2);
 | 
			
		||||
    ok $test->(), "absolute first layer height";
 | 
			
		||||
 | 
			
		||||
    $config->set('first_layer_height', '60%');
 | 
			
		||||
    ok $test->(), "relative first layer height";
 | 
			
		||||
 | 
			
		||||
    $config->set('z_offset', 0.9);
 | 
			
		||||
    ok $test->(), "positive Z offset";
 | 
			
		||||
 | 
			
		||||
    $config->set('z_offset', -0.8);
 | 
			
		||||
    ok $test->(), "negative Z offset";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    my $config = Slic3r::Config->new;
 | 
			
		||||
    $config->set('fill_density', 0);  # just for making the test faster
 | 
			
		||||
    my $print = Slic3r::Test::init_print('20mm_cube', config => $config, scale => 2);
 | 
			
		||||
    
 | 
			
		||||
    my @z = ();
 | 
			
		||||
    my @increments = ();
 | 
			
		||||
    Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
 | 
			
		||||
        my ($self, $cmd, $args, $info) = @_;
 | 
			
		||||
        
 | 
			
		||||
        if ($info->{dist_Z}) {
 | 
			
		||||
            push @z, 1*$args->{Z};
 | 
			
		||||
            push @increments, $info->{dist_Z};
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    fail 'wrong first layer height'
 | 
			
		||||
        if $z[0] ne $config->get_value('first_layer_height') + $config->z_offset;
 | 
			
		||||
    
 | 
			
		||||
    fail 'wrong second layer height'
 | 
			
		||||
        if $z[1] ne $config->get_value('first_layer_height') + $config->get_value('layer_height') + $config->z_offset;
 | 
			
		||||
    
 | 
			
		||||
    fail 'wrong layer height'
 | 
			
		||||
        if first { !_eq($_, $config->layer_height) } @increments[1..$#increments];
 | 
			
		||||
    
 | 
			
		||||
    1;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$config->set('start_gcode',             '');  # to avoid dealing with the nozzle lift in start G-code
 | 
			
		||||
$config->set('layer_height', 0.3);
 | 
			
		||||
$config->set('first_layer_height', 0.2);
 | 
			
		||||
ok $test->(), "absolute first layer height";
 | 
			
		||||
 | 
			
		||||
$config->set('first_layer_height', '60%');
 | 
			
		||||
ok $test->(), "relative first layer height";
 | 
			
		||||
 | 
			
		||||
$config->set('z_offset', 0.9);
 | 
			
		||||
ok $test->(), "positive Z offset";
 | 
			
		||||
 | 
			
		||||
$config->set('z_offset', -0.8);
 | 
			
		||||
ok $test->(), "negative Z offset";
 | 
			
		||||
    ok $z[-1] > 20*1.8 && $z[-1] < 20*2.2, 'resulting G-code has reasonable height';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__END__
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue