diff --git a/t/gcode.t b/t/gcode.t index ef2209a802..243acb24b9 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 23; +use Test::More tests => 25; use strict; use warnings; @@ -215,4 +215,47 @@ use Slic3r::Test; ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops'; } +{ + # Test verifies that if has_heatbed is false, M190/M140 gcodes are not + # generated by default even if a bed temperature is set. + my $config = Slic3r::Config->new_from_defaults; + $config->set('has_heatbed', 0); + $config->set('first_layer_bed_temperature', 100); + $config->set('bed_temperature', 60); + + my $had_gcode = 0; + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if (($cmd eq 'M140' && exists $args->{S}) || + ($cmd eq 'M190' && exists $args->{S})) { + $had_gcode = 1; + } + }); + + ok !$had_gcode, 'M190/M140 codes are not generated if has_heatbed = 0'; +} + +{ + # Test verifies that if has_heatbed is true, M190/M140 gcodes are + # generated by default if a bed temperature is set. + my $config = Slic3r::Config->new_from_defaults; + $config->set('has_heatbed', 1); + $config->set('first_layer_bed_temperature', 100); + $config->set('bed_temperature', 60); + + my $had_gcode = 0; + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if (($cmd eq 'M140' && exists $args->{S}) || + ($cmd eq 'M190' && exists $args->{S})) { + $had_gcode = 1; + } + }); + + ok $had_gcode, 'M190/M140 codes are generated if has_heatbed = 1'; +} __END__