blob: 8ad6ee0d4393e026a5ddf16e44e762cecf3826e7 [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>
20
21#include "DemuxTests.h"
22#include "DescramblerTests.h"
23#include "DvrTests.h"
24#include "FrontendTests.h"
25#include "LnbTests.h"
26
27using android::sp;
28
29namespace {
30
31bool initConfiguration() {
32 TunerTestingConfigAidlReader1_0::setConfigFilePath(configFilePath);
33 if (!TunerTestingConfigAidlReader1_0::checkConfigFileExists()) {
34 return false;
35 }
36 initFrontendConfig();
37 initFilterConfig();
38 initDvrConfig();
Frankie Lizcano1fd52972022-06-30 16:50:21 +000039 initTimeFilterConfig();
Frankie Lizcanof5352122022-06-29 22:10:16 +000040 initDescramblerConfig();
Frankie Lizcano647d5aa2022-06-30 20:49:31 +000041 initLnbConfig();
42 initDiseqcMsgsConfig();
Hongguang600a6ae2021-07-08 18:51:51 -070043 connectHardwaresToTestCases();
44 if (!validateConnections()) {
45 ALOGW("[vts] failed to validate connections.");
46 return false;
47 }
Frankie Lizcano5b29f502022-07-06 22:09:42 +000048 determineDataFlows();
49
Hongguang600a6ae2021-07-08 18:51:51 -070050 return true;
51}
52
53static AssertionResult success() {
54 return ::testing::AssertionSuccess();
55}
56
57AssertionResult filterDataOutputTestBase(FilterTests& tests) {
58 // Data Verify Module
59 std::map<int64_t, std::shared_ptr<FilterCallback>>::iterator it;
60 std::map<int64_t, std::shared_ptr<FilterCallback>> filterCallbacks = tests.getFilterCallbacks();
61 for (it = filterCallbacks.begin(); it != filterCallbacks.end(); it++) {
62 it->second->testFilterDataOutput();
63 }
64 return success();
65}
66
Frankie Lizcano5b29f502022-07-06 22:09:42 +000067void clearIds() {
Frankie Lizcano1e283b32022-07-08 21:07:42 +000068 lnbIds.clear();
69 diseqcMsgs.clear();
70 frontendIds.clear();
Frankie Lizcano8b87f252022-07-19 21:51:54 +000071 ipFilterIds.clear();
72 pcrFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000073 recordDvrIds.clear();
Frankie Lizcano0c069532022-07-14 20:20:46 +000074 timeFilterIds.clear();
Frankie Lizcanof4e07962022-07-13 20:54:34 +000075 descramblerIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000076 audioFilterIds.clear();
77 videoFilterIds.clear();
78 playbackDvrIds.clear();
79 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000080 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000081}
82
Frankie Lizcano82101d22022-07-28 00:12:35 +000083enum class Dataflow_Context { LNBRECORD, RECORD, DESCRAMBLING, LNBDESCRAMBLING };
Frankie Lizcano9c464f72022-07-18 17:56:52 +000084
Hongguang600a6ae2021-07-08 18:51:51 -070085class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
86 public:
87 virtual void SetUp() override {
88 if (AServiceManager_isDeclared(GetParam().c_str())) {
89 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
90 mService = ITuner::fromBinder(binder);
91 } else {
92 mService = nullptr;
93 }
94 ASSERT_NE(mService, nullptr);
95 ASSERT_TRUE(initConfiguration());
96
97 mLnbTests.setService(mService);
98 }
99
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000100 virtual void TearDown() override {
101 clearIds();
102 mService = nullptr;
103 }
104
Hongguang600a6ae2021-07-08 18:51:51 -0700105 protected:
106 static void description(const std::string& description) {
107 RecordProperty("description", description);
108 }
109
110 std::shared_ptr<ITuner> mService;
111 LnbTests mLnbTests;
112};
113
114GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
115
116class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
117 public:
118 virtual void SetUp() override {
119 if (AServiceManager_isDeclared(GetParam().c_str())) {
120 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
121 mService = ITuner::fromBinder(binder);
122 } else {
123 mService = nullptr;
124 }
125 ASSERT_NE(mService, nullptr);
126 ASSERT_TRUE(initConfiguration());
127
128 mFrontendTests.setService(mService);
129 mDemuxTests.setService(mService);
130 mFilterTests.setService(mService);
131 }
132
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000133 virtual void TearDown() override {
134 clearIds();
135 mService = nullptr;
136 }
137
Hongguang600a6ae2021-07-08 18:51:51 -0700138 protected:
139 static void description(const std::string& description) {
140 RecordProperty("description", description);
141 }
142
143 std::shared_ptr<ITuner> mService;
144 FrontendTests mFrontendTests;
145 DemuxTests mDemuxTests;
146 FilterTests mFilterTests;
147};
148
149GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
150
151class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
152 public:
153 virtual void SetUp() override {
154 if (AServiceManager_isDeclared(GetParam().c_str())) {
155 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
156 mService = ITuner::fromBinder(binder);
157 } else {
158 mService = nullptr;
159 }
160 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000161 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700162
163 mFrontendTests.setService(mService);
164 mDemuxTests.setService(mService);
165 mFilterTests.setService(mService);
166 }
167
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000168 virtual void TearDown() override {
169 clearIds();
170 mService = nullptr;
171 }
172
Hongguang600a6ae2021-07-08 18:51:51 -0700173 protected:
174 static void description(const std::string& description) {
175 RecordProperty("description", description);
176 }
177
178 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
179 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
180 FrontendConfig frontendConf);
181 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100182 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700183
184 DemuxFilterType getLinkageFilterType(int bit) {
185 DemuxFilterType type;
186 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
187 switch (type.mainType) {
188 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700189 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700190 DemuxTsFilterType::UNDEFINED);
191 break;
192 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700193 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700194 DemuxMmtpFilterType::UNDEFINED);
195 break;
196 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700197 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700198 DemuxIpFilterType::UNDEFINED);
199 break;
200 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700201 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700202 DemuxTlvFilterType::UNDEFINED);
203 break;
204 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700205 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700206 DemuxAlpFilterType::UNDEFINED);
207 break;
208 default:
209 break;
210 }
211 return type;
212 }
213 std::shared_ptr<ITuner> mService;
214 FrontendTests mFrontendTests;
215 DemuxTests mDemuxTests;
216 FilterTests mFilterTests;
217};
218
219GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
220
221class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
222 public:
223 virtual void SetUp() override {
224 if (AServiceManager_isDeclared(GetParam().c_str())) {
225 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
226 mService = ITuner::fromBinder(binder);
227 } else {
228 mService = nullptr;
229 }
230 ASSERT_NE(mService, nullptr);
231 ASSERT_TRUE(initConfiguration());
232
233 mFrontendTests.setService(mService);
234 mDemuxTests.setService(mService);
235 mFilterTests.setService(mService);
236 mDvrTests.setService(mService);
237 }
238
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000239 virtual void TearDown() override {
240 clearIds();
241 mService = nullptr;
242 }
243
Hongguang600a6ae2021-07-08 18:51:51 -0700244 protected:
245 static void description(const std::string& description) {
246 RecordProperty("description", description);
247 }
248
249 std::shared_ptr<ITuner> mService;
250 FrontendTests mFrontendTests;
251 DemuxTests mDemuxTests;
252 FilterTests mFilterTests;
253 DvrTests mDvrTests;
254
255 AssertionResult filterDataOutputTest();
256
257 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
Ray Chin62ab6c92022-09-15 15:07:33 +0800258
259 void setStatusCheckIntervalHintTest(int64_t milliseconds, DvrConfig dvrConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700260};
261
262GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
263
264class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
265 public:
266 virtual void SetUp() override {
267 if (AServiceManager_isDeclared(GetParam().c_str())) {
268 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
269 mService = ITuner::fromBinder(binder);
270 } else {
271 mService = nullptr;
272 }
273 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000274 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700275
276 mFrontendTests.setService(mService);
277 mDemuxTests.setService(mService);
278 mFilterTests.setService(mService);
279 mDvrTests.setService(mService);
280 mLnbTests.setService(mService);
281 }
282
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000283 virtual void TearDown() override {
284 clearIds();
285 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000286 }
287
Hongguang600a6ae2021-07-08 18:51:51 -0700288 protected:
289 static void description(const std::string& description) {
290 RecordProperty("description", description);
291 }
292
293 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
294 DvrConfig dvrConf);
295 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
296 DvrConfig dvrConf, LnbConfig lnbConf);
297 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000298 DvrConfig dvrConf, Dataflow_Context context);
Ray Chin62ab6c92022-09-15 15:07:33 +0800299 void setStatusCheckIntervalHintTest(int64_t milliseconds, FrontendConfig frontendConf,
300 DvrConfig dvrConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700301
302 std::shared_ptr<ITuner> mService;
303 FrontendTests mFrontendTests;
304 DemuxTests mDemuxTests;
305 FilterTests mFilterTests;
306 DvrTests mDvrTests;
307 LnbTests mLnbTests;
308
309 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000310 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700311};
312
313GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
314
315class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
316 public:
317 virtual void SetUp() override {
318 if (AServiceManager_isDeclared(GetParam().c_str())) {
319 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
320 mService = ITuner::fromBinder(binder);
321 } else {
322 mService = nullptr;
323 }
324 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000325 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700326
327 mFrontendTests.setService(mService);
328 }
329
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000330 virtual void TearDown() override {
331 clearIds();
332 mService = nullptr;
333 }
334
Hongguang600a6ae2021-07-08 18:51:51 -0700335 protected:
336 static void description(const std::string& description) {
337 RecordProperty("description", description);
338 }
339
340 std::shared_ptr<ITuner> mService;
341 FrontendTests mFrontendTests;
342};
343
344GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
345
346class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
347 public:
348 virtual void SetUp() override {
349 if (AServiceManager_isDeclared(GetParam().c_str())) {
350 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
351 mService = ITuner::fromBinder(binder);
352 } else {
353 mService = nullptr;
354 }
355 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000356 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700357
358 mFrontendTests.setService(mService);
359 mDemuxTests.setService(mService);
360 mFilterTests.setService(mService);
361 mLnbTests.setService(mService);
362 mDvrTests.setService(mService);
363 }
364
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000365 virtual void TearDown() override {
366 clearIds();
367 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000368 }
369
Hongguang600a6ae2021-07-08 18:51:51 -0700370 protected:
371 static void description(const std::string& description) {
372 RecordProperty("description", description);
373 }
374
375 std::shared_ptr<ITuner> mService;
376 FrontendTests mFrontendTests;
377 DemuxTests mDemuxTests;
378 FilterTests mFilterTests;
379 LnbTests mLnbTests;
380 DvrTests mDvrTests;
381
382 AssertionResult filterDataOutputTest();
383
384 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
385 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
386 LnbConfig lnbConf);
387 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
388
389 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000390 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700391};
392
393GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
394
395class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
396 public:
397 virtual void SetUp() override {
398 if (AServiceManager_isDeclared(GetParam().c_str())) {
399 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
400 mService = ITuner::fromBinder(binder);
401 } else {
402 mService = nullptr;
403 }
Hongguang600a6ae2021-07-08 18:51:51 -0700404 ASSERT_NE(mService, nullptr);
Yixiao Luoe8730a72023-02-01 18:39:51 -0800405
406 // Get IMediaCasService. Try getting AIDL service first, if AIDL does not exist, try HIDL.
407 if (AServiceManager_isDeclared(MEDIA_CAS_AIDL_SERVICE_NAME.c_str())) {
408 ::ndk::SpAIBinder binder(
409 AServiceManager_waitForService(MEDIA_CAS_AIDL_SERVICE_NAME.c_str()));
410 mCasServiceAidl = IMediaCasServiceAidl::fromBinder(binder);
411 } else {
412 mCasServiceAidl = nullptr;
413 }
414 if (mCasServiceAidl == nullptr) {
415 mCasServiceHidl = IMediaCasServiceHidl::getService();
416 }
417 ASSERT_TRUE(mCasServiceAidl != nullptr || mCasServiceHidl != nullptr);
Hongguang600a6ae2021-07-08 18:51:51 -0700418 ASSERT_TRUE(initConfiguration());
419
420 mFrontendTests.setService(mService);
421 mDemuxTests.setService(mService);
422 mDvrTests.setService(mService);
423 mDescramblerTests.setService(mService);
Yixiao Luoe8730a72023-02-01 18:39:51 -0800424 if (mCasServiceAidl != nullptr) {
425 mDescramblerTests.setCasServiceAidl(mCasServiceAidl);
426 } else {
427 mDescramblerTests.setCasServiceHidl(mCasServiceHidl);
428 }
Frankie Lizcano82101d22022-07-28 00:12:35 +0000429 mLnbTests.setService(mService);
Hongguang600a6ae2021-07-08 18:51:51 -0700430 }
431
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000432 virtual void TearDown() override {
433 clearIds();
434 mService = nullptr;
435 }
436
Hongguang600a6ae2021-07-08 18:51:51 -0700437 protected:
438 static void description(const std::string& description) {
439 RecordProperty("description", description);
440 }
441
442 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000443 FrontendConfig frontendConf, DescramblerConfig descConfig,
444 Dataflow_Context context);
445 void scrambledBroadcastTestWithLnb(set<struct FilterConfig>& mediaFilterConfs,
446 FrontendConfig& frontendConf, DescramblerConfig& descConfig,
447 LnbConfig& lnbConfig);
Hongguang600a6ae2021-07-08 18:51:51 -0700448 AssertionResult filterDataOutputTest();
449
450 std::shared_ptr<ITuner> mService;
Yixiao Luoe8730a72023-02-01 18:39:51 -0800451 sp<IMediaCasServiceHidl> mCasServiceHidl;
452 std::shared_ptr<IMediaCasServiceAidl> mCasServiceAidl;
Hongguang600a6ae2021-07-08 18:51:51 -0700453 FrontendTests mFrontendTests;
454 DemuxTests mDemuxTests;
455 FilterTests mFilterTests;
456 DescramblerTests mDescramblerTests;
457 DvrTests mDvrTests;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000458 LnbTests mLnbTests;
459
460 private:
461 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700462};
463
464GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
465
466} // namespace