mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-05 10:20:39 +08:00
Implementing tests for PresetChooser, covering basic construction of the object and load().
This commit is contained in:
parent
18fd2b7dc2
commit
cfcf569a5e
153
src/test/GUI/test_preset_chooser.cpp
Normal file
153
src/test/GUI/test_preset_chooser.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
#include <catch.hpp>
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/uiaction.h"
|
||||
#endif // WX_PRECOMP
|
||||
#include <iostream>
|
||||
#include "testableframe.h"
|
||||
|
||||
|
||||
#include "Print.hpp"
|
||||
|
||||
#include "Preset.hpp"
|
||||
#include "Plater/PresetChooser.hpp"
|
||||
#include "Config.hpp"
|
||||
#include <test_options.hpp>
|
||||
|
||||
using namespace Slic3r::GUI;
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
|
||||
std::array<Presets, preset_types> defaults() {
|
||||
std::array<Presets, preset_types> default_presets;
|
||||
default_presets[get_preset(preset_t::Print)].push_back(Preset(true, "- default -", preset_t::Print));
|
||||
default_presets[get_preset(preset_t::Material)].push_back(Preset(true, "- default -", preset_t::Material));
|
||||
default_presets[get_preset(preset_t::Printer)].push_back(Preset(true, "- default -", preset_t::Printer));
|
||||
return default_presets;
|
||||
}
|
||||
|
||||
std::array<Presets, preset_types> sample() {
|
||||
std::array<Presets, preset_types> preset_list;
|
||||
preset_list[get_preset(preset_t::Print)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "print-profile.ini", preset_t::Print));
|
||||
preset_list[get_preset(preset_t::Print)].push_back(Preset(true, "- default -", preset_t::Print));
|
||||
|
||||
preset_list[get_preset(preset_t::Material)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "material-profile.ini", preset_t::Material));
|
||||
preset_list[get_preset(preset_t::Material)].push_back(Preset(true, "- default -", preset_t::Material));
|
||||
|
||||
preset_list[get_preset(preset_t::Printer)].push_back(Preset(true, "- default -", preset_t::Printer));
|
||||
preset_list[get_preset(preset_t::Printer)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "printer-profile.ini", preset_t::Printer));
|
||||
|
||||
return preset_list;
|
||||
}
|
||||
|
||||
std::array<Presets, preset_types> sample_compatible() {
|
||||
std::array<Presets, preset_types> preset_list;
|
||||
preset_list[get_preset(preset_t::Print)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "print-profile.ini", preset_t::Print));
|
||||
preset_list[get_preset(preset_t::Print)].push_back(Preset(true, "- default -", preset_t::Print));
|
||||
|
||||
preset_list[get_preset(preset_t::Material)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "material-profile.ini", preset_t::Material));
|
||||
preset_list[get_preset(preset_t::Material)][0].config().lock()->get_ptr<ConfigOptionStrings>("compatible_printers"s)->append("not-printer-profile"s);
|
||||
preset_list[get_preset(preset_t::Material)].push_back(Preset(true, "- default -", preset_t::Material));
|
||||
|
||||
preset_list[get_preset(preset_t::Printer)].push_back(Preset(true, "- default -", preset_t::Printer));
|
||||
preset_list[get_preset(preset_t::Printer)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "printer-profile.ini", preset_t::Printer));
|
||||
preset_list[get_preset(preset_t::Printer)].push_back(Preset(testfile_dir + "test_preset_chooser"s, "printer-profile-2.ini", preset_t::Printer));
|
||||
|
||||
return preset_list;
|
||||
}
|
||||
|
||||
SCENARIO( "PresetChooser Preset loading" ) {
|
||||
Print fake_print;
|
||||
Settings default_settings;
|
||||
wxUIActionSimulator sim;
|
||||
wxTestableFrame* old = dynamic_cast<wxTestableFrame*>(wxTheApp->GetTopWindow());
|
||||
old->Destroy();
|
||||
wxTheApp->SetTopWindow(new wxTestableFrame());
|
||||
|
||||
GIVEN( "A PresetChooser object." ) {
|
||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, default_settings);
|
||||
WHEN( "load() is called with only default presets" ) {
|
||||
cut.load(defaults());
|
||||
THEN( "Number of preset choosers created is 3" ) {
|
||||
REQUIRE(cut.preset_choosers.size() == 3);
|
||||
}
|
||||
THEN( "Each profile chooser has 1 entry" ) {
|
||||
for (auto chooser_list : cut.preset_choosers) {
|
||||
REQUIRE(chooser_list.size() == 1);
|
||||
for (auto* chooser : chooser_list) {
|
||||
REQUIRE(chooser->GetCount() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
THEN( "Selection mapping table has 3 profile entries, all named \"- default - \"") {
|
||||
for (const auto& group : { preset_t::Print, preset_t::Material, preset_t::Printer }) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(group)].at(0) == wxString("- default -"));
|
||||
}
|
||||
}
|
||||
}
|
||||
WHEN( "load is called with non-default presets and default presets" ) {
|
||||
cut.load(sample());
|
||||
THEN( "Number of preset choosers created is 3" ) {
|
||||
REQUIRE(cut.preset_choosers.size() == 3);
|
||||
}
|
||||
THEN( "Each profile chooser has 1 entry" ) {
|
||||
for (auto chooser_list : cut.preset_choosers) {
|
||||
REQUIRE(chooser_list.size() == 1);
|
||||
for (auto* chooser : chooser_list) {
|
||||
REQUIRE(chooser->GetCount() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
THEN( "Selection mapping table has 3 profile entries, none named \"- default - \"") {
|
||||
for (const auto& group : { preset_t::Print, preset_t::Material, preset_t::Printer }) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(group)].at(0) != wxString("- default -"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GIVEN( "A PresetChooser object and a Settings indicating that print-profile is the default option." ) {
|
||||
Settings test_settings;
|
||||
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, test_settings);
|
||||
WHEN( "load is called with non-default presets and default presets and the material is listed with an incompatible printer" ) {
|
||||
cut.load(sample_compatible());
|
||||
THEN( "Number of preset choosers created is 3" ) {
|
||||
REQUIRE(cut.preset_choosers.size() == 3);
|
||||
}
|
||||
THEN( "Print profile chooser has 1 entry" ) {
|
||||
for (auto* chooser : cut.preset_choosers[get_preset(preset_t::Print)]) {
|
||||
REQUIRE(chooser->GetCount() == 1);
|
||||
}
|
||||
}
|
||||
THEN( "Printer profile chooser has 2 entries" ) {
|
||||
for (auto* chooser : cut.preset_choosers[get_preset(preset_t::Printer)]) {
|
||||
REQUIRE(chooser->GetCount() == 2);
|
||||
}
|
||||
}
|
||||
THEN( "Material profile chooser has one entry" ) {
|
||||
for (auto* chooser : cut.preset_choosers[get_preset(preset_t::Material)]) {
|
||||
REQUIRE(chooser->GetCount() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
THEN( "Selected printer profile entry is \"printer-profile\"" ) {
|
||||
for (auto* chooser : cut.preset_choosers[get_preset(preset_t::Printer)]) {
|
||||
REQUIRE(chooser->GetString(chooser->GetSelection()) == wxString("printer-profile"));
|
||||
}
|
||||
}
|
||||
THEN( "Print profile entry has one entry named \"print-profile\"" ) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(preset_t::Print)].at(0) == wxString("print-profile"));
|
||||
}
|
||||
THEN( "Printer profile entry has an entry named \"printer-profile\"" ) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(preset_t::Printer)].at(0) == wxString("printer-profile"));
|
||||
}
|
||||
THEN( "Printer profile entry has an entry named \"printer-profile\"" ) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(preset_t::Printer)].at(1) == wxString("printer-profile-2"));
|
||||
}
|
||||
THEN( "Material profile entry has one entry named \"- default -\"" ) {
|
||||
REQUIRE(cut._chooser_names()[get_preset(preset_t::Material)].at(0) == wxString("- default -"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/test/inputs/test_preset_chooser/material-profile.ini
Normal file
25
src/test/inputs/test_preset_chooser/material-profile.ini
Normal file
@ -0,0 +1,25 @@
|
||||
# generated by Slic3r 1.3.0-dev on 2018-03-23 03:49:17
|
||||
bed_temperature = 70
|
||||
bridge_fan_speed = 100
|
||||
compatible_printers =
|
||||
cooling = 1
|
||||
disable_fan_first_layers = 4
|
||||
end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n"
|
||||
extrusion_multiplier = 1
|
||||
fan_always_on = 1
|
||||
fan_below_layer_time = 10
|
||||
filament_colour = #4EFF00
|
||||
filament_cost = 30
|
||||
filament_density = 1.25
|
||||
filament_diameter = 1.73
|
||||
filament_max_volumetric_speed = 0
|
||||
filament_notes = ""
|
||||
filament_settings_id =
|
||||
first_layer_bed_temperature = 70
|
||||
first_layer_temperature = 220
|
||||
max_fan_speed = 100
|
||||
min_fan_speed = 100
|
||||
min_print_speed = 10
|
||||
slowdown_below_layer_time = 60
|
||||
start_filament_gcode = "; Filament gcode\n; ATOMIC PLA"
|
||||
temperature = 218
|
98
src/test/inputs/test_preset_chooser/print-profile.ini
Normal file
98
src/test/inputs/test_preset_chooser/print-profile.ini
Normal file
@ -0,0 +1,98 @@
|
||||
# generated by Slic3r 1.3.0-dev on 2017-10-30 20:38:52
|
||||
adaptive_slicing = 0
|
||||
adaptive_slicing_quality = 75%
|
||||
avoid_crossing_perimeters = 0
|
||||
bottom_infill_pattern = rectilinear
|
||||
bottom_solid_layers = 2
|
||||
bridge_acceleration = 5000
|
||||
bridge_flow_ratio = 1
|
||||
bridge_speed = 60
|
||||
brim_connections_width = 0
|
||||
brim_width = 0
|
||||
compatible_printers =
|
||||
complete_objects = 0
|
||||
default_acceleration = 5000
|
||||
dont_support_bridges = 1
|
||||
external_perimeter_extrusion_width = 0.8
|
||||
external_perimeter_speed = 50%
|
||||
external_perimeters_first = 0
|
||||
extra_perimeters = 1
|
||||
extruder_clearance_height = 20
|
||||
extruder_clearance_radius = 20
|
||||
extrusion_width = 0
|
||||
fill_angle = 45
|
||||
fill_density = 0%
|
||||
fill_gaps = 1
|
||||
fill_pattern = honeycomb
|
||||
first_layer_acceleration = 5000
|
||||
first_layer_extrusion_width = 200%
|
||||
first_layer_height = 0.3
|
||||
first_layer_speed = 30
|
||||
gap_fill_speed = 20
|
||||
gcode_comments = 0
|
||||
infill_acceleration = 5000
|
||||
infill_every_layers = 1
|
||||
infill_extruder = 1
|
||||
infill_extrusion_width = 0
|
||||
infill_first = 0
|
||||
infill_only_where_needed = 0
|
||||
infill_overlap = 15%
|
||||
infill_speed = 80
|
||||
interface_shells = 0
|
||||
interior_brim_width = 0
|
||||
layer_height = 0.2
|
||||
match_horizontal_surfaces = 0
|
||||
max_print_speed = 80
|
||||
max_volumetric_speed = 0
|
||||
min_skirt_length = 5
|
||||
notes =
|
||||
only_retract_when_crossing_perimeters = 1
|
||||
ooze_prevention = 0
|
||||
output_filename_format = [input_filename_base].gcode
|
||||
overhangs = 1
|
||||
perimeter_acceleration = 450
|
||||
perimeter_extruder = 1
|
||||
perimeter_extrusion_width = 0.8
|
||||
perimeter_speed = 60
|
||||
perimeters = 2
|
||||
post_process =
|
||||
print_settings_id =
|
||||
raft_layers = 0
|
||||
regions_overlap = 0
|
||||
resolution = 0
|
||||
seam_position = aligned
|
||||
shortcuts = support_material
|
||||
skirt_distance = 2
|
||||
skirt_height = 1
|
||||
skirts = 1
|
||||
small_perimeter_speed = 15
|
||||
solid_infill_below_area = 70
|
||||
solid_infill_every_layers = 0
|
||||
solid_infill_extruder = 1
|
||||
solid_infill_extrusion_width = 0
|
||||
solid_infill_speed = 20
|
||||
spiral_vase = 0
|
||||
standby_temperature_delta = -5
|
||||
support_material = 0
|
||||
support_material_angle = 0
|
||||
support_material_buildplate_only = 0
|
||||
support_material_contact_distance = 0.2
|
||||
support_material_enforce_layers = 0
|
||||
support_material_extruder = 1
|
||||
support_material_extrusion_width = 0
|
||||
support_material_interface_extruder = 1
|
||||
support_material_interface_extrusion_width = 0
|
||||
support_material_interface_layers = 3
|
||||
support_material_interface_spacing = 0
|
||||
support_material_interface_speed = 100%
|
||||
support_material_pattern = rectilinear-grid
|
||||
support_material_spacing = 1
|
||||
support_material_speed = 60
|
||||
support_material_threshold = 60%
|
||||
thin_walls = 1
|
||||
top_infill_extrusion_width = 0
|
||||
top_infill_pattern = archimedeanchords
|
||||
top_solid_infill_speed = 15
|
||||
top_solid_layers = 0
|
||||
travel_speed = 130
|
||||
xy_size_compensation = 0
|
37
src/test/inputs/test_preset_chooser/printer-profile-2.ini
Normal file
37
src/test/inputs/test_preset_chooser/printer-profile-2.ini
Normal file
@ -0,0 +1,37 @@
|
||||
# generated by Slic3r 1.3.0-dev on 2017-06-25 14:39:57
|
||||
bed_shape = 79.5618x8.36228,78.2518x16.6329,76.0845x24.7214,73.0836x32.5389,69.282x40,64.7214x47.0228,59.4516x53.5304,53.5304x59.4516,47.0228x64.7214,40x69.282,32.5389x73.0836,24.7214x76.0845,16.6329x78.2518,8.36228x79.5618,0x80,-8.36228x79.5618,-16.6329x78.2518,-24.7214x76.0845,-32.5389x73.0836,-40x69.282,-47.0228x64.7214,-53.5304x59.4516,-59.4516x53.5304,-64.7214x47.0228,-69.282x40,-73.0836x32.5389,-76.0845x24.7214,-78.2518x16.6329,-79.5618x8.36228,-80x0,-79.5618x-8.36228,-78.2518x-16.6329,-76.0845x-24.7214,-73.0836x-32.5389,-69.282x-40,-64.7214x-47.0228,-59.4516x-53.5304,-53.5304x-59.4516,-47.0228x-64.7214,-40x-69.282,-32.5389x-73.0836,-24.7214x-76.0845,-16.6329x-78.2518,-8.36228x-79.5618,0x-80,8.36228x-79.5618,16.6329x-78.2518,24.7214x-76.0845,32.5389x-73.0836,40x-69.282,47.0228x-64.7214,53.5304x-59.4516,59.4516x-53.5304,64.7214x-47.0228,69.282x-40,73.0836x-32.5389,76.0845x-24.7214,78.2518x-16.6329,79.5618x-8.36228,80x0
|
||||
before_layer_gcode =
|
||||
between_objects_gcode =
|
||||
end_gcode = M104 S0 ; turn off temperature\nM140 S0;\nG28 ;home all axis\nM84; disable motors\n
|
||||
extruder_offset = 0x0
|
||||
gcode_flavor = smoothie
|
||||
has_heatbed = 1
|
||||
host_type = octoprint
|
||||
layer_gcode =
|
||||
nozzle_diameter = 0.35
|
||||
octoprint_apikey =
|
||||
pressure_advance = 0
|
||||
print_host =
|
||||
printer_notes =
|
||||
printer_settings_id =
|
||||
retract_before_travel = 1
|
||||
retract_layer_change = 1
|
||||
retract_length = 2
|
||||
retract_length_toolchange = 10
|
||||
retract_lift = 0
|
||||
retract_lift_above = 0
|
||||
retract_lift_below = 0
|
||||
retract_restart_extra = 0
|
||||
retract_restart_extra_toolchange = 0
|
||||
retract_speed = 40
|
||||
serial_port =
|
||||
serial_speed = 250000
|
||||
start_gcode = M106 S0\nG90; set to absolute position\nG28\nM190 S60; preheat bed\nM104 S100; preheat nozzle.\nM190 S[first_layer_bed_temperature]; Wait until heatbed hits [first_layer_bed_temperature] \nG0 X0 Y0 Z0\nM109 S[first_layer_temperature]; heat nozzle to [first_layer_temperature]C;
|
||||
toolchange_gcode =
|
||||
use_firmware_retraction = 1
|
||||
use_relative_e_distances = 0
|
||||
use_volumetric_e = 1
|
||||
vibration_limit = 0
|
||||
wipe = 0
|
||||
z_offset = 0
|
||||
z_steps_per_mm = 0
|
37
src/test/inputs/test_preset_chooser/printer-profile.ini
Normal file
37
src/test/inputs/test_preset_chooser/printer-profile.ini
Normal file
@ -0,0 +1,37 @@
|
||||
# generated by Slic3r 1.3.0-dev on 2017-06-25 14:39:57
|
||||
bed_shape = 79.5618x8.36228,78.2518x16.6329,76.0845x24.7214,73.0836x32.5389,69.282x40,64.7214x47.0228,59.4516x53.5304,53.5304x59.4516,47.0228x64.7214,40x69.282,32.5389x73.0836,24.7214x76.0845,16.6329x78.2518,8.36228x79.5618,0x80,-8.36228x79.5618,-16.6329x78.2518,-24.7214x76.0845,-32.5389x73.0836,-40x69.282,-47.0228x64.7214,-53.5304x59.4516,-59.4516x53.5304,-64.7214x47.0228,-69.282x40,-73.0836x32.5389,-76.0845x24.7214,-78.2518x16.6329,-79.5618x8.36228,-80x0,-79.5618x-8.36228,-78.2518x-16.6329,-76.0845x-24.7214,-73.0836x-32.5389,-69.282x-40,-64.7214x-47.0228,-59.4516x-53.5304,-53.5304x-59.4516,-47.0228x-64.7214,-40x-69.282,-32.5389x-73.0836,-24.7214x-76.0845,-16.6329x-78.2518,-8.36228x-79.5618,0x-80,8.36228x-79.5618,16.6329x-78.2518,24.7214x-76.0845,32.5389x-73.0836,40x-69.282,47.0228x-64.7214,53.5304x-59.4516,59.4516x-53.5304,64.7214x-47.0228,69.282x-40,73.0836x-32.5389,76.0845x-24.7214,78.2518x-16.6329,79.5618x-8.36228,80x0
|
||||
before_layer_gcode =
|
||||
between_objects_gcode =
|
||||
end_gcode = M104 S0 ; turn off temperature\nM140 S0;\nG28 ;home all axis\nM84; disable motors\n
|
||||
extruder_offset = 0x0
|
||||
gcode_flavor = smoothie
|
||||
has_heatbed = 1
|
||||
host_type = octoprint
|
||||
layer_gcode =
|
||||
nozzle_diameter = 0.35
|
||||
octoprint_apikey =
|
||||
pressure_advance = 0
|
||||
print_host =
|
||||
printer_notes =
|
||||
printer_settings_id =
|
||||
retract_before_travel = 1
|
||||
retract_layer_change = 1
|
||||
retract_length = 2
|
||||
retract_length_toolchange = 10
|
||||
retract_lift = 0
|
||||
retract_lift_above = 0
|
||||
retract_lift_below = 0
|
||||
retract_restart_extra = 0
|
||||
retract_restart_extra_toolchange = 0
|
||||
retract_speed = 40
|
||||
serial_port =
|
||||
serial_speed = 250000
|
||||
start_gcode = M106 S0\nG90; set to absolute position\nG28\nM190 S60; preheat bed\nM104 S100; preheat nozzle.\nM190 S[first_layer_bed_temperature]; Wait until heatbed hits [first_layer_bed_temperature] \nG0 X0 Y0 Z0\nM109 S[first_layer_temperature]; heat nozzle to [first_layer_temperature]C;
|
||||
toolchange_gcode =
|
||||
use_firmware_retraction = 1
|
||||
use_relative_e_distances = 0
|
||||
use_volumetric_e = 1
|
||||
vibration_limit = 0
|
||||
wipe = 0
|
||||
z_offset = 0
|
||||
z_steps_per_mm = 0
|
Loading…
x
Reference in New Issue
Block a user