startup/test-values.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 //#cmake: static!
5 //#test:device L500*
6 
7 #include "../../../func-common.h"
8 #include "../../presets-common.h"
9 #include <l500/l500-options.h>
10 
11 using namespace rs2;
12 
13 TEST_CASE( "check current values on start up", "[l500][live]" )
14 {
15  // This test will create for each preset value new rs2::device and destroy it
16  // in order to simulate the scenario of:
17  // 1. start up librealsense and create an object of L500 device
18  // 2. set specific preset to depth sensor
19  // 3. close librealsense
20  // 4. start up again librealsense
21  // we expect that on the second start up librealsense will calculated preset correctly from the
22  // control values
23 
25  auto dev = devices[0];
26  auto sens = dev.first< rs2::depth_sensor >();
27 
29 
30  preset_values_map expected_values, expected_defs;
31  build_presets_to_expected_values_defs_map( dev, sens, expected_values, expected_defs );
32 
34  preset++ )
35  {
36 
37  // this will create an object of L500 device set it preset and destroy it
39  REQUIRE_NOTHROW( sens.set_option( RS2_OPTION_VISUAL_PRESET, (float)preset ) );
40  } );
41 
45  CAPTURE( preset );
46 
47  auto sensor_mode_def
49 
50  compare_to_actual( sens,
51  expected_values[{ (rs2_l500_visual_preset)preset, sensor_mode_def }],
52  expected_defs[{ (rs2_l500_visual_preset)preset, sensor_mode_def }] );
53  } );
54  }
55 }
const std::string MIN_GET_DEFAULT_FW_VERSION("1.5.4.0")
void compare_to_actual(const rs2::sensor &sens, const std::map< rs2_option, float > &expected_values, const std::map< rs2_option, float > &expected_defaults)
std::map< preset_mode_pair, std::map< rs2_option, float > > preset_values_map
Definition: cah-model.h:10
#define CAPTURE(...)
Definition: catch.hpp:17432
rs2::device_list find_devices_by_product_line_or_exit(int product)
Definition: func-common.h:24
devices
Definition: test-fg.py:9
void build_new_device_and_do(std::function< void(rs2::depth_sensor &depth_sens) > action)
#define RS2_PRODUCT_LINE_L500
Definition: rs_context.h:96
rs2_sensor_mode
For setting the camera_mode option.
Definition: rs_option.h:165
REQUIRE_NOTHROW(rs2_log(RS2_LOG_SEVERITY_INFO,"Log message using rs2_log()", nullptr))
void exit_if_fw_version_is_under(rs2::device &dev, librealsense::firmware_version version)
Definition: func-common.h:38
void build_presets_to_expected_values_defs_map(rs2::device &dev, rs2::depth_sensor &depth_sens, preset_values_map &expected_values, preset_values_map &expected_defs)
option_range get_option_range(rs2_option option) const
Definition: rs_options.hpp:84
TEST_CASE("check current values on start up","[l500][live]")
void set_option(rs2_option option, float value) const
Definition: rs_options.hpp:99
rs2_l500_visual_preset
For L500 devices: provides optimized settings (presets) for specific types of usage.
Definition: rs_option.h:151


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11