blob: f68e1ecd42f3a62a46837693fb78951c6ce77eb1 [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);
258};
259
260GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
261
262class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
263 public:
264 virtual void SetUp() override {
265 if (AServiceManager_isDeclared(GetParam().c_str())) {
266 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
267 mService = ITuner::fromBinder(binder);
268 } else {
269 mService = nullptr;
270 }
271 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000272 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700273
274 mFrontendTests.setService(mService);
275 mDemuxTests.setService(mService);
276 mFilterTests.setService(mService);
277 mDvrTests.setService(mService);
278 mLnbTests.setService(mService);
279 }
280
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000281 virtual void TearDown() override {
282 clearIds();
283 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000284 }
285
Hongguang600a6ae2021-07-08 18:51:51 -0700286 protected:
287 static void description(const std::string& description) {
288 RecordProperty("description", description);
289 }
290
291 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
292 DvrConfig dvrConf);
293 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
294 DvrConfig dvrConf, LnbConfig lnbConf);
295 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000296 DvrConfig dvrConf, Dataflow_Context context);
Hongguang600a6ae2021-07-08 18:51:51 -0700297
298 std::shared_ptr<ITuner> mService;
299 FrontendTests mFrontendTests;
300 DemuxTests mDemuxTests;
301 FilterTests mFilterTests;
302 DvrTests mDvrTests;
303 LnbTests mLnbTests;
304
305 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000306 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700307};
308
309GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
310
311class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
312 public:
313 virtual void SetUp() override {
314 if (AServiceManager_isDeclared(GetParam().c_str())) {
315 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
316 mService = ITuner::fromBinder(binder);
317 } else {
318 mService = nullptr;
319 }
320 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000321 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700322
323 mFrontendTests.setService(mService);
324 }
325
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000326 virtual void TearDown() override {
327 clearIds();
328 mService = nullptr;
329 }
330
Hongguang600a6ae2021-07-08 18:51:51 -0700331 protected:
332 static void description(const std::string& description) {
333 RecordProperty("description", description);
334 }
335
336 std::shared_ptr<ITuner> mService;
337 FrontendTests mFrontendTests;
338};
339
340GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
341
342class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
343 public:
344 virtual void SetUp() override {
345 if (AServiceManager_isDeclared(GetParam().c_str())) {
346 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
347 mService = ITuner::fromBinder(binder);
348 } else {
349 mService = nullptr;
350 }
351 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000352 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700353
354 mFrontendTests.setService(mService);
355 mDemuxTests.setService(mService);
356 mFilterTests.setService(mService);
357 mLnbTests.setService(mService);
358 mDvrTests.setService(mService);
359 }
360
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000361 virtual void TearDown() override {
362 clearIds();
363 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000364 }
365
Hongguang600a6ae2021-07-08 18:51:51 -0700366 protected:
367 static void description(const std::string& description) {
368 RecordProperty("description", description);
369 }
370
371 std::shared_ptr<ITuner> mService;
372 FrontendTests mFrontendTests;
373 DemuxTests mDemuxTests;
374 FilterTests mFilterTests;
375 LnbTests mLnbTests;
376 DvrTests mDvrTests;
377
378 AssertionResult filterDataOutputTest();
379
380 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
381 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
382 LnbConfig lnbConf);
383 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
384
385 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000386 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700387};
388
389GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
390
391class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
392 public:
393 virtual void SetUp() override {
394 if (AServiceManager_isDeclared(GetParam().c_str())) {
395 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
396 mService = ITuner::fromBinder(binder);
397 } else {
398 mService = nullptr;
399 }
400 mCasService = IMediaCasService::getService();
401 ASSERT_NE(mService, nullptr);
402 ASSERT_NE(mCasService, nullptr);
403 ASSERT_TRUE(initConfiguration());
404
405 mFrontendTests.setService(mService);
406 mDemuxTests.setService(mService);
407 mDvrTests.setService(mService);
408 mDescramblerTests.setService(mService);
409 mDescramblerTests.setCasService(mCasService);
Frankie Lizcano82101d22022-07-28 00:12:35 +0000410 mLnbTests.setService(mService);
Hongguang600a6ae2021-07-08 18:51:51 -0700411 }
412
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000413 virtual void TearDown() override {
414 clearIds();
415 mService = nullptr;
416 }
417
Hongguang600a6ae2021-07-08 18:51:51 -0700418 protected:
419 static void description(const std::string& description) {
420 RecordProperty("description", description);
421 }
422
423 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000424 FrontendConfig frontendConf, DescramblerConfig descConfig,
425 Dataflow_Context context);
426 void scrambledBroadcastTestWithLnb(set<struct FilterConfig>& mediaFilterConfs,
427 FrontendConfig& frontendConf, DescramblerConfig& descConfig,
428 LnbConfig& lnbConfig);
Hongguang600a6ae2021-07-08 18:51:51 -0700429 AssertionResult filterDataOutputTest();
430
431 std::shared_ptr<ITuner> mService;
432 android::sp<IMediaCasService> mCasService;
433 FrontendTests mFrontendTests;
434 DemuxTests mDemuxTests;
435 FilterTests mFilterTests;
436 DescramblerTests mDescramblerTests;
437 DvrTests mDvrTests;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000438 LnbTests mLnbTests;
439
440 private:
441 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700442};
443
444GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
445
446} // namespace