blob: d4536aad1e8f8d7116bbbc4897066014dfb4abc6 [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() {
68 recordDvrIds.clear();
69 audioFilterIds.clear();
70 videoFilterIds.clear();
71 playbackDvrIds.clear();
72 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000073 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000074}
75
Hongguang600a6ae2021-07-08 18:51:51 -070076class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
77 public:
78 virtual void SetUp() override {
79 if (AServiceManager_isDeclared(GetParam().c_str())) {
80 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
81 mService = ITuner::fromBinder(binder);
82 } else {
83 mService = nullptr;
84 }
85 ASSERT_NE(mService, nullptr);
86 ASSERT_TRUE(initConfiguration());
87
88 mLnbTests.setService(mService);
89 }
90
Frankie Lizcano5b29f502022-07-06 22:09:42 +000091 virtual void TearDown() override {
92 clearIds();
93 mService = nullptr;
94 }
95
Hongguang600a6ae2021-07-08 18:51:51 -070096 protected:
97 static void description(const std::string& description) {
98 RecordProperty("description", description);
99 }
100
101 std::shared_ptr<ITuner> mService;
102 LnbTests mLnbTests;
103};
104
105GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
106
107class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
108 public:
109 virtual void SetUp() override {
110 if (AServiceManager_isDeclared(GetParam().c_str())) {
111 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
112 mService = ITuner::fromBinder(binder);
113 } else {
114 mService = nullptr;
115 }
116 ASSERT_NE(mService, nullptr);
117 ASSERT_TRUE(initConfiguration());
118
119 mFrontendTests.setService(mService);
120 mDemuxTests.setService(mService);
121 mFilterTests.setService(mService);
122 }
123
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000124 virtual void TearDown() override {
125 clearIds();
126 mService = nullptr;
127 }
128
Hongguang600a6ae2021-07-08 18:51:51 -0700129 protected:
130 static void description(const std::string& description) {
131 RecordProperty("description", description);
132 }
133
134 std::shared_ptr<ITuner> mService;
135 FrontendTests mFrontendTests;
136 DemuxTests mDemuxTests;
137 FilterTests mFilterTests;
138};
139
140GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
141
142class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
143 public:
144 virtual void SetUp() override {
145 if (AServiceManager_isDeclared(GetParam().c_str())) {
146 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
147 mService = ITuner::fromBinder(binder);
148 } else {
149 mService = nullptr;
150 }
151 ASSERT_NE(mService, nullptr);
152 initConfiguration();
153
154 mFrontendTests.setService(mService);
155 mDemuxTests.setService(mService);
156 mFilterTests.setService(mService);
157 }
158
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000159 virtual void TearDown() override {
160 clearIds();
161 mService = nullptr;
162 }
163
Hongguang600a6ae2021-07-08 18:51:51 -0700164 protected:
165 static void description(const std::string& description) {
166 RecordProperty("description", description);
167 }
168
169 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
170 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
171 FrontendConfig frontendConf);
172 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100173 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700174
175 DemuxFilterType getLinkageFilterType(int bit) {
176 DemuxFilterType type;
177 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
178 switch (type.mainType) {
179 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700180 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700181 DemuxTsFilterType::UNDEFINED);
182 break;
183 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700184 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700185 DemuxMmtpFilterType::UNDEFINED);
186 break;
187 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700188 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700189 DemuxIpFilterType::UNDEFINED);
190 break;
191 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700192 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700193 DemuxTlvFilterType::UNDEFINED);
194 break;
195 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700196 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700197 DemuxAlpFilterType::UNDEFINED);
198 break;
199 default:
200 break;
201 }
202 return type;
203 }
204 std::shared_ptr<ITuner> mService;
205 FrontendTests mFrontendTests;
206 DemuxTests mDemuxTests;
207 FilterTests mFilterTests;
208};
209
210GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
211
212class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
213 public:
214 virtual void SetUp() override {
215 if (AServiceManager_isDeclared(GetParam().c_str())) {
216 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
217 mService = ITuner::fromBinder(binder);
218 } else {
219 mService = nullptr;
220 }
221 ASSERT_NE(mService, nullptr);
222 ASSERT_TRUE(initConfiguration());
223
224 mFrontendTests.setService(mService);
225 mDemuxTests.setService(mService);
226 mFilterTests.setService(mService);
227 mDvrTests.setService(mService);
228 }
229
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000230 virtual void TearDown() override {
231 clearIds();
232 mService = nullptr;
233 }
234
Hongguang600a6ae2021-07-08 18:51:51 -0700235 protected:
236 static void description(const std::string& description) {
237 RecordProperty("description", description);
238 }
239
240 std::shared_ptr<ITuner> mService;
241 FrontendTests mFrontendTests;
242 DemuxTests mDemuxTests;
243 FilterTests mFilterTests;
244 DvrTests mDvrTests;
245
246 AssertionResult filterDataOutputTest();
247
248 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
249};
250
251GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
252
253class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
254 public:
255 virtual void SetUp() override {
256 if (AServiceManager_isDeclared(GetParam().c_str())) {
257 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
258 mService = ITuner::fromBinder(binder);
259 } else {
260 mService = nullptr;
261 }
262 ASSERT_NE(mService, nullptr);
263 initConfiguration();
264
265 mFrontendTests.setService(mService);
266 mDemuxTests.setService(mService);
267 mFilterTests.setService(mService);
268 mDvrTests.setService(mService);
269 mLnbTests.setService(mService);
270 }
271
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000272 virtual void TearDown() override {
273 clearIds();
274 mService = nullptr;
275 mLnbId = nullptr;
276 }
277
Hongguang600a6ae2021-07-08 18:51:51 -0700278 protected:
279 static void description(const std::string& description) {
280 RecordProperty("description", description);
281 }
282
283 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
284 DvrConfig dvrConf);
285 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
286 DvrConfig dvrConf, LnbConfig lnbConf);
287 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
288 DvrConfig dvrConf);
289
290 std::shared_ptr<ITuner> mService;
291 FrontendTests mFrontendTests;
292 DemuxTests mDemuxTests;
293 FilterTests mFilterTests;
294 DvrTests mDvrTests;
295 LnbTests mLnbTests;
296
297 private:
298 int32_t* mLnbId = nullptr;
299};
300
301GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
302
303class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
304 public:
305 virtual void SetUp() override {
306 if (AServiceManager_isDeclared(GetParam().c_str())) {
307 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
308 mService = ITuner::fromBinder(binder);
309 } else {
310 mService = nullptr;
311 }
312 ASSERT_NE(mService, nullptr);
313 initConfiguration();
314
315 mFrontendTests.setService(mService);
316 }
317
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000318 virtual void TearDown() override {
319 clearIds();
320 mService = nullptr;
321 }
322
Hongguang600a6ae2021-07-08 18:51:51 -0700323 protected:
324 static void description(const std::string& description) {
325 RecordProperty("description", description);
326 }
327
328 std::shared_ptr<ITuner> mService;
329 FrontendTests mFrontendTests;
330};
331
332GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
333
334class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
335 public:
336 virtual void SetUp() override {
337 if (AServiceManager_isDeclared(GetParam().c_str())) {
338 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
339 mService = ITuner::fromBinder(binder);
340 } else {
341 mService = nullptr;
342 }
343 ASSERT_NE(mService, nullptr);
344 initConfiguration();
345
346 mFrontendTests.setService(mService);
347 mDemuxTests.setService(mService);
348 mFilterTests.setService(mService);
349 mLnbTests.setService(mService);
350 mDvrTests.setService(mService);
351 }
352
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000353 virtual void TearDown() override {
354 clearIds();
355 mService = nullptr;
356 mLnbId = nullptr;
357 }
358
Hongguang600a6ae2021-07-08 18:51:51 -0700359 protected:
360 static void description(const std::string& description) {
361 RecordProperty("description", description);
362 }
363
364 std::shared_ptr<ITuner> mService;
365 FrontendTests mFrontendTests;
366 DemuxTests mDemuxTests;
367 FilterTests mFilterTests;
368 LnbTests mLnbTests;
369 DvrTests mDvrTests;
370
371 AssertionResult filterDataOutputTest();
372
373 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
374 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
375 LnbConfig lnbConf);
376 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
377
378 private:
379 int32_t* mLnbId = nullptr;
380};
381
382GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
383
384class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
385 public:
386 virtual void SetUp() override {
387 if (AServiceManager_isDeclared(GetParam().c_str())) {
388 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
389 mService = ITuner::fromBinder(binder);
390 } else {
391 mService = nullptr;
392 }
393 mCasService = IMediaCasService::getService();
394 ASSERT_NE(mService, nullptr);
395 ASSERT_NE(mCasService, nullptr);
396 ASSERT_TRUE(initConfiguration());
397
398 mFrontendTests.setService(mService);
399 mDemuxTests.setService(mService);
400 mDvrTests.setService(mService);
401 mDescramblerTests.setService(mService);
402 mDescramblerTests.setCasService(mCasService);
403 }
404
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000405 virtual void TearDown() override {
406 clearIds();
407 mService = nullptr;
408 }
409
Hongguang600a6ae2021-07-08 18:51:51 -0700410 protected:
411 static void description(const std::string& description) {
412 RecordProperty("description", description);
413 }
414
415 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
416 FrontendConfig frontendConf, DescramblerConfig descConfig);
417 AssertionResult filterDataOutputTest();
418
419 std::shared_ptr<ITuner> mService;
420 android::sp<IMediaCasService> mCasService;
421 FrontendTests mFrontendTests;
422 DemuxTests mDemuxTests;
423 FilterTests mFilterTests;
424 DescramblerTests mDescramblerTests;
425 DvrTests mDvrTests;
426};
427
428GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
429
430} // namespace