blob: 491a79b5a45ad4581514c9e8590725ab890957b1 [file] [log] [blame]
Hongguang600a6ae2021-07-08 18:51:51 -07001/*
2 * Copyright 2021 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#pragma once
18
19#include <android/binder_manager.h>
Ray Chin7d03f492024-03-29 11:07:37 +080020#include <cutils/properties.h>
Hongguang600a6ae2021-07-08 18:51:51 -070021
22#include "DemuxTests.h"
23#include "DescramblerTests.h"
24#include "DvrTests.h"
25#include "FrontendTests.h"
26#include "LnbTests.h"
27
28using android::sp;
29
30namespace {
31
32bool initConfiguration() {
Ray Chin7d03f492024-03-29 11:07:37 +080033 std::array<char, PROPERTY_VALUE_MAX> variant;
34 auto res = property_get("ro.vendor.vts_tuner_configuration_variant", variant.data(), "");
35 if (res <= 0) {
36 ALOGE("[vts] failed to read system property ro.vendor.vts_tuner_configuration_variant");
37 return false;
38 }
39 string configFilePath = "/vendor/etc/tuner_vts_config_aidl_V1";
40 if (variant.size() != 0) {
41 configFilePath = configFilePath + "." + variant.data();
42 }
43 configFilePath = configFilePath + ".xml";
Hongguang600a6ae2021-07-08 18:51:51 -070044 TunerTestingConfigAidlReader1_0::setConfigFilePath(configFilePath);
45 if (!TunerTestingConfigAidlReader1_0::checkConfigFileExists()) {
46 return false;
47 }
48 initFrontendConfig();
49 initFilterConfig();
50 initDvrConfig();
Frankie Lizcano1fd52972022-06-30 16:50:21 +000051 initTimeFilterConfig();
Frankie Lizcanof5352122022-06-29 22:10:16 +000052 initDescramblerConfig();
Frankie Lizcano647d5aa2022-06-30 20:49:31 +000053 initLnbConfig();
54 initDiseqcMsgsConfig();
Hongguang600a6ae2021-07-08 18:51:51 -070055 connectHardwaresToTestCases();
56 if (!validateConnections()) {
57 ALOGW("[vts] failed to validate connections.");
58 return false;
59 }
Frankie Lizcano5b29f502022-07-06 22:09:42 +000060 determineDataFlows();
61
Hongguang600a6ae2021-07-08 18:51:51 -070062 return true;
63}
64
65static AssertionResult success() {
66 return ::testing::AssertionSuccess();
67}
68
69AssertionResult filterDataOutputTestBase(FilterTests& tests) {
70 // Data Verify Module
71 std::map<int64_t, std::shared_ptr<FilterCallback>>::iterator it;
72 std::map<int64_t, std::shared_ptr<FilterCallback>> filterCallbacks = tests.getFilterCallbacks();
73 for (it = filterCallbacks.begin(); it != filterCallbacks.end(); it++) {
74 it->second->testFilterDataOutput();
75 }
76 return success();
77}
78
Frankie Lizcano5b29f502022-07-06 22:09:42 +000079void clearIds() {
Frankie Lizcano1e283b32022-07-08 21:07:42 +000080 lnbIds.clear();
81 diseqcMsgs.clear();
82 frontendIds.clear();
Frankie Lizcano8b87f252022-07-19 21:51:54 +000083 ipFilterIds.clear();
84 pcrFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000085 recordDvrIds.clear();
Frankie Lizcano0c069532022-07-14 20:20:46 +000086 timeFilterIds.clear();
Frankie Lizcanof4e07962022-07-13 20:54:34 +000087 descramblerIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000088 audioFilterIds.clear();
89 videoFilterIds.clear();
90 playbackDvrIds.clear();
91 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000092 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000093}
94
Frankie Lizcano82101d22022-07-28 00:12:35 +000095enum class Dataflow_Context { LNBRECORD, RECORD, DESCRAMBLING, LNBDESCRAMBLING };
Frankie Lizcano9c464f72022-07-18 17:56:52 +000096
Hongguang600a6ae2021-07-08 18:51:51 -070097class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
98 public:
99 virtual void SetUp() override {
100 if (AServiceManager_isDeclared(GetParam().c_str())) {
101 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
102 mService = ITuner::fromBinder(binder);
103 } else {
104 mService = nullptr;
105 }
106 ASSERT_NE(mService, nullptr);
107 ASSERT_TRUE(initConfiguration());
108
109 mLnbTests.setService(mService);
110 }
111
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000112 virtual void TearDown() override {
113 clearIds();
114 mService = nullptr;
115 }
116
Hongguang600a6ae2021-07-08 18:51:51 -0700117 protected:
118 static void description(const std::string& description) {
119 RecordProperty("description", description);
120 }
121
122 std::shared_ptr<ITuner> mService;
123 LnbTests mLnbTests;
124};
125
126GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
127
128class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
129 public:
130 virtual void SetUp() override {
131 if (AServiceManager_isDeclared(GetParam().c_str())) {
132 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
133 mService = ITuner::fromBinder(binder);
134 } else {
135 mService = nullptr;
136 }
137 ASSERT_NE(mService, nullptr);
138 ASSERT_TRUE(initConfiguration());
139
140 mFrontendTests.setService(mService);
141 mDemuxTests.setService(mService);
142 mFilterTests.setService(mService);
143 }
144
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000145 virtual void TearDown() override {
146 clearIds();
147 mService = nullptr;
148 }
149
Hongguang600a6ae2021-07-08 18:51:51 -0700150 protected:
151 static void description(const std::string& description) {
152 RecordProperty("description", description);
153 }
154
155 std::shared_ptr<ITuner> mService;
156 FrontendTests mFrontendTests;
157 DemuxTests mDemuxTests;
158 FilterTests mFilterTests;
159};
160
161GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
162
163class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
164 public:
165 virtual void SetUp() override {
166 if (AServiceManager_isDeclared(GetParam().c_str())) {
167 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
168 mService = ITuner::fromBinder(binder);
169 } else {
170 mService = nullptr;
171 }
172 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000173 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700174
175 mFrontendTests.setService(mService);
176 mDemuxTests.setService(mService);
177 mFilterTests.setService(mService);
178 }
179
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000180 virtual void TearDown() override {
181 clearIds();
182 mService = nullptr;
183 }
184
Hongguang600a6ae2021-07-08 18:51:51 -0700185 protected:
186 static void description(const std::string& description) {
187 RecordProperty("description", description);
188 }
189
190 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
191 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
192 FrontendConfig frontendConf);
193 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100194 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700195
196 DemuxFilterType getLinkageFilterType(int bit) {
197 DemuxFilterType type;
198 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
199 switch (type.mainType) {
200 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700201 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700202 DemuxTsFilterType::UNDEFINED);
203 break;
204 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700205 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700206 DemuxMmtpFilterType::UNDEFINED);
207 break;
208 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700209 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700210 DemuxIpFilterType::UNDEFINED);
211 break;
212 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700213 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700214 DemuxTlvFilterType::UNDEFINED);
215 break;
216 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700217 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700218 DemuxAlpFilterType::UNDEFINED);
219 break;
220 default:
221 break;
222 }
223 return type;
224 }
225 std::shared_ptr<ITuner> mService;
226 FrontendTests mFrontendTests;
227 DemuxTests mDemuxTests;
228 FilterTests mFilterTests;
229};
230
231GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
232
233class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
234 public:
235 virtual void SetUp() override {
236 if (AServiceManager_isDeclared(GetParam().c_str())) {
237 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
238 mService = ITuner::fromBinder(binder);
239 } else {
240 mService = nullptr;
241 }
242 ASSERT_NE(mService, nullptr);
243 ASSERT_TRUE(initConfiguration());
244
245 mFrontendTests.setService(mService);
246 mDemuxTests.setService(mService);
247 mFilterTests.setService(mService);
248 mDvrTests.setService(mService);
249 }
250
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000251 virtual void TearDown() override {
252 clearIds();
253 mService = nullptr;
254 }
255
Hongguang600a6ae2021-07-08 18:51:51 -0700256 protected:
257 static void description(const std::string& description) {
258 RecordProperty("description", description);
259 }
260
261 std::shared_ptr<ITuner> mService;
262 FrontendTests mFrontendTests;
263 DemuxTests mDemuxTests;
264 FilterTests mFilterTests;
265 DvrTests mDvrTests;
266
267 AssertionResult filterDataOutputTest();
268
269 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
Ray Chin62ab6c92022-09-15 15:07:33 +0800270
271 void setStatusCheckIntervalHintTest(int64_t milliseconds, DvrConfig dvrConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700272};
273
274GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
275
276class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
277 public:
278 virtual void SetUp() override {
279 if (AServiceManager_isDeclared(GetParam().c_str())) {
280 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
281 mService = ITuner::fromBinder(binder);
282 } else {
283 mService = nullptr;
284 }
285 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000286 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700287
288 mFrontendTests.setService(mService);
289 mDemuxTests.setService(mService);
290 mFilterTests.setService(mService);
291 mDvrTests.setService(mService);
292 mLnbTests.setService(mService);
293 }
294
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000295 virtual void TearDown() override {
296 clearIds();
297 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000298 }
299
Hongguang600a6ae2021-07-08 18:51:51 -0700300 protected:
301 static void description(const std::string& description) {
302 RecordProperty("description", description);
303 }
304
305 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
306 DvrConfig dvrConf);
307 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
308 DvrConfig dvrConf, LnbConfig lnbConf);
309 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000310 DvrConfig dvrConf, Dataflow_Context context);
Ray Chin62ab6c92022-09-15 15:07:33 +0800311 void setStatusCheckIntervalHintTest(int64_t milliseconds, FrontendConfig frontendConf,
312 DvrConfig dvrConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700313
314 std::shared_ptr<ITuner> mService;
315 FrontendTests mFrontendTests;
316 DemuxTests mDemuxTests;
317 FilterTests mFilterTests;
318 DvrTests mDvrTests;
319 LnbTests mLnbTests;
320
321 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000322 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700323};
324
325GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
326
327class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
328 public:
329 virtual void SetUp() override {
330 if (AServiceManager_isDeclared(GetParam().c_str())) {
331 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
332 mService = ITuner::fromBinder(binder);
333 } else {
334 mService = nullptr;
335 }
336 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000337 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700338
339 mFrontendTests.setService(mService);
340 }
341
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000342 virtual void TearDown() override {
343 clearIds();
344 mService = nullptr;
345 }
346
Hongguang600a6ae2021-07-08 18:51:51 -0700347 protected:
348 static void description(const std::string& description) {
349 RecordProperty("description", description);
350 }
351
352 std::shared_ptr<ITuner> mService;
353 FrontendTests mFrontendTests;
354};
355
356GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
357
358class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
359 public:
360 virtual void SetUp() override {
361 if (AServiceManager_isDeclared(GetParam().c_str())) {
362 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
363 mService = ITuner::fromBinder(binder);
364 } else {
365 mService = nullptr;
366 }
367 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000368 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700369
370 mFrontendTests.setService(mService);
371 mDemuxTests.setService(mService);
372 mFilterTests.setService(mService);
373 mLnbTests.setService(mService);
374 mDvrTests.setService(mService);
375 }
376
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000377 virtual void TearDown() override {
378 clearIds();
379 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000380 }
381
Hongguang600a6ae2021-07-08 18:51:51 -0700382 protected:
383 static void description(const std::string& description) {
384 RecordProperty("description", description);
385 }
386
387 std::shared_ptr<ITuner> mService;
388 FrontendTests mFrontendTests;
389 DemuxTests mDemuxTests;
390 FilterTests mFilterTests;
391 LnbTests mLnbTests;
392 DvrTests mDvrTests;
393
394 AssertionResult filterDataOutputTest();
395
396 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
397 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
398 LnbConfig lnbConf);
399 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
400
401 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000402 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700403};
404
405GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
406
407class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
408 public:
409 virtual void SetUp() override {
410 if (AServiceManager_isDeclared(GetParam().c_str())) {
411 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
412 mService = ITuner::fromBinder(binder);
413 } else {
414 mService = nullptr;
415 }
Hongguang600a6ae2021-07-08 18:51:51 -0700416 ASSERT_NE(mService, nullptr);
Yixiao Luoe8730a72023-02-01 18:39:51 -0800417
418 // Get IMediaCasService. Try getting AIDL service first, if AIDL does not exist, try HIDL.
419 if (AServiceManager_isDeclared(MEDIA_CAS_AIDL_SERVICE_NAME.c_str())) {
420 ::ndk::SpAIBinder binder(
421 AServiceManager_waitForService(MEDIA_CAS_AIDL_SERVICE_NAME.c_str()));
422 mCasServiceAidl = IMediaCasServiceAidl::fromBinder(binder);
423 } else {
424 mCasServiceAidl = nullptr;
425 }
426 if (mCasServiceAidl == nullptr) {
427 mCasServiceHidl = IMediaCasServiceHidl::getService();
428 }
429 ASSERT_TRUE(mCasServiceAidl != nullptr || mCasServiceHidl != nullptr);
Hongguang600a6ae2021-07-08 18:51:51 -0700430 ASSERT_TRUE(initConfiguration());
431
432 mFrontendTests.setService(mService);
433 mDemuxTests.setService(mService);
434 mDvrTests.setService(mService);
435 mDescramblerTests.setService(mService);
Yixiao Luoe8730a72023-02-01 18:39:51 -0800436 if (mCasServiceAidl != nullptr) {
437 mDescramblerTests.setCasServiceAidl(mCasServiceAidl);
438 } else {
439 mDescramblerTests.setCasServiceHidl(mCasServiceHidl);
440 }
Frankie Lizcano82101d22022-07-28 00:12:35 +0000441 mLnbTests.setService(mService);
Hongguang600a6ae2021-07-08 18:51:51 -0700442 }
443
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000444 virtual void TearDown() override {
445 clearIds();
446 mService = nullptr;
447 }
448
Hongguang600a6ae2021-07-08 18:51:51 -0700449 protected:
450 static void description(const std::string& description) {
451 RecordProperty("description", description);
452 }
453
454 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000455 FrontendConfig frontendConf, DescramblerConfig descConfig,
456 Dataflow_Context context);
457 void scrambledBroadcastTestWithLnb(set<struct FilterConfig>& mediaFilterConfs,
458 FrontendConfig& frontendConf, DescramblerConfig& descConfig,
459 LnbConfig& lnbConfig);
Hongguang600a6ae2021-07-08 18:51:51 -0700460 AssertionResult filterDataOutputTest();
461
462 std::shared_ptr<ITuner> mService;
Yixiao Luoe8730a72023-02-01 18:39:51 -0800463 sp<IMediaCasServiceHidl> mCasServiceHidl;
464 std::shared_ptr<IMediaCasServiceAidl> mCasServiceAidl;
Hongguang600a6ae2021-07-08 18:51:51 -0700465 FrontendTests mFrontendTests;
466 DemuxTests mDemuxTests;
467 FilterTests mFilterTests;
468 DescramblerTests mDescramblerTests;
469 DvrTests mDvrTests;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000470 LnbTests mLnbTests;
471
472 private:
473 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700474};
475
476GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
477
478} // namespace