Go to the documentation of this file.00001
00002
00003
00005
00007 #pragma once
00008 #ifndef LIBREALSENSE_UNITTESTS_LIVE_DS_COMMON_H
00009 #define LIBREALSENSE_UNITTESTS_LIVE_DS_COMMON_H
00010
00011 #include "catch/catch.hpp"
00012
00013 #include "unit-tests-common.h"
00014
00015 #include <algorithm>
00016 #include <iostream>
00017 #include <limits>
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef WIN32
00027 #define NOEXCEPT_FALSE
00028 #else
00029 #define NOEXCEPT_FALSE noexcept(false)
00030 #endif
00031
00032 #include "unit-tests-common.h"
00033
00034
00035 static const std::vector<std::string> ds_names = { "Intel RealSense R200" ,"Intel RealSense LR200", "Intel RealSense ZR300" };
00036 enum { Intel_R200, Intel_LR200, Intel_ZR300};
00037
00038 enum { BEFORE_START_DEVICE = 1, AFTER_START_DEVICE = 2 };
00039
00040 inline void test_ds_device_option(rs_option option, std::initializer_list<int> values, std::initializer_list<int> bad_values, int when)
00041 {
00042 safe_context ctx;
00043 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00044
00045 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00046 REQUIRE(dev != nullptr);
00047 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00048
00049 if (when & BEFORE_START_DEVICE)
00050 {
00051 test_option(dev, option, values, bad_values);
00052 }
00053
00054 if (when & AFTER_START_DEVICE)
00055 {
00056 rs_enable_stream_preset(dev, RS_STREAM_DEPTH, RS_PRESET_BEST_QUALITY, require_no_error());
00057 rs_start_device(dev, require_no_error());
00058
00059
00060
00061 std::this_thread::sleep_for(std::chrono::seconds(1));
00062 test_option(dev, option, values, bad_values);
00063 }
00064 }
00065
00066
00067 inline void test_ds_device_streaming(std::initializer_list<stream_mode> modes)
00068 {
00069 safe_context ctx;
00070 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00071
00072 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00073 REQUIRE(dev != nullptr);
00074 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00075
00076 test_streaming(dev, modes);
00077 }
00078
00079
00080 #endif