YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
testDefalutOrNotUsedParam.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <linux/v4l2-controls.h>
21
22#include <chrono>
23#include <thread>
24
25#include "../Statistics.h"
26#include "../UltraPythonCameraHelper.h"
27#include "CApiMock.h"
28#include "common.h"
29#include "gmock/gmock.h"
30#include "gtest/gtest.h"
31
32using namespace std::chrono_literals;
33using namespace testing;
34
35TEST(UltraPython, notusedparams_ok)
36{
37 // given
39 UltraPythonCameraHelper helper(interface);
40
41 // when
42 bool force = helper.getForceFormatProperty();
43 bool crop = helper.getCropEnabledProperty();
44 bool honor = helper.getHonorFps();
45 double step = helper.getStepPeriod();
46
47 // then
48 EXPECT_FALSE(crop);
49 EXPECT_TRUE(force);
50 EXPECT_FALSE(honor);
51 EXPECT_EQ(40, step);
52
53 delete interface;
54}
55
56TEST(UltraPython, hasControls_ok)
57{
58 // given
60 UltraPythonCameraHelper helper(interface);
61
62 // when
63 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_BRIGHTNESS));
64 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_CONTRAST));
65 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_SHUTTER));
66 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_EXPOSURE));
67 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_GAIN));
68 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_RED_GAIN));
69 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_BLUE_GAIN));
70 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_GREEN_GAIN));
71 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_GAIN_ABSOLUTE));
72 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_EXPOSURE_ABSOLUTE));
73 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_BRIGHTNESS_ABSOLUTE));
74 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_CONTRAST_ABSOLUTE));
75 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_FPS));
76 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_HONOR_FPS));
77 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_SUBSAMPLING));
78 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_RED_GAIN_ABSOLUTE));
79 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_BLUE_GAIN_ABSOLUTE));
80 EXPECT_TRUE(FeatureHelper::exists(YARP_FEATURE_GREEN_GAIN_ABSOLUTE));
81
82 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_BRIGHTNESS));
83 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_CONTRAST));
84 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_SHUTTER));
85 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_EXPOSURE));
86 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_GAIN));
87 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_RED_GAIN));
88 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_BLUE_GAIN));
89 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_GREEN_GAIN));
90 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_GAIN_ABSOLUTE));
91 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_EXPOSURE_ABSOLUTE));
92 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_BRIGHTNESS_ABSOLUTE));
93 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_CONTRAST_ABSOLUTE));
94 EXPECT_FALSE(FeatureHelper::existsForWrite(YARP_FEATURE_FPS));
95 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_HONOR_FPS));
96 EXPECT_FALSE(FeatureHelper::existsForWrite(YARP_FEATURE_SUBSAMPLING));
97 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_RED_GAIN_ABSOLUTE));
98 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_BLUE_GAIN_ABSOLUTE));
99 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_GREEN_GAIN_ABSOLUTE));
100
101 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_BRIGHTNESS));
102 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_CONTRAST));
103 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_SHUTTER));
104 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_EXPOSURE));
105 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_GAIN));
106 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_RED_GAIN));
107 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_BLUE_GAIN));
108 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_GREEN_GAIN));
109 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_GAIN_ABSOLUTE));
110 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_EXPOSURE_ABSOLUTE));
111 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_BRIGHTNESS_ABSOLUTE));
112 EXPECT_TRUE(FeatureHelper::existsForWrite(YARP_FEATURE_CONTRAST_ABSOLUTE));
113 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_FPS));
114 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_HONOR_FPS));
115 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_SUBSAMPLING));
116 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_RED_GAIN_ABSOLUTE));
117 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_BLUE_GAIN_ABSOLUTE));
118 EXPECT_TRUE(FeatureHelper::existsForRead(YARP_FEATURE_GREEN_GAIN_ABSOLUTE));
119
120 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_BRIGHTNESS));
121 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_CONTRAST));
122 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_SHUTTER));
123 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_EXPOSURE));
124 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_GAIN));
125 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_RED_GAIN));
126 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_BLUE_GAIN));
127 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_GREEN_GAIN));
128 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_GAIN_ABSOLUTE));
129 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_EXPOSURE_ABSOLUTE));
130 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_BRIGHTNESS_ABSOLUTE));
131 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_CONTRAST_ABSOLUTE));
132 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_FPS));
133 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_HONOR_FPS));
134 EXPECT_FALSE(FeatureHelper::isAbsolute(YARP_FEATURE_SUBSAMPLING));
135 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_RED_GAIN_ABSOLUTE));
136 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_BLUE_GAIN_ABSOLUTE));
137 EXPECT_TRUE(FeatureHelper::isAbsolute(YARP_FEATURE_GREEN_GAIN_ABSOLUTE));
138
139 delete interface;
140}
@ YARP_FEATURE_BRIGHTNESS
@ YARP_FEATURE_EXPOSURE
@ YARP_FEATURE_SHUTTER
@ YARP_FEATURE_GAIN
TEST(UltraPython, notusedparams_ok)