1 /*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <map>
18 #include <utility>
19 #include <vector>
20
21 #define LOG_TAG "VtsHalHapticGeneratorTargetTest"
22 #include <android-base/logging.h>
23 #include <android/binder_enums.h>
24
25 #include "EffectHelper.h"
26
27 using namespace android;
28
29 using aidl::android::hardware::audio::effect::Descriptor;
30 using aidl::android::hardware::audio::effect::getEffectTypeUuidHapticGenerator;
31 using aidl::android::hardware::audio::effect::HapticGenerator;
32 using aidl::android::hardware::audio::effect::IEffect;
33 using aidl::android::hardware::audio::effect::IFactory;
34 using aidl::android::hardware::audio::effect::Parameter;
35 using android::hardware::audio::common::testing::detail::TestExecutionTracer;
36
37 /**
38 * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
39 * VtsAudioEffectTargetTest.
40 */
41 enum ParamName {
42 PARAM_INSTANCE_NAME,
43 PARAM_HAPTIC_SCALE_ID,
44 PARAM_HAPTIC_SCALE_VIBRATOR_SCALE,
45 PARAM_VIBRATION_INFORMATION_RESONANT_FREQUENCY,
46 PARAM_VIBRATION_INFORMATION_Q_FACTOR,
47 PARAM_VIBRATION_INFORMATION_MAX_AMPLITUDE,
48 };
49 using HapticGeneratorParamTestParam =
50 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int,
51 HapticGenerator::VibratorScale, float, float, float>;
52
53 /*
54 * Testing parameter range, assuming the parameter supported by effect is in this range.
55 * Parameter should be within the valid range defined in the documentation,
56 * for any supported value test expects EX_NONE from IEffect.setParameter(),
57 * otherwise expect EX_ILLEGAL_ARGUMENT.
58 */
59
60 // TODO : Update the test values once range/capability is updated by implementation
61 const int MIN_ID = std::numeric_limits<int>::min();
62 const int MAX_ID = std::numeric_limits<int>::max();
63 const float MIN_FLOAT = std::numeric_limits<float>::min();
64 const float MAX_FLOAT = std::numeric_limits<float>::max();
65
66 const std::vector<int> kHapticScaleIdValues = {MIN_ID, 0, MAX_ID};
67 const std::vector<HapticGenerator::VibratorScale> kVibratorScaleValues = {
68 ndk::enum_range<HapticGenerator::VibratorScale>().begin(),
69 ndk::enum_range<HapticGenerator::VibratorScale>().end()};
70
71 const std::vector<float> kResonantFrequencyValues = {MIN_FLOAT, 100, MAX_FLOAT};
72 const std::vector<float> kQFactorValues = {MIN_FLOAT, 100, MAX_FLOAT};
73 const std::vector<float> kMaxAmplitude = {MIN_FLOAT, 100, MAX_FLOAT};
74
75 class HapticGeneratorParamTest : public ::testing::TestWithParam<HapticGeneratorParamTestParam>,
76 public EffectHelper {
77 public:
HapticGeneratorParamTest()78 HapticGeneratorParamTest()
79 : mParamHapticScaleId(std::get<PARAM_HAPTIC_SCALE_ID>(GetParam())),
80 mParamVibratorScale(std::get<PARAM_HAPTIC_SCALE_VIBRATOR_SCALE>(GetParam())),
81 mParamResonantFrequency(
82 std::get<PARAM_VIBRATION_INFORMATION_RESONANT_FREQUENCY>(GetParam())),
83 mParamQFactor(std::get<PARAM_VIBRATION_INFORMATION_Q_FACTOR>(GetParam())),
84 mParamMaxAmplitude(std::get<PARAM_VIBRATION_INFORMATION_MAX_AMPLITUDE>(GetParam())) {
85 std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
86 }
SetUp()87 void SetUp() override {
88 ASSERT_NE(nullptr, mFactory);
89 ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
90
91 Parameter::Common common = createParamCommon(
92 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
93 kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
94 IEffect::OpenEffectReturn ret;
95 ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt, &ret, EX_NONE));
96 ASSERT_NE(nullptr, mEffect);
97 }
98
TearDown()99 void TearDown() override {
100 ASSERT_NO_FATAL_FAILURE(close(mEffect));
101 ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
102 }
103
104 static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
105 std::shared_ptr<IFactory> mFactory;
106 std::shared_ptr<IEffect> mEffect;
107 Descriptor mDescriptor;
108 int mParamHapticScaleId = 0;
109 HapticGenerator::VibratorScale mParamVibratorScale = HapticGenerator::VibratorScale::MUTE;
110 float mParamResonantFrequency = 0;
111 float mParamQFactor = 0;
112 float mParamMaxAmplitude = 0;
113
SetAndGetHapticGeneratorParameters()114 void SetAndGetHapticGeneratorParameters() {
115 for (auto& it : mTags) {
116 auto& tag = std::get<ParamTestEnum::PARAM_TEST_TAG>(it);
117 auto& setHg = std::get<ParamTestEnum::PARAM_TEST_TARGET>(it);
118
119 // set parameter
120 Parameter expectParam;
121 Parameter::Specific specific;
122 specific.set<Parameter::Specific::hapticGenerator>(setHg);
123 expectParam.set<Parameter::specific>(specific);
124 EXPECT_STATUS(EX_NONE, mEffect->setParameter(expectParam)) << expectParam.toString();
125
126 // get parameter
127 Parameter getParam;
128 Parameter::Id id;
129 HapticGenerator::Id hgId;
130 hgId.set<HapticGenerator::Id::commonTag>(tag);
131 id.set<Parameter::Id::hapticGeneratorTag>(hgId);
132 EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
133 EXPECT_EQ(expectParam, getParam) << expectParam.toString() << "\n"
134 << getParam.toString();
135 }
136 }
137
addHapticScaleParam(int id,HapticGenerator::VibratorScale scale)138 void addHapticScaleParam(int id, HapticGenerator::VibratorScale scale) {
139 HapticGenerator setHg;
140 std::vector<HapticGenerator::HapticScale> hapticScales = {{.id = id, .scale = scale}};
141 setHg.set<HapticGenerator::hapticScales>(hapticScales);
142 mTags.push_back({HapticGenerator::hapticScales, setHg});
143 }
144
addVibratorInformationParam(float resonantFrequencyHz,float qFactor,float maxAmplitude)145 void addVibratorInformationParam(float resonantFrequencyHz, float qFactor, float maxAmplitude) {
146 HapticGenerator hg;
147 HapticGenerator::VibratorInformation vibrationInfo = {
148 .resonantFrequencyHz = resonantFrequencyHz,
149 .qFactor = qFactor,
150 .maxAmplitude = maxAmplitude};
151 hg.set<HapticGenerator::vibratorInfo>(vibrationInfo);
152 mTags.push_back({HapticGenerator::vibratorInfo, hg});
153 }
154
155 private:
156 enum ParamTestEnum { PARAM_TEST_TAG, PARAM_TEST_TARGET };
157 std::vector<std::tuple<HapticGenerator::Tag, HapticGenerator>> mTags;
158
CleanUp()159 void CleanUp() { mTags.clear(); }
160 };
161
TEST_P(HapticGeneratorParamTest,SetAndGetHapticScale)162 TEST_P(HapticGeneratorParamTest, SetAndGetHapticScale) {
163 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam(mParamHapticScaleId, mParamVibratorScale));
164 SetAndGetHapticGeneratorParameters();
165 }
166
TEST_P(HapticGeneratorParamTest,SetAndGetMultipleHapticScales)167 TEST_P(HapticGeneratorParamTest, SetAndGetMultipleHapticScales) {
168 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam(mParamHapticScaleId, mParamVibratorScale));
169 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam(mParamHapticScaleId, mParamVibratorScale));
170 SetAndGetHapticGeneratorParameters();
171 }
172
TEST_P(HapticGeneratorParamTest,SetAndGetVibratorInformation)173 TEST_P(HapticGeneratorParamTest, SetAndGetVibratorInformation) {
174 EXPECT_NO_FATAL_FAILURE(addVibratorInformationParam(mParamResonantFrequency, mParamQFactor,
175 mParamMaxAmplitude));
176 SetAndGetHapticGeneratorParameters();
177 }
178
179 INSTANTIATE_TEST_SUITE_P(
180 HapticGeneratorValidTest, HapticGeneratorParamTest,
181 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
182 IFactory::descriptor, getEffectTypeUuidHapticGenerator())),
183 testing::ValuesIn(kHapticScaleIdValues),
184 testing::ValuesIn(kVibratorScaleValues),
185 testing::ValuesIn(kResonantFrequencyValues),
186 testing::ValuesIn(kQFactorValues), testing::ValuesIn(kMaxAmplitude)),
__anoncee4f6030102(const testing::TestParamInfo<HapticGeneratorParamTest::ParamType>& info) 187 [](const testing::TestParamInfo<HapticGeneratorParamTest::ParamType>& info) {
188 auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
189 std::string hapticScaleID = std::to_string(std::get<PARAM_HAPTIC_SCALE_ID>(info.param));
190 std::string hapticScaleVibScale = std::to_string(
191 static_cast<int>(std::get<PARAM_HAPTIC_SCALE_VIBRATOR_SCALE>(info.param)));
192 std::string resonantFrequency = std::to_string(
193 std::get<PARAM_VIBRATION_INFORMATION_RESONANT_FREQUENCY>(info.param));
194 std::string qFactor =
195 std::to_string(std::get<PARAM_VIBRATION_INFORMATION_Q_FACTOR>(info.param));
196 std::string maxAmplitude =
197 std::to_string(std::get<PARAM_VIBRATION_INFORMATION_MAX_AMPLITUDE>(info.param));
198 std::string name = getPrefix(descriptor) + "_hapticScaleId" + hapticScaleID +
199 "_hapticScaleVibScale" + hapticScaleVibScale + "_resonantFrequency" +
200 resonantFrequency + "_qFactor" + qFactor + "_maxAmplitude" +
201 maxAmplitude;
202 std::replace_if(
203 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
204 return name;
205 });
206
207 INSTANTIATE_TEST_SUITE_P(
208 HapticGeneratorInvalidTest, HapticGeneratorParamTest,
209 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
210 IFactory::descriptor, getEffectTypeUuidHapticGenerator())),
211 testing::Values(MIN_ID),
212 testing::Values(HapticGenerator::VibratorScale::NONE),
213 testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT),
214 testing::Values(MIN_FLOAT)),
__anoncee4f6030302(const testing::TestParamInfo<HapticGeneratorParamTest::ParamType>& info) 215 [](const testing::TestParamInfo<HapticGeneratorParamTest::ParamType>& info) {
216 auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
217 std::string hapticScaleID = std::to_string(std::get<PARAM_HAPTIC_SCALE_ID>(info.param));
218 std::string hapticScaleVibScale = std::to_string(
219 static_cast<int>(std::get<PARAM_HAPTIC_SCALE_VIBRATOR_SCALE>(info.param)));
220 std::string resonantFrequency = std::to_string(
221 std::get<PARAM_VIBRATION_INFORMATION_RESONANT_FREQUENCY>(info.param));
222 std::string qFactor =
223 std::to_string(std::get<PARAM_VIBRATION_INFORMATION_Q_FACTOR>(info.param));
224 std::string maxAmplitude =
225 std::to_string(std::get<PARAM_VIBRATION_INFORMATION_MAX_AMPLITUDE>(info.param));
226 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
227 descriptor.common.name + "_UUID_" +
228 toString(descriptor.common.id.uuid) + "_hapticScaleId" +
229 hapticScaleID + "_hapticScaleVibScale" + hapticScaleVibScale +
230 "_resonantFrequency" + resonantFrequency + "_qFactor" + qFactor +
231 "_maxAmplitude" + maxAmplitude;
232 std::replace_if(
233 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
234 return name;
235 });
236 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HapticGeneratorParamTest);
237
238 // Test HapticScale[] hapticScales parameter
239 using HapticGeneratorScalesTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>>;
240 class HapticGeneratorScalesTest : public ::testing::TestWithParam<HapticGeneratorScalesTestParam>,
241 public EffectHelper {
242 public:
HapticGeneratorScalesTest()243 HapticGeneratorScalesTest() {
244 std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
245 }
246
SetUp()247 void SetUp() override {
248 ASSERT_NE(nullptr, mFactory);
249 ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
250
251 Parameter::Common common = createParamCommon(
252 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
253 kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
254 IEffect::OpenEffectReturn ret;
255 ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt, &ret, EX_NONE));
256 ASSERT_NE(nullptr, mEffect);
257 }
258
TearDown()259 void TearDown() override {
260 ASSERT_NO_FATAL_FAILURE(close(mEffect));
261 ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
262 CleanUp();
263 }
264
265 static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
266 std::shared_ptr<IFactory> mFactory;
267 std::shared_ptr<IEffect> mEffect;
268 Descriptor mDescriptor;
269
addHapticScaleParam(std::vector<HapticGenerator::HapticScale> scales)270 void addHapticScaleParam(std::vector<HapticGenerator::HapticScale> scales) {
271 mHapticScales.push_back(HapticGenerator::make<HapticGenerator::hapticScales>(scales));
272 for (const auto& scale : scales) {
273 expectMap.insert_or_assign(scale.id, scale.scale);
274 }
275 }
276
SetHapticScaleParameters()277 void SetHapticScaleParameters() {
278 // std::unordered_set<HapticGenerator::HapticScale> target;
279 for (auto& it : mHapticScales) {
280 Parameter::Specific specific =
281 Parameter::Specific::make<Parameter::Specific::hapticGenerator>(it);
282 Parameter param = Parameter::make<Parameter::specific>(specific);
283 EXPECT_STATUS(EX_NONE, mEffect->setParameter(param)) << param.toString();
284 }
285 }
286
checkHapticScaleParameter()287 void checkHapticScaleParameter() {
288 // get parameter
289 Parameter targetParam;
290 HapticGenerator::Id hgId = HapticGenerator::Id::make<HapticGenerator::Id::commonTag>(
291 HapticGenerator::hapticScales);
292 Parameter::Id id = Parameter::Id::make<Parameter::Id::hapticGeneratorTag>(hgId);
293 EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &targetParam));
294 ASSERT_EQ(Parameter::specific, targetParam.getTag());
295 Parameter::Specific specific = targetParam.get<Parameter::specific>();
296 ASSERT_EQ(Parameter::Specific::hapticGenerator, specific.getTag());
297 HapticGenerator hg = specific.get<Parameter::Specific::hapticGenerator>();
298 ASSERT_EQ(HapticGenerator::hapticScales, hg.getTag());
299 std::vector<HapticGenerator::HapticScale> scales = hg.get<HapticGenerator::hapticScales>();
300 ASSERT_EQ(scales.size(), expectMap.size());
301 for (const auto& scale : scales) {
302 auto itor = expectMap.find(scale.id);
303 ASSERT_NE(expectMap.end(), itor);
304 ASSERT_EQ(scale.scale, itor->second);
305 expectMap.erase(scale.id);
306 }
307 ASSERT_EQ(0ul, expectMap.size());
308 }
309
310 const static HapticGenerator::HapticScale kHapticScaleWithMinId;
311 const static HapticGenerator::HapticScale kHapticScaleWithMinIdNew;
312 const static HapticGenerator::HapticScale kHapticScale;
313 const static HapticGenerator::HapticScale kHapticScaleNew;
314 const static HapticGenerator::HapticScale kHapticScaleWithMaxId;
315 const static HapticGenerator::HapticScale kHapticScaleWithMaxIdNew;
316
317 std::vector<HapticGenerator> mHapticScales;
318
CleanUp()319 void CleanUp() {
320 mHapticScales.clear();
321 expectMap.clear();
322 }
323
324 private:
325 std::map<int /* trackID */, HapticGenerator::VibratorScale> expectMap;
326 };
327
328 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScaleWithMinId = {
329 .id = MIN_ID, .scale = HapticGenerator::VibratorScale::MUTE};
330 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScaleWithMinIdNew = {
331 .id = MIN_ID, .scale = HapticGenerator::VibratorScale::VERY_LOW};
332 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScale = {
333 .id = 1, .scale = HapticGenerator::VibratorScale::LOW};
334 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScaleNew = {
335 .id = 1, .scale = HapticGenerator::VibratorScale::NONE};
336 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScaleWithMaxId = {
337 .id = MAX_ID, .scale = HapticGenerator::VibratorScale::VERY_HIGH};
338 const HapticGenerator::HapticScale HapticGeneratorScalesTest::kHapticScaleWithMaxIdNew = {
339 .id = MAX_ID, .scale = HapticGenerator::VibratorScale::MUTE};
340
TEST_P(HapticGeneratorScalesTest,SetAndUpdateOne)341 TEST_P(HapticGeneratorScalesTest, SetAndUpdateOne) {
342 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScale}));
343 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
344 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleNew}));
345 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
346
347 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMinId}));
348 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
349 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMinIdNew}));
350 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
351
352 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMaxId}));
353 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
354 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMaxIdNew}));
355 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
356
357 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
358 }
359
TEST_P(HapticGeneratorScalesTest,SetAndUpdateVector)360 TEST_P(HapticGeneratorScalesTest, SetAndUpdateVector) {
361 EXPECT_NO_FATAL_FAILURE(
362 addHapticScaleParam({kHapticScale, kHapticScaleWithMaxId, kHapticScaleWithMinId}));
363 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
364 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam(
365 {kHapticScaleNew, kHapticScaleWithMaxIdNew, kHapticScaleWithMinIdNew}));
366 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
367
368 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
369 }
370
TEST_P(HapticGeneratorScalesTest,SetAndUpdateMultipleVector)371 TEST_P(HapticGeneratorScalesTest, SetAndUpdateMultipleVector) {
372 EXPECT_NO_FATAL_FAILURE(
373 addHapticScaleParam({kHapticScale, kHapticScaleWithMaxId, kHapticScaleWithMinId}));
374 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
375 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam(
376 {kHapticScaleNew, kHapticScaleWithMaxIdNew, kHapticScaleWithMinIdNew}));
377 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
378 EXPECT_NO_FATAL_FAILURE(
379 addHapticScaleParam({kHapticScale, kHapticScaleWithMaxId, kHapticScaleWithMinId}));
380 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
381
382 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
383 }
384
TEST_P(HapticGeneratorScalesTest,SetOneAndAddMoreVector)385 TEST_P(HapticGeneratorScalesTest, SetOneAndAddMoreVector) {
386 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScale}));
387 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
388 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMaxId, kHapticScaleWithMinId}));
389 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
390
391 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
392 }
393
TEST_P(HapticGeneratorScalesTest,SetMultipleAndAddOneVector)394 TEST_P(HapticGeneratorScalesTest, SetMultipleAndAddOneVector) {
395 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScaleWithMaxId, kHapticScaleWithMinId}));
396 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
397 EXPECT_NO_FATAL_FAILURE(addHapticScaleParam({kHapticScale}));
398 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
399
400 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
401 }
402
TEST_P(HapticGeneratorScalesTest,SetMultipleVectorRepeat)403 TEST_P(HapticGeneratorScalesTest, SetMultipleVectorRepeat) {
404 EXPECT_NO_FATAL_FAILURE(
405 addHapticScaleParam({kHapticScaleWithMaxId, kHapticScale, kHapticScaleWithMinId}));
406 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
407 EXPECT_NO_FATAL_FAILURE(
408 addHapticScaleParam({kHapticScaleWithMaxId, kHapticScale, kHapticScaleWithMinId}));
409 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
410 EXPECT_NO_FATAL_FAILURE(
411 addHapticScaleParam({kHapticScaleWithMaxId, kHapticScale, kHapticScaleWithMinId}));
412 EXPECT_NO_FATAL_FAILURE(SetHapticScaleParameters());
413
414 EXPECT_NO_FATAL_FAILURE(checkHapticScaleParameter());
415 }
416
417 INSTANTIATE_TEST_SUITE_P(
418 HapticGeneratorScalesTest, HapticGeneratorScalesTest,
419 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
420 IFactory::descriptor, getEffectTypeUuidHapticGenerator()))),
__anoncee4f6030502(const testing::TestParamInfo<HapticGeneratorScalesTest::ParamType>& info) 421 [](const testing::TestParamInfo<HapticGeneratorScalesTest::ParamType>& info) {
422 auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
423 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
424 descriptor.common.name + "_UUID_" +
425 toString(descriptor.common.id.uuid);
426 std::replace_if(
427 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
428 return name;
429 });
430 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HapticGeneratorScalesTest);
431
main(int argc,char ** argv)432 int main(int argc, char** argv) {
433 ::testing::InitGoogleTest(&argc, argv);
434 ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
435 ABinderProcess_setThreadPoolMaxThreadCount(1);
436 ABinderProcess_startThreadPool();
437 return RUN_ALL_TESTS();
438 }
439