blob: 6ffa18f5bd42f7e983f628cefc0df416bcfe0e40 [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 Lizcanof4e07962022-07-13 20:54:34 +000072 descramblerIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000073 audioFilterIds.clear();
74 videoFilterIds.clear();
75 playbackDvrIds.clear();
76 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000077 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000078}
79
Hongguang600a6ae2021-07-08 18:51:51 -070080class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
81 public:
82 virtual void SetUp() override {
83 if (AServiceManager_isDeclared(GetParam().c_str())) {
84 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
85 mService = ITuner::fromBinder(binder);
86 } else {
87 mService = nullptr;
88 }
89 ASSERT_NE(mService, nullptr);
90 ASSERT_TRUE(initConfiguration());
91
92 mLnbTests.setService(mService);
93 }
94
Frankie Lizcano5b29f502022-07-06 22:09:42 +000095 virtual void TearDown() override {
96 clearIds();
97 mService = nullptr;
98 }
99
Hongguang600a6ae2021-07-08 18:51:51 -0700100 protected:
101 static void description(const std::string& description) {
102 RecordProperty("description", description);
103 }
104
105 std::shared_ptr<ITuner> mService;
106 LnbTests mLnbTests;
107};
108
109GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
110
111class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
112 public:
113 virtual void SetUp() override {
114 if (AServiceManager_isDeclared(GetParam().c_str())) {
115 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
116 mService = ITuner::fromBinder(binder);
117 } else {
118 mService = nullptr;
119 }
120 ASSERT_NE(mService, nullptr);
121 ASSERT_TRUE(initConfiguration());
122
123 mFrontendTests.setService(mService);
124 mDemuxTests.setService(mService);
125 mFilterTests.setService(mService);
126 }
127
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000128 virtual void TearDown() override {
129 clearIds();
130 mService = nullptr;
131 }
132
Hongguang600a6ae2021-07-08 18:51:51 -0700133 protected:
134 static void description(const std::string& description) {
135 RecordProperty("description", description);
136 }
137
138 std::shared_ptr<ITuner> mService;
139 FrontendTests mFrontendTests;
140 DemuxTests mDemuxTests;
141 FilterTests mFilterTests;
142};
143
144GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
145
146class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
147 public:
148 virtual void SetUp() override {
149 if (AServiceManager_isDeclared(GetParam().c_str())) {
150 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
151 mService = ITuner::fromBinder(binder);
152 } else {
153 mService = nullptr;
154 }
155 ASSERT_NE(mService, nullptr);
156 initConfiguration();
157
158 mFrontendTests.setService(mService);
159 mDemuxTests.setService(mService);
160 mFilterTests.setService(mService);
161 }
162
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000163 virtual void TearDown() override {
164 clearIds();
165 mService = nullptr;
166 }
167
Hongguang600a6ae2021-07-08 18:51:51 -0700168 protected:
169 static void description(const std::string& description) {
170 RecordProperty("description", description);
171 }
172
173 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
174 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
175 FrontendConfig frontendConf);
176 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100177 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700178
179 DemuxFilterType getLinkageFilterType(int bit) {
180 DemuxFilterType type;
181 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
182 switch (type.mainType) {
183 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700184 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700185 DemuxTsFilterType::UNDEFINED);
186 break;
187 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700188 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700189 DemuxMmtpFilterType::UNDEFINED);
190 break;
191 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700192 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700193 DemuxIpFilterType::UNDEFINED);
194 break;
195 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700196 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700197 DemuxTlvFilterType::UNDEFINED);
198 break;
199 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700200 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700201 DemuxAlpFilterType::UNDEFINED);
202 break;
203 default:
204 break;
205 }
206 return type;
207 }
208 std::shared_ptr<ITuner> mService;
209 FrontendTests mFrontendTests;
210 DemuxTests mDemuxTests;
211 FilterTests mFilterTests;
212};
213
214GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
215
216class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
217 public:
218 virtual void SetUp() override {
219 if (AServiceManager_isDeclared(GetParam().c_str())) {
220 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
221 mService = ITuner::fromBinder(binder);
222 } else {
223 mService = nullptr;
224 }
225 ASSERT_NE(mService, nullptr);
226 ASSERT_TRUE(initConfiguration());
227
228 mFrontendTests.setService(mService);
229 mDemuxTests.setService(mService);
230 mFilterTests.setService(mService);
231 mDvrTests.setService(mService);
232 }
233
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000234 virtual void TearDown() override {
235 clearIds();
236 mService = nullptr;
237 }
238
Hongguang600a6ae2021-07-08 18:51:51 -0700239 protected:
240 static void description(const std::string& description) {
241 RecordProperty("description", description);
242 }
243
244 std::shared_ptr<ITuner> mService;
245 FrontendTests mFrontendTests;
246 DemuxTests mDemuxTests;
247 FilterTests mFilterTests;
248 DvrTests mDvrTests;
249
250 AssertionResult filterDataOutputTest();
251
252 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
253};
254
255GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
256
257class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
258 public:
259 virtual void SetUp() override {
260 if (AServiceManager_isDeclared(GetParam().c_str())) {
261 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
262 mService = ITuner::fromBinder(binder);
263 } else {
264 mService = nullptr;
265 }
266 ASSERT_NE(mService, nullptr);
267 initConfiguration();
268
269 mFrontendTests.setService(mService);
270 mDemuxTests.setService(mService);
271 mFilterTests.setService(mService);
272 mDvrTests.setService(mService);
273 mLnbTests.setService(mService);
274 }
275
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000276 virtual void TearDown() override {
277 clearIds();
278 mService = nullptr;
279 mLnbId = nullptr;
280 }
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:
302 int32_t* mLnbId = nullptr;
303};
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);
317 initConfiguration();
318
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);
348 initConfiguration();
349
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;
360 mLnbId = nullptr;
361 }
362
Hongguang600a6ae2021-07-08 18:51:51 -0700363 protected:
364 static void description(const std::string& description) {
365 RecordProperty("description", description);
366 }
367
368 std::shared_ptr<ITuner> mService;
369 FrontendTests mFrontendTests;
370 DemuxTests mDemuxTests;
371 FilterTests mFilterTests;
372 LnbTests mLnbTests;
373 DvrTests mDvrTests;
374
375 AssertionResult filterDataOutputTest();
376
377 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
378 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
379 LnbConfig lnbConf);
380 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
381
382 private:
383 int32_t* mLnbId = nullptr;
384};
385
386GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
387
388class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
389 public:
390 virtual void SetUp() override {
391 if (AServiceManager_isDeclared(GetParam().c_str())) {
392 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
393 mService = ITuner::fromBinder(binder);
394 } else {
395 mService = nullptr;
396 }
397 mCasService = IMediaCasService::getService();
398 ASSERT_NE(mService, nullptr);
399 ASSERT_NE(mCasService, nullptr);
400 ASSERT_TRUE(initConfiguration());
401
402 mFrontendTests.setService(mService);
403 mDemuxTests.setService(mService);
404 mDvrTests.setService(mService);
405 mDescramblerTests.setService(mService);
406 mDescramblerTests.setCasService(mCasService);
407 }
408
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000409 virtual void TearDown() override {
410 clearIds();
411 mService = nullptr;
412 }
413
Hongguang600a6ae2021-07-08 18:51:51 -0700414 protected:
415 static void description(const std::string& description) {
416 RecordProperty("description", description);
417 }
418
419 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
420 FrontendConfig frontendConf, DescramblerConfig descConfig);
421 AssertionResult filterDataOutputTest();
422
423 std::shared_ptr<ITuner> mService;
424 android::sp<IMediaCasService> mCasService;
425 FrontendTests mFrontendTests;
426 DemuxTests mDemuxTests;
427 FilterTests mFilterTests;
428 DescramblerTests mDescramblerTests;
429 DvrTests mDvrTests;
430};
431
432GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
433
434} // namespace