blob: f6b6815634a3fcd0d31723e1f4d33448329c6060 [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 Lizcano5b29f502022-07-06 22:09:42 +000071 recordDvrIds.clear();
Frankie Lizcano0c069532022-07-14 20:20:46 +000072 timeFilterIds.clear();
Frankie Lizcanof4e07962022-07-13 20:54:34 +000073 descramblerIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000074 audioFilterIds.clear();
75 videoFilterIds.clear();
76 playbackDvrIds.clear();
77 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000078 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000079}
80
Hongguang600a6ae2021-07-08 18:51:51 -070081class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
82 public:
83 virtual void SetUp() override {
84 if (AServiceManager_isDeclared(GetParam().c_str())) {
85 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
86 mService = ITuner::fromBinder(binder);
87 } else {
88 mService = nullptr;
89 }
90 ASSERT_NE(mService, nullptr);
91 ASSERT_TRUE(initConfiguration());
92
93 mLnbTests.setService(mService);
94 }
95
Frankie Lizcano5b29f502022-07-06 22:09:42 +000096 virtual void TearDown() override {
97 clearIds();
98 mService = nullptr;
99 }
100
Hongguang600a6ae2021-07-08 18:51:51 -0700101 protected:
102 static void description(const std::string& description) {
103 RecordProperty("description", description);
104 }
105
106 std::shared_ptr<ITuner> mService;
107 LnbTests mLnbTests;
108};
109
110GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
111
112class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
113 public:
114 virtual void SetUp() override {
115 if (AServiceManager_isDeclared(GetParam().c_str())) {
116 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
117 mService = ITuner::fromBinder(binder);
118 } else {
119 mService = nullptr;
120 }
121 ASSERT_NE(mService, nullptr);
122 ASSERT_TRUE(initConfiguration());
123
124 mFrontendTests.setService(mService);
125 mDemuxTests.setService(mService);
126 mFilterTests.setService(mService);
127 }
128
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000129 virtual void TearDown() override {
130 clearIds();
131 mService = nullptr;
132 }
133
Hongguang600a6ae2021-07-08 18:51:51 -0700134 protected:
135 static void description(const std::string& description) {
136 RecordProperty("description", description);
137 }
138
139 std::shared_ptr<ITuner> mService;
140 FrontendTests mFrontendTests;
141 DemuxTests mDemuxTests;
142 FilterTests mFilterTests;
143};
144
145GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
146
147class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
148 public:
149 virtual void SetUp() override {
150 if (AServiceManager_isDeclared(GetParam().c_str())) {
151 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
152 mService = ITuner::fromBinder(binder);
153 } else {
154 mService = nullptr;
155 }
156 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000157 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700158
159 mFrontendTests.setService(mService);
160 mDemuxTests.setService(mService);
161 mFilterTests.setService(mService);
162 }
163
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000164 virtual void TearDown() override {
165 clearIds();
166 mService = nullptr;
167 }
168
Hongguang600a6ae2021-07-08 18:51:51 -0700169 protected:
170 static void description(const std::string& description) {
171 RecordProperty("description", description);
172 }
173
174 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
175 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
176 FrontendConfig frontendConf);
177 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100178 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700179
180 DemuxFilterType getLinkageFilterType(int bit) {
181 DemuxFilterType type;
182 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
183 switch (type.mainType) {
184 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700185 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700186 DemuxTsFilterType::UNDEFINED);
187 break;
188 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700189 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700190 DemuxMmtpFilterType::UNDEFINED);
191 break;
192 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700193 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700194 DemuxIpFilterType::UNDEFINED);
195 break;
196 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700197 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700198 DemuxTlvFilterType::UNDEFINED);
199 break;
200 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700201 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700202 DemuxAlpFilterType::UNDEFINED);
203 break;
204 default:
205 break;
206 }
207 return type;
208 }
209 std::shared_ptr<ITuner> mService;
210 FrontendTests mFrontendTests;
211 DemuxTests mDemuxTests;
212 FilterTests mFilterTests;
213};
214
215GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
216
217class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
218 public:
219 virtual void SetUp() override {
220 if (AServiceManager_isDeclared(GetParam().c_str())) {
221 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
222 mService = ITuner::fromBinder(binder);
223 } else {
224 mService = nullptr;
225 }
226 ASSERT_NE(mService, nullptr);
227 ASSERT_TRUE(initConfiguration());
228
229 mFrontendTests.setService(mService);
230 mDemuxTests.setService(mService);
231 mFilterTests.setService(mService);
232 mDvrTests.setService(mService);
233 }
234
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000235 virtual void TearDown() override {
236 clearIds();
237 mService = nullptr;
238 }
239
Hongguang600a6ae2021-07-08 18:51:51 -0700240 protected:
241 static void description(const std::string& description) {
242 RecordProperty("description", description);
243 }
244
245 std::shared_ptr<ITuner> mService;
246 FrontendTests mFrontendTests;
247 DemuxTests mDemuxTests;
248 FilterTests mFilterTests;
249 DvrTests mDvrTests;
250
251 AssertionResult filterDataOutputTest();
252
253 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
254};
255
256GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
257
258class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
259 public:
260 virtual void SetUp() override {
261 if (AServiceManager_isDeclared(GetParam().c_str())) {
262 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
263 mService = ITuner::fromBinder(binder);
264 } else {
265 mService = nullptr;
266 }
267 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000268 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700269
270 mFrontendTests.setService(mService);
271 mDemuxTests.setService(mService);
272 mFilterTests.setService(mService);
273 mDvrTests.setService(mService);
274 mLnbTests.setService(mService);
275 }
276
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000277 virtual void TearDown() override {
278 clearIds();
279 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000280 }
281
Hongguang600a6ae2021-07-08 18:51:51 -0700282 protected:
283 static void description(const std::string& description) {
284 RecordProperty("description", description);
285 }
286
287 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
288 DvrConfig dvrConf);
289 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
290 DvrConfig dvrConf, LnbConfig lnbConf);
291 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
292 DvrConfig dvrConf);
293
294 std::shared_ptr<ITuner> mService;
295 FrontendTests mFrontendTests;
296 DemuxTests mDemuxTests;
297 FilterTests mFilterTests;
298 DvrTests mDvrTests;
299 LnbTests mLnbTests;
300
301 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000302 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700303};
304
305GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
306
307class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
308 public:
309 virtual void SetUp() override {
310 if (AServiceManager_isDeclared(GetParam().c_str())) {
311 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
312 mService = ITuner::fromBinder(binder);
313 } else {
314 mService = nullptr;
315 }
316 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000317 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700318
319 mFrontendTests.setService(mService);
320 }
321
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000322 virtual void TearDown() override {
323 clearIds();
324 mService = nullptr;
325 }
326
Hongguang600a6ae2021-07-08 18:51:51 -0700327 protected:
328 static void description(const std::string& description) {
329 RecordProperty("description", description);
330 }
331
332 std::shared_ptr<ITuner> mService;
333 FrontendTests mFrontendTests;
334};
335
336GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
337
338class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
339 public:
340 virtual void SetUp() override {
341 if (AServiceManager_isDeclared(GetParam().c_str())) {
342 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
343 mService = ITuner::fromBinder(binder);
344 } else {
345 mService = nullptr;
346 }
347 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000348 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700349
350 mFrontendTests.setService(mService);
351 mDemuxTests.setService(mService);
352 mFilterTests.setService(mService);
353 mLnbTests.setService(mService);
354 mDvrTests.setService(mService);
355 }
356
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000357 virtual void TearDown() override {
358 clearIds();
359 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000360 }
361
Hongguang600a6ae2021-07-08 18:51:51 -0700362 protected:
363 static void description(const std::string& description) {
364 RecordProperty("description", description);
365 }
366
367 std::shared_ptr<ITuner> mService;
368 FrontendTests mFrontendTests;
369 DemuxTests mDemuxTests;
370 FilterTests mFilterTests;
371 LnbTests mLnbTests;
372 DvrTests mDvrTests;
373
374 AssertionResult filterDataOutputTest();
375
376 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
377 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
378 LnbConfig lnbConf);
379 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
380
381 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000382 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700383};
384
385GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
386
387class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
388 public:
389 virtual void SetUp() override {
390 if (AServiceManager_isDeclared(GetParam().c_str())) {
391 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
392 mService = ITuner::fromBinder(binder);
393 } else {
394 mService = nullptr;
395 }
396 mCasService = IMediaCasService::getService();
397 ASSERT_NE(mService, nullptr);
398 ASSERT_NE(mCasService, nullptr);
399 ASSERT_TRUE(initConfiguration());
400
401 mFrontendTests.setService(mService);
402 mDemuxTests.setService(mService);
403 mDvrTests.setService(mService);
404 mDescramblerTests.setService(mService);
405 mDescramblerTests.setCasService(mCasService);
406 }
407
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000408 virtual void TearDown() override {
409 clearIds();
410 mService = nullptr;
411 }
412
Hongguang600a6ae2021-07-08 18:51:51 -0700413 protected:
414 static void description(const std::string& description) {
415 RecordProperty("description", description);
416 }
417
418 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
419 FrontendConfig frontendConf, DescramblerConfig descConfig);
420 AssertionResult filterDataOutputTest();
421
422 std::shared_ptr<ITuner> mService;
423 android::sp<IMediaCasService> mCasService;
424 FrontendTests mFrontendTests;
425 DemuxTests mDemuxTests;
426 FilterTests mFilterTests;
427 DescramblerTests mDescramblerTests;
428 DvrTests mDvrTests;
429};
430
431GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
432
433} // namespace