blob: e5f331bde7b9a65297c98efc3a08db4fa6652a59 [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
Frankie Lizcano9c464f72022-07-18 17:56:52 +000081enum class Dataflow_Context { LNBRECORD, RECORD };
82
Hongguang600a6ae2021-07-08 18:51:51 -070083class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
84 public:
85 virtual void SetUp() override {
86 if (AServiceManager_isDeclared(GetParam().c_str())) {
87 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
88 mService = ITuner::fromBinder(binder);
89 } else {
90 mService = nullptr;
91 }
92 ASSERT_NE(mService, nullptr);
93 ASSERT_TRUE(initConfiguration());
94
95 mLnbTests.setService(mService);
96 }
97
Frankie Lizcano5b29f502022-07-06 22:09:42 +000098 virtual void TearDown() override {
99 clearIds();
100 mService = nullptr;
101 }
102
Hongguang600a6ae2021-07-08 18:51:51 -0700103 protected:
104 static void description(const std::string& description) {
105 RecordProperty("description", description);
106 }
107
108 std::shared_ptr<ITuner> mService;
109 LnbTests mLnbTests;
110};
111
112GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
113
114class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
115 public:
116 virtual void SetUp() override {
117 if (AServiceManager_isDeclared(GetParam().c_str())) {
118 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
119 mService = ITuner::fromBinder(binder);
120 } else {
121 mService = nullptr;
122 }
123 ASSERT_NE(mService, nullptr);
124 ASSERT_TRUE(initConfiguration());
125
126 mFrontendTests.setService(mService);
127 mDemuxTests.setService(mService);
128 mFilterTests.setService(mService);
129 }
130
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000131 virtual void TearDown() override {
132 clearIds();
133 mService = nullptr;
134 }
135
Hongguang600a6ae2021-07-08 18:51:51 -0700136 protected:
137 static void description(const std::string& description) {
138 RecordProperty("description", description);
139 }
140
141 std::shared_ptr<ITuner> mService;
142 FrontendTests mFrontendTests;
143 DemuxTests mDemuxTests;
144 FilterTests mFilterTests;
145};
146
147GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
148
149class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
150 public:
151 virtual void SetUp() override {
152 if (AServiceManager_isDeclared(GetParam().c_str())) {
153 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
154 mService = ITuner::fromBinder(binder);
155 } else {
156 mService = nullptr;
157 }
158 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000159 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700160
161 mFrontendTests.setService(mService);
162 mDemuxTests.setService(mService);
163 mFilterTests.setService(mService);
164 }
165
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000166 virtual void TearDown() override {
167 clearIds();
168 mService = nullptr;
169 }
170
Hongguang600a6ae2021-07-08 18:51:51 -0700171 protected:
172 static void description(const std::string& description) {
173 RecordProperty("description", description);
174 }
175
176 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
177 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
178 FrontendConfig frontendConf);
179 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100180 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700181
182 DemuxFilterType getLinkageFilterType(int bit) {
183 DemuxFilterType type;
184 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
185 switch (type.mainType) {
186 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700187 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700188 DemuxTsFilterType::UNDEFINED);
189 break;
190 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700191 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700192 DemuxMmtpFilterType::UNDEFINED);
193 break;
194 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700195 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700196 DemuxIpFilterType::UNDEFINED);
197 break;
198 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700199 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700200 DemuxTlvFilterType::UNDEFINED);
201 break;
202 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700203 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700204 DemuxAlpFilterType::UNDEFINED);
205 break;
206 default:
207 break;
208 }
209 return type;
210 }
211 std::shared_ptr<ITuner> mService;
212 FrontendTests mFrontendTests;
213 DemuxTests mDemuxTests;
214 FilterTests mFilterTests;
215};
216
217GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
218
219class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
220 public:
221 virtual void SetUp() override {
222 if (AServiceManager_isDeclared(GetParam().c_str())) {
223 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
224 mService = ITuner::fromBinder(binder);
225 } else {
226 mService = nullptr;
227 }
228 ASSERT_NE(mService, nullptr);
229 ASSERT_TRUE(initConfiguration());
230
231 mFrontendTests.setService(mService);
232 mDemuxTests.setService(mService);
233 mFilterTests.setService(mService);
234 mDvrTests.setService(mService);
235 }
236
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000237 virtual void TearDown() override {
238 clearIds();
239 mService = nullptr;
240 }
241
Hongguang600a6ae2021-07-08 18:51:51 -0700242 protected:
243 static void description(const std::string& description) {
244 RecordProperty("description", description);
245 }
246
247 std::shared_ptr<ITuner> mService;
248 FrontendTests mFrontendTests;
249 DemuxTests mDemuxTests;
250 FilterTests mFilterTests;
251 DvrTests mDvrTests;
252
253 AssertionResult filterDataOutputTest();
254
255 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
256};
257
258GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
259
260class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
261 public:
262 virtual void SetUp() override {
263 if (AServiceManager_isDeclared(GetParam().c_str())) {
264 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
265 mService = ITuner::fromBinder(binder);
266 } else {
267 mService = nullptr;
268 }
269 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000270 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700271
272 mFrontendTests.setService(mService);
273 mDemuxTests.setService(mService);
274 mFilterTests.setService(mService);
275 mDvrTests.setService(mService);
276 mLnbTests.setService(mService);
277 }
278
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000279 virtual void TearDown() override {
280 clearIds();
281 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000282 }
283
Hongguang600a6ae2021-07-08 18:51:51 -0700284 protected:
285 static void description(const std::string& description) {
286 RecordProperty("description", description);
287 }
288
289 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
290 DvrConfig dvrConf);
291 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
292 DvrConfig dvrConf, LnbConfig lnbConf);
293 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000294 DvrConfig dvrConf, Dataflow_Context context);
Hongguang600a6ae2021-07-08 18:51:51 -0700295
296 std::shared_ptr<ITuner> mService;
297 FrontendTests mFrontendTests;
298 DemuxTests mDemuxTests;
299 FilterTests mFilterTests;
300 DvrTests mDvrTests;
301 LnbTests mLnbTests;
302
303 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000304 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700305};
306
307GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
308
309class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
310 public:
311 virtual void SetUp() override {
312 if (AServiceManager_isDeclared(GetParam().c_str())) {
313 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
314 mService = ITuner::fromBinder(binder);
315 } else {
316 mService = nullptr;
317 }
318 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000319 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700320
321 mFrontendTests.setService(mService);
322 }
323
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000324 virtual void TearDown() override {
325 clearIds();
326 mService = nullptr;
327 }
328
Hongguang600a6ae2021-07-08 18:51:51 -0700329 protected:
330 static void description(const std::string& description) {
331 RecordProperty("description", description);
332 }
333
334 std::shared_ptr<ITuner> mService;
335 FrontendTests mFrontendTests;
336};
337
338GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
339
340class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
341 public:
342 virtual void SetUp() override {
343 if (AServiceManager_isDeclared(GetParam().c_str())) {
344 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
345 mService = ITuner::fromBinder(binder);
346 } else {
347 mService = nullptr;
348 }
349 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000350 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700351
352 mFrontendTests.setService(mService);
353 mDemuxTests.setService(mService);
354 mFilterTests.setService(mService);
355 mLnbTests.setService(mService);
356 mDvrTests.setService(mService);
357 }
358
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000359 virtual void TearDown() override {
360 clearIds();
361 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000362 }
363
Hongguang600a6ae2021-07-08 18:51:51 -0700364 protected:
365 static void description(const std::string& description) {
366 RecordProperty("description", description);
367 }
368
369 std::shared_ptr<ITuner> mService;
370 FrontendTests mFrontendTests;
371 DemuxTests mDemuxTests;
372 FilterTests mFilterTests;
373 LnbTests mLnbTests;
374 DvrTests mDvrTests;
375
376 AssertionResult filterDataOutputTest();
377
378 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
379 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
380 LnbConfig lnbConf);
381 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
382
383 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000384 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700385};
386
387GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
388
389class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
390 public:
391 virtual void SetUp() override {
392 if (AServiceManager_isDeclared(GetParam().c_str())) {
393 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
394 mService = ITuner::fromBinder(binder);
395 } else {
396 mService = nullptr;
397 }
398 mCasService = IMediaCasService::getService();
399 ASSERT_NE(mService, nullptr);
400 ASSERT_NE(mCasService, nullptr);
401 ASSERT_TRUE(initConfiguration());
402
403 mFrontendTests.setService(mService);
404 mDemuxTests.setService(mService);
405 mDvrTests.setService(mService);
406 mDescramblerTests.setService(mService);
407 mDescramblerTests.setCasService(mCasService);
408 }
409
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000410 virtual void TearDown() override {
411 clearIds();
412 mService = nullptr;
413 }
414
Hongguang600a6ae2021-07-08 18:51:51 -0700415 protected:
416 static void description(const std::string& description) {
417 RecordProperty("description", description);
418 }
419
420 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
421 FrontendConfig frontendConf, DescramblerConfig descConfig);
422 AssertionResult filterDataOutputTest();
423
424 std::shared_ptr<ITuner> mService;
425 android::sp<IMediaCasService> mCasService;
426 FrontendTests mFrontendTests;
427 DemuxTests mDemuxTests;
428 FilterTests mFilterTests;
429 DescramblerTests mDescramblerTests;
430 DvrTests mDvrTests;
431};
432
433GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
434
435} // namespace