summaryrefslogtreecommitdiff
path: root/testsuite/backend
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:55 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:55 +0200
commita77bc1fcbdf83cfdac9570c0a0ac886b5534c90f (patch)
treed839746371ecb8ed64ac81d2e37c11fcd25a00ac /testsuite/backend
parent787fb1d54ec9ee5fb941ae897fb201feb9cb2fd1 (diff)
parent2b3e02411ecc09e7d41741b5587655c9b2f955b7 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'testsuite/backend')
-rw-r--r--testsuite/backend/genesys/Makefile.am2
-rw-r--r--testsuite/backend/genesys/session_config_test.cpp54
-rw-r--r--testsuite/backend/genesys/tests_calibration.cpp6
-rw-r--r--testsuite/backend/genesys/tests_image_pipeline.cpp522
-rw-r--r--testsuite/backend/genesys/tests_motor.cpp174
5 files changed, 555 insertions, 203 deletions
diff --git a/testsuite/backend/genesys/Makefile.am b/testsuite/backend/genesys/Makefile.am
index 818a523..3c0443e 100644
--- a/testsuite/backend/genesys/Makefile.am
+++ b/testsuite/backend/genesys/Makefile.am
@@ -11,7 +11,7 @@ TEST_LDADD = \
../../../lib/liblib.la \
../../../backend/libgenesys.la \
../../../backend/sane_strstatus.lo \
- $(MATH_LIB) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS)
+ $(MATH_LIB) $(TIFF_LIBS) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS)
check_PROGRAMS = genesys_unit_tests genesys_session_config_tests
TESTS = genesys_unit_tests
diff --git a/testsuite/backend/genesys/session_config_test.cpp b/testsuite/backend/genesys/session_config_test.cpp
index 72043bb..7c2ddbe 100644
--- a/testsuite/backend/genesys/session_config_test.cpp
+++ b/testsuite/backend/genesys/session_config_test.cpp
@@ -47,6 +47,7 @@ struct TestConfig
{
std::uint16_t vendor_id = 0;
std::uint16_t product_id = 0;
+ std::uint16_t bcd_device = 0;
std::string model_name;
genesys::ScanMethod method = genesys::ScanMethod::FLATBED;
genesys::ScanColorMode color_mode = genesys::ScanColorMode::COLOR_SINGLE_PASS;
@@ -143,7 +144,7 @@ public:
auto i = find_option(name, SANE_TYPE_FIXED);
int value = 0;
TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr));
- return static_cast<float>(SANE_UNFIX(value));
+ return genesys::fixed_to_float(value);
}
void set_value_float(const std::string& name, float value)
@@ -198,7 +199,19 @@ private:
};
-void build_checkpoint(const genesys::Genesys_Device& dev,
+void print_params(const SANE_Parameters& params, std::stringstream& out)
+{
+ out << "\n\n================\n"
+ << "Scan params:\n"
+ << "format: " << params.format << "\n"
+ << "last_frame: " << params.last_frame << "\n"
+ << "bytes_per_line: " << params.bytes_per_line << "\n"
+ << "pixels_per_line: " << params.pixels_per_line << "\n"
+ << "lines: " << params.lines << "\n"
+ << "depth: " << params.depth << "\n";
+}
+
+void print_checkpoint(const genesys::Genesys_Device& dev,
genesys::TestScannerInterface& iface,
const std::string& checkpoint_name,
std::stringstream& out)
@@ -239,14 +252,15 @@ void build_checkpoint(const genesys::Genesys_Device& dev,
void run_single_test_scan(const TestConfig& config, std::stringstream& out)
{
- auto build_checkpoint_wrapper = [&](const genesys::Genesys_Device& dev,
+ auto print_checkpoint_wrapper = [&](const genesys::Genesys_Device& dev,
genesys::TestScannerInterface& iface,
const std::string& checkpoint_name)
{
- build_checkpoint(dev, iface, checkpoint_name, out);
+ print_checkpoint(dev, iface, checkpoint_name, out);
};
- genesys::enable_testing_mode(config.vendor_id, config.product_id, build_checkpoint_wrapper);
+ genesys::enable_testing_mode(config.vendor_id, config.product_id, config.bcd_device,
+ print_checkpoint_wrapper);
SANE_Handle handle;
@@ -272,6 +286,8 @@ void run_single_test_scan(const TestConfig& config, std::stringstream& out)
SANE_Parameters params;
TIE(sane_get_parameters(handle, &params));
+ print_params(params, out);
+
int buffer_size = 1024 * 1024;
std::vector<std::uint8_t> buffer;
buffer.resize(buffer_size);
@@ -389,35 +405,41 @@ TestResult perform_single_test(const TestConfig& config, const std::string& chec
std::vector<TestConfig> get_all_test_configs()
{
genesys::genesys_init_usb_device_tables();
+ genesys::genesys_init_sensor_tables();
+ genesys::verify_usb_device_tables();
+ genesys::verify_sensor_tables();
std::vector<TestConfig> configs;
std::unordered_set<std::string> model_names;
for (const auto& usb_dev : *genesys::s_usb_devices) {
- if (usb_dev.model.flags & GENESYS_FLAG_UNTESTED) {
+
+ const auto& model = usb_dev.model();
+
+ if (genesys::has_flag(model.flags, genesys::ModelFlag::UNTESTED)) {
continue;
}
- if (model_names.find(usb_dev.model.name) != model_names.end()) {
+ if (model_names.find(model.name) != model_names.end()) {
continue;
}
- model_names.insert(usb_dev.model.name);
+ model_names.insert(model.name);
- for (auto scan_mode : { genesys::ScanColorMode::LINEART,
- genesys::ScanColorMode::GRAY,
+ for (auto scan_mode : { genesys::ScanColorMode::GRAY,
genesys::ScanColorMode::COLOR_SINGLE_PASS }) {
- auto depth_values = usb_dev.model.bpp_gray_values;
+ auto depth_values = model.bpp_gray_values;
if (scan_mode == genesys::ScanColorMode::COLOR_SINGLE_PASS) {
- depth_values = usb_dev.model.bpp_color_values;
+ depth_values = model.bpp_color_values;
}
for (unsigned depth : depth_values) {
- for (auto method_resolutions : usb_dev.model.resolutions) {
+ for (auto method_resolutions : model.resolutions) {
for (auto method : method_resolutions.methods) {
for (unsigned resolution : method_resolutions.get_resolutions()) {
TestConfig config;
- config.vendor_id = usb_dev.vendor;
- config.product_id = usb_dev.product;
- config.model_name = usb_dev.model.name;
+ config.vendor_id = usb_dev.vendor_id();
+ config.product_id = usb_dev.product_id();
+ config.bcd_device = usb_dev.bcd_device();
+ config.model_name = model.name;
config.method = method;
config.depth = depth;
config.resolution = resolution;
diff --git a/testsuite/backend/genesys/tests_calibration.cpp b/testsuite/backend/genesys/tests_calibration.cpp
index 559f8a8..8c9c8b5 100644
--- a/testsuite/backend/genesys/tests_calibration.cpp
+++ b/testsuite/backend/genesys/tests_calibration.cpp
@@ -66,11 +66,9 @@ Genesys_Calibration_Cache create_fake_calibration_entry()
Genesys_Sensor sensor;
sensor.sensor_id = SensorId::CCD_UMAX;
- sensor.optical_res = 1200;
+ sensor.full_resolution = 1200;
sensor.black_pixels = 48;
sensor.dummy_pixel = 64;
- sensor.ccd_start_xoffset = 0;
- sensor.sensor_pixels = 10800;
sensor.fau_gain_white_ref = 210;
sensor.gain_white_ref = 230;
sensor.exposure = { 0x0000, 0x0000, 0x0000 };
@@ -104,8 +102,6 @@ Genesys_Calibration_Cache create_fake_calibration_entry()
sensor.gamma = {1.0, 1.0, 1.0};
calib.sensor = sensor;
- calib.calib_pixels = 12345;
- calib.calib_channels = 3;
calib.average_size = 7;
calib.white_average_data = { 8, 7, 6, 5, 4, 3, 2 };
calib.dark_average_data = { 6, 5, 4, 3, 2, 18, 12 };
diff --git a/testsuite/backend/genesys/tests_image_pipeline.cpp b/testsuite/backend/genesys/tests_image_pipeline.cpp
index d4853d2..7eed9e6 100644
--- a/testsuite/backend/genesys/tests_image_pipeline.cpp
+++ b/testsuite/backend/genesys/tests_image_pipeline.cpp
@@ -32,72 +32,139 @@
namespace genesys {
-void test_image_buffer_genesys_usb()
+
+void test_image_buffer_exact_reads()
{
std::vector<std::size_t> requests;
- auto on_read_usb = [&](std::size_t x, std::uint8_t* data)
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
{
(void) data;
requests.push_back(x);
+ return true;
};
- FakeBufferModel model;
- model.push_step(453120, 1);
- model.push_step(56640, 3540);
- ImageBufferGenesysUsb buffer{1086780, model, on_read_usb};
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
std::vector<std::uint8_t> dummy;
- dummy.resize(1086780);
-
- ASSERT_TRUE(buffer.get_data(453120, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
+ dummy.resize(1000);
+
+ ASSERT_TRUE(buffer.get_data(1000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(1000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(500, dummy.data()));
std::vector<std::size_t> expected = {
- 453120, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 11008
+ 1000, 1000, 500
};
ASSERT_EQ(requests, expected);
}
-void test_image_buffer_genesys_usb_capped_remaining_bytes()
+void test_image_buffer_smaller_reads()
{
std::vector<std::size_t> requests;
- auto on_read_usb = [&](std::size_t x, std::uint8_t* data)
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
{
(void) data;
requests.push_back(x);
+ return true;
};
- FakeBufferModel model;
- model.push_step(453120, 1);
- model.push_step(56640, 3540);
- ImageBufferGenesysUsb buffer{1086780, model, on_read_usb};
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
std::vector<std::uint8_t> dummy;
- dummy.resize(1086780);
+ dummy.resize(700);
+
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(700, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 500
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_larger_reads()
+{
+ std::vector<std::size_t> requests;
- ASSERT_TRUE(buffer.get_data(453120, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ return true;
+ };
+
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(2500);
+
+ ASSERT_TRUE(buffer.get_data(2500, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 500
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_uncapped_remaining_bytes()
+{
+ std::vector<std::size_t> requests;
+ unsigned request_count = 0;
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ request_count++;
+ return request_count < 4;
+ };
+
+ ImageBuffer buffer{1000, on_read};
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(3000);
+
+ ASSERT_TRUE(buffer.get_data(3000, dummy.data()));
+ ASSERT_FALSE(buffer.get_data(3000, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 1000, 1000
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_capped_remaining_bytes()
+{
+ std::vector<std::size_t> requests;
+
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ return true;
+ };
+
+ ImageBuffer buffer{1000, on_read};
buffer.set_remaining_size(10000);
- ASSERT_FALSE(buffer.get_data(56640, dummy.data()));
+ buffer.set_last_read_multiple(16);
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(2000);
+
+ ASSERT_TRUE(buffer.get_data(2000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(2000, dummy.data()));
+ buffer.set_remaining_size(100);
+ ASSERT_FALSE(buffer.get_data(200, dummy.data()));
std::vector<std::size_t> expected = {
- // note that the sizes are rounded-up to 256 bytes
- 453120, 56576, 56576, 56576, 56832, 10240
+ // note that the sizes are rounded-up to 16 bytes
+ 1000, 1000, 1000, 1000, 112
};
ASSERT_EQ(requests, expected);
}
@@ -300,6 +367,109 @@ void test_node_swap_16bit_endian()
ASSERT_EQ(out_data, expected_data);
}
+void test_node_invert_16_bits()
+{
+ using Data16 = std::vector<std::uint16_t>;
+ using Data = std::vector<std::uint8_t>;
+
+ Data16 in_data = {
+ 0x1020, 0x3011, 0x2131,
+ 0x1222, 0x3213, 0x2333,
+ 0x1424, 0x3415, 0x2525,
+ 0x1626, 0x3617, 0x2737,
+ };
+
+ Data in_data_8bit;
+ in_data_8bit.resize(in_data.size() * 2);
+ std::memcpy(in_data_8bit.data(), in_data.data(), in_data_8bit.size());
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(4, 1, PixelFormat::RGB161616,
+ std::move(in_data_8bit));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 4u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 24u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB161616);
+
+ auto out_data_8bit = stack.get_all_data();
+ Data16 out_data;
+ out_data.resize(out_data_8bit.size() / 2);
+ std::memcpy(out_data.data(), out_data_8bit.data(), out_data_8bit.size());
+
+ Data16 expected_data = {
+ 0xefdf, 0xcfee, 0xdece,
+ 0xeddd, 0xcdec, 0xdccc,
+ 0xebdb, 0xcbea, 0xdada,
+ 0xe9d9, 0xc9e8, 0xd8c8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_invert_8_bits()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x10, 0x20, 0x30, 0x11, 0x21, 0x31,
+ 0x12, 0x22, 0x32, 0x13, 0x23, 0x33,
+ 0x14, 0x24, 0x34, 0x15, 0x25, 0x35,
+ 0x16, 0x26, 0x36, 0x17, 0x27, 0x37,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(8, 1, PixelFormat::RGB888,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 24u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0xef, 0xdf, 0xcf, 0xee, 0xde, 0xce,
+ 0xed, 0xdd, 0xcd, 0xec, 0xdc, 0xcc,
+ 0xeb, 0xdb, 0xcb, 0xea, 0xda, 0xca,
+ 0xe9, 0xd9, 0xc9, 0xe8, 0xd8, 0xc8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_invert_1_bits()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x10, 0x20, 0x30, 0x11, 0x21, 0x31,
+ 0x16, 0x26, 0x36, 0x17, 0x27, 0x37,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(32, 1, PixelFormat::RGB111,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 32u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB111);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0xef, 0xdf, 0xcf, 0xee, 0xde, 0xce,
+ 0xe9, 0xd9, 0xc9, 0xe8, 0xd8, 0xc8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
void test_node_merge_mono_lines()
{
using Data = std::vector<std::uint8_t>;
@@ -395,7 +565,7 @@ void test_node_component_shift_lines()
ASSERT_EQ(out_data, expected_data);
}
-void test_node_pixel_shift_lines()
+void test_node_pixel_shift_lines_2lines()
{
using Data = std::vector<std::uint8_t>;
@@ -426,6 +596,261 @@ void test_node_pixel_shift_lines()
ASSERT_EQ(out_data, expected_data);
}
+void test_node_pixel_shift_lines_4lines()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 9, PixelFormat::I8,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodePixelShiftLines>(std::vector<std::size_t>{0, 2, 1, 3});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 6u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x00, 0x21, 0x12, 0x33, 0x04, 0x25, 0x16, 0x37, 0x08, 0x29, 0x1a, 0x3b,
+ 0x10, 0x31, 0x22, 0x43, 0x14, 0x35, 0x26, 0x47, 0x18, 0x39, 0x2a, 0x4b,
+ 0x20, 0x41, 0x32, 0x53, 0x24, 0x45, 0x36, 0x57, 0x28, 0x49, 0x3a, 0x5b,
+ 0x30, 0x51, 0x42, 0x63, 0x34, 0x55, 0x46, 0x67, 0x38, 0x59, 0x4a, 0x6b,
+ 0x40, 0x61, 0x52, 0x73, 0x44, 0x65, 0x56, 0x77, 0x48, 0x69, 0x5a, 0x7b,
+ 0x50, 0x71, 0x62, 0x83, 0x54, 0x75, 0x66, 0x87, 0x58, 0x79, 0x6a, 0x8b,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_compute_max_width()
+{
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {1, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {1, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {1, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {2, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {2, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {2, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {2, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {2, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {3, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {3, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {3, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {3, 1, 2, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {3, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {3, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {3, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {3, 1, 2, 3}), 3u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {7, 1, 2, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {7, 1, 2, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {7, 1, 2, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {7, 1, 2, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {7, 1, 2, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {7, 1, 2, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {7, 1, 2, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {7, 1, 2, 3}), 7u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 3, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 3, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 4, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 4, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 4, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 4, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 5, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 5, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 5, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 5, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 5, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 5, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 5, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 5, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 9, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 9, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 9, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 9, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 9, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 9, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 9, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 9, 3}), 5u);
+}
+
+void test_node_pixel_shift_columns_no_switch()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{0, 1, 2, 3});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ ASSERT_EQ(out_data, in_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{3, 1, 2, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x03, 0x01, 0x02, 0x00, 0x07, 0x05, 0x06, 0x04, 0x0b, 0x09, 0x0a, 0x08,
+ 0x13, 0x11, 0x12, 0x10, 0x17, 0x15, 0x16, 0x14, 0x1b, 0x19, 0x1a, 0x18,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_not_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(13, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{3, 1, 2, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x03, 0x01, 0x02, 0x00, 0x07, 0x05, 0x06, 0x04, 0x0b, 0x09, 0x0a, 0x08,
+ 0x13, 0x11, 0x12, 0x10, 0x17, 0x15, 0x16, 0x14, 0x1b, 0x19, 0x1a, 0x18,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_large_offsets_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{7, 1, 5, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 8u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x07, 0x01, 0x05, 0x00, 0x0b, 0x05, 0x09, 0x04,
+ 0x17, 0x11, 0x15, 0x10, 0x1b, 0x15, 0x19, 0x14,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_large_offsets_not_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(13, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{7, 1, 5, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 8u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x07, 0x01, 0x05, 0x00, 0x0b, 0x05, 0x09, 0x04,
+ 0x17, 0x11, 0x15, 0x10, 0x1b, 0x15, 0x19, 0x14,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
void test_node_calibrate_8bit()
{
using Data = std::vector<std::uint8_t>;
@@ -445,7 +870,7 @@ void test_node_calibrate_8bit()
ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB888,
std::move(in_data));
- stack.push_node<ImagePipelineNodeCalibrate>(bottom, top);
+ stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u);
@@ -481,7 +906,7 @@ void test_node_calibrate_16bit()
ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB161616,
std::move(in_data));
- stack.push_node<ImagePipelineNodeCalibrate>(bottom, top);
+ stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u);
@@ -500,18 +925,31 @@ void test_node_calibrate_16bit()
void test_image_pipeline()
{
- test_image_buffer_genesys_usb();
- test_image_buffer_genesys_usb_capped_remaining_bytes();
+ test_image_buffer_exact_reads();
+ test_image_buffer_smaller_reads();
+ test_image_buffer_larger_reads();
+ test_image_buffer_uncapped_remaining_bytes();
+ test_image_buffer_capped_remaining_bytes();
test_node_buffered_callable_source();
test_node_format_convert();
test_node_desegment_1_line();
test_node_deinterleave_lines_i8();
test_node_deinterleave_lines_rgb888();
test_node_swap_16bit_endian();
+ test_node_invert_16_bits();
+ test_node_invert_8_bits();
+ test_node_invert_1_bits();
test_node_merge_mono_lines();
test_node_split_mono_lines();
test_node_component_shift_lines();
- test_node_pixel_shift_lines();
+ test_node_pixel_shift_columns_no_switch();
+ test_node_pixel_shift_columns_group_switch_pixel_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_not_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_large_offsets_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_large_offsets_not_multiple();
+ test_node_pixel_shift_lines_2lines();
+ test_node_pixel_shift_lines_4lines();
+ test_node_pixel_shift_columns_compute_max_width();
test_node_calibrate_8bit();
test_node_calibrate_16bit();
}
diff --git a/testsuite/backend/genesys/tests_motor.cpp b/testsuite/backend/genesys/tests_motor.cpp
index 07ca693..18a4d7e 100644
--- a/testsuite/backend/genesys/tests_motor.cpp
+++ b/testsuite/backend/genesys/tests_motor.cpp
@@ -31,100 +31,6 @@
namespace genesys {
-void test_create_slope_table3()
-{
- auto asic_type = AsicType::GL841;
- auto max_table_size = get_slope_table_max_size(asic_type);
-
- Genesys_Motor motor;
- motor.id = MotorId::CANON_LIDE_200;
- motor.base_ydpi = 1200;
- motor.optical_ydpi = 6400;
- motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 20));
- motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 20));
- motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 16));
-
- auto table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::FULL, 10000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 10000u);
- ASSERT_EQ(table.steps_count, 1u);
-
- std::vector<std::uint16_t> expected_steps = {
- 10000,
- };
- expected_steps.resize(max_table_size, 10000);
-
- ASSERT_EQ(table.table, expected_steps);
-
- table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::FULL, 2000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 33830u);
- ASSERT_EQ(table.steps_count, 7u);
-
- expected_steps = {
- 10000, 10000, 4099, 3028, 2511, 2192, 2000
- };
- expected_steps.resize(max_table_size, 2000);
-
- ASSERT_EQ(table.table, expected_steps);
-
- table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 10000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 5000u);
- ASSERT_EQ(table.steps_count, 1u);
-
- expected_steps = {
- 5000,
- };
- expected_steps.resize(max_table_size, 5000);
-
-
- ASSERT_EQ(table.table, expected_steps);
-
- table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 2000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 16914u);
- ASSERT_EQ(table.steps_count, 7u);
-
- expected_steps = {
- 5000, 5000, 2049, 1514, 1255, 1096, 1000
- };
- expected_steps.resize(max_table_size, 1000);
-
- ASSERT_EQ(table.table, expected_steps);
-
- table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 10000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 2500u);
- ASSERT_EQ(table.steps_count, 1u);
-
- expected_steps = {
- 2500,
- };
- expected_steps.resize(max_table_size, 2500);
-
-
- ASSERT_EQ(table.table, expected_steps);
-
- table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 2000,
- motor.base_ydpi);
-
- ASSERT_EQ(table.pixeltime_sum, 7680u);
- ASSERT_EQ(table.steps_count, 6u);
-
- expected_steps = {
- 2500, 2500, 932, 683, 565, 500
- };
- expected_steps.resize(max_table_size, 500);
-
- ASSERT_EQ(table.table, expected_steps);
-}
-
void test_create_slope_table_small_full_step()
{
unsigned max_table_size = 1024;
@@ -135,26 +41,24 @@ void test_create_slope_table_small_full_step()
slope.max_speed_w = 2632;
slope.acceleration = 1.2e-8;
- auto table = create_slope_table(slope, 5000, StepType::FULL, 4, 8, max_table_size);
+ auto table = create_slope_table_for_speed(slope, 5000, StepType::FULL, 4, 8, max_table_size);
std::vector<std::uint16_t> expected_table = {
- 62464, 62464, 6420, 5000
+ 62464, 62464, 6420, 5000, 5000, 5000, 5000, 5000
};
- expected_table.resize(max_table_size, 5000);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 8u);
- ASSERT_EQ(table.pixeltime_sum, 156348u);
+ ASSERT_EQ(table.table.size(), 8u);
+ ASSERT_EQ(table.pixeltime_sum(), 156348u);
- table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size);
+ table = create_slope_table_for_speed(slope, 3000, StepType::FULL, 4, 8, max_table_size);
expected_table = {
- 62464, 62464, 6420, 4552, 3720, 3223, 3000
+ 62464, 62464, 6420, 4552, 3720, 3223, 3000, 3000
};
- expected_table.resize(max_table_size, 3000);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 8u);
- ASSERT_EQ(table.pixeltime_sum, 148843u);
+ ASSERT_EQ(table.table.size(), 8u);
+ ASSERT_EQ(table.pixeltime_sum(), 148843u);
}
void test_create_slope_table_small_full_step_target_speed_too_high()
@@ -167,15 +71,14 @@ void test_create_slope_table_small_full_step_target_speed_too_high()
slope.max_speed_w = 2632;
slope.acceleration = 1.2e-8;
- auto table = create_slope_table(slope, 2000, StepType::FULL, 4, 8, max_table_size);
+ auto table = create_slope_table_for_speed(slope, 2000, StepType::FULL, 4, 8, max_table_size);
std::vector<std::uint16_t> expected_table = {
62464, 62464, 6420, 4552, 3720, 3223, 2883, 2632
};
- expected_table.resize(max_table_size, 2632);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 8u);
- ASSERT_EQ(table.pixeltime_sum, 148358u);
+ ASSERT_EQ(table.table.size(), 8u);
+ ASSERT_EQ(table.pixeltime_sum(), 148358u);
}
void test_create_slope_table_small_half_step()
@@ -188,26 +91,24 @@ void test_create_slope_table_small_half_step()
slope.max_speed_w = 2632;
slope.acceleration = 1.2e-8;
- auto table = create_slope_table(slope, 5000, StepType::HALF, 4, 8, max_table_size);
+ auto table = create_slope_table_for_speed(slope, 5000, StepType::HALF, 4, 8, max_table_size);
std::vector<std::uint16_t> expected_table = {
- 31232, 31232, 3210, 2500
+ 31232, 31232, 3210, 2500, 2500, 2500, 2500, 2500
};
- expected_table.resize(max_table_size, 2500);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 8u);
- ASSERT_EQ(table.pixeltime_sum, 78174u);
+ ASSERT_EQ(table.table.size(), 8u);
+ ASSERT_EQ(table.pixeltime_sum(), 78174u);
- table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size);
+ table = create_slope_table_for_speed(slope, 3000, StepType::HALF, 4, 8, max_table_size);
expected_table = {
- 31232, 31232, 3210, 2276, 1860, 1611, 1500
+ 31232, 31232, 3210, 2276, 1860, 1611, 1500, 1500
};
- expected_table.resize(max_table_size, 1500);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 8u);
- ASSERT_EQ(table.pixeltime_sum, 74421u);
+ ASSERT_EQ(table.table.size(), 8u);
+ ASSERT_EQ(table.pixeltime_sum(), 74421u);
}
void test_create_slope_table_large_full_step()
@@ -243,7 +144,7 @@ void test_create_slope_table_large_full_step()
slope.max_speed_w = 1500;
slope.acceleration = 1.013948e-9;
- auto table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size);
+ auto table = create_slope_table_for_speed(slope, 3000, StepType::FULL, 4, 8, max_table_size);
std::vector<std::uint16_t> expected_table = {
54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771,
@@ -251,15 +152,14 @@ void test_create_slope_table_large_full_step()
5072, 4945, 4826, 4716, 4613, 4517, 4426, 4341, 4260, 4184,
4111, 4043, 3977, 3915, 3855, 3799, 3744, 3692, 3642, 3594,
3548, 3503, 3461, 3419, 3379, 3341, 3304, 3268, 3233, 3199,
- 3166, 3135, 3104, 3074, 3045, 3017, 3000,
+ 3166, 3135, 3104, 3074, 3045, 3017, 3000, 3000, 3000, 3000,
};
- expected_table.resize(max_table_size, 3000);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 60u);
- ASSERT_EQ(table.pixeltime_sum, 412616u);
+ ASSERT_EQ(table.table.size(), 60u);
+ ASSERT_EQ(table.pixeltime_sum(), 412616u);
- table = create_slope_table(slope, 1500, StepType::FULL, 4, 8, max_table_size);
+ table = create_slope_table_for_speed(slope, 1500, StepType::FULL, 4, 8, max_table_size);
expected_table = {
54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771,
@@ -284,12 +184,11 @@ void test_create_slope_table_large_full_step()
1614, 1610, 1606, 1601, 1597, 1593, 1589, 1585, 1581, 1577,
1573, 1569, 1565, 1561, 1557, 1554, 1550, 1546, 1542, 1539,
1535, 1531, 1528, 1524, 1520, 1517, 1513, 1510, 1506, 1503,
- 1500,
+ 1500, 1500, 1500, 1500,
};
- expected_table.resize(max_table_size, 1500);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 224u);
- ASSERT_EQ(table.pixeltime_sum, 734910u);
+ ASSERT_EQ(table.table.size(), 224u);
+ ASSERT_EQ(table.pixeltime_sum(), 734910u);
}
void test_create_slope_table_large_half_step()
@@ -303,7 +202,7 @@ void test_create_slope_table_large_half_step()
slope.max_speed_w = 1500;
slope.acceleration = 1.013948e-9;
- auto table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size);
+ auto table = create_slope_table_for_speed(slope, 3000, StepType::HALF, 4, 8, max_table_size);
std::vector<std::uint16_t> expected_table = {
27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885,
@@ -311,15 +210,14 @@ void test_create_slope_table_large_half_step()
2536, 2472, 2413, 2358, 2306, 2258, 2213, 2170, 2130, 2092,
2055, 2021, 1988, 1957, 1927, 1899, 1872, 1846, 1821, 1797,
1774, 1751, 1730, 1709, 1689, 1670, 1652, 1634, 1616, 1599,
- 1583, 1567, 1552, 1537, 1522, 1508, 1500,
+ 1583, 1567, 1552, 1537, 1522, 1508, 1500, 1500, 1500, 1500,
};
- expected_table.resize(max_table_size, 1500);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 60u);
- ASSERT_EQ(table.pixeltime_sum, 206294u);
+ ASSERT_EQ(table.table.size(), 60u);
+ ASSERT_EQ(table.pixeltime_sum(), 206294u);
- table = create_slope_table(slope, 1500, StepType::HALF, 4, 8, max_table_size);
+ table = create_slope_table_for_speed(slope, 1500, StepType::HALF, 4, 8, max_table_size);
expected_table = {
27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885,
@@ -344,17 +242,15 @@ void test_create_slope_table_large_half_step()
807, 805, 803, 800, 798, 796, 794, 792, 790, 788,
786, 784, 782, 780, 778, 777, 775, 773, 771, 769,
767, 765, 764, 762, 760, 758, 756, 755, 753, 751,
- 750,
+ 750, 750, 750, 750,
};
- expected_table.resize(max_table_size, 750);
ASSERT_EQ(table.table, expected_table);
- ASSERT_EQ(table.steps_count, 224u);
- ASSERT_EQ(table.pixeltime_sum, 367399u);
+ ASSERT_EQ(table.table.size(), 224u);
+ ASSERT_EQ(table.pixeltime_sum(), 367399u);
}
void test_motor()
{
- test_create_slope_table3();
test_create_slope_table_small_full_step();
test_create_slope_table_small_full_step_target_speed_too_high();
test_create_slope_table_small_half_step();