blob: e40540d99762dcf1078cecc26086709ea1761d58 [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);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000156 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700157
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);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000267 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700268
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;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000279 }
280
Hongguang600a6ae2021-07-08 18:51:51 -0700281 protected:
282 static void description(const std::string& description) {
283 RecordProperty("description", description);
284 }
285
286 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
287 DvrConfig dvrConf);
288 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
289 DvrConfig dvrConf, LnbConfig lnbConf);
290 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
291 DvrConfig dvrConf);
292
293 std::shared_ptr<ITuner> mService;
294 FrontendTests mFrontendTests;
295 DemuxTests mDemuxTests;
296 FilterTests mFilterTests;
297 DvrTests mDvrTests;
298 LnbTests mLnbTests;
299
300 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000301 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700302};
303
304GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
305
306class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
307 public:
308 virtual void SetUp() override {
309 if (AServiceManager_isDeclared(GetParam().c_str())) {
310 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
311 mService = ITuner::fromBinder(binder);
312 } else {
313 mService = nullptr;
314 }
315 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000316 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700317
318 mFrontendTests.setService(mService);
319 }
320
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000321 virtual void TearDown() override {
322 clearIds();
323 mService = nullptr;
324 }
325
Hongguang600a6ae2021-07-08 18:51:51 -0700326 protected:
327 static void description(const std::string& description) {
328 RecordProperty("description", description);
329 }
330
331 std::shared_ptr<ITuner> mService;
332 FrontendTests mFrontendTests;
333};
334
335GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
336
337class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
338 public:
339 virtual void SetUp() override {
340 if (AServiceManager_isDeclared(GetParam().c_str())) {
341 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
342 mService = ITuner::fromBinder(binder);
343 } else {
344 mService = nullptr;
345 }
346 ASSERT_NE(mService, nullptr);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000347 ASSERT_TRUE(initConfiguration());
Hongguang600a6ae2021-07-08 18:51:51 -0700348
349 mFrontendTests.setService(mService);
350 mDemuxTests.setService(mService);
351 mFilterTests.setService(mService);
352 mLnbTests.setService(mService);
353 mDvrTests.setService(mService);
354 }
355
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000356 virtual void TearDown() override {
357 clearIds();
358 mService = nullptr;
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000359 }
360
Hongguang600a6ae2021-07-08 18:51:51 -0700361 protected:
362 static void description(const std::string& description) {
363 RecordProperty("description", description);
364 }
365
366 std::shared_ptr<ITuner> mService;
367 FrontendTests mFrontendTests;
368 DemuxTests mDemuxTests;
369 FilterTests mFilterTests;
370 LnbTests mLnbTests;
371 DvrTests mDvrTests;
372
373 AssertionResult filterDataOutputTest();
374
375 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
376 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
377 LnbConfig lnbConf);
378 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
379
380 private:
Frankie Lizcano87421812022-07-28 17:13:01 +0000381 int32_t mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700382};
383
384GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
385
386class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
387 public:
388 virtual void SetUp() override {
389 if (AServiceManager_isDeclared(GetParam().c_str())) {
390 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
391 mService = ITuner::fromBinder(binder);
392 } else {
393 mService = nullptr;
394 }
395 mCasService = IMediaCasService::getService();
396 ASSERT_NE(mService, nullptr);
397 ASSERT_NE(mCasService, nullptr);
398 ASSERT_TRUE(initConfiguration());
399
400 mFrontendTests.setService(mService);
401 mDemuxTests.setService(mService);
402 mDvrTests.setService(mService);
403 mDescramblerTests.setService(mService);
404 mDescramblerTests.setCasService(mCasService);
405 }
406
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000407 virtual void TearDown() override {
408 clearIds();
409 mService = nullptr;
410 }
411
Hongguang600a6ae2021-07-08 18:51:51 -0700412 protected:
413 static void description(const std::string& description) {
414 RecordProperty("description", description);
415 }
416
417 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
418 FrontendConfig frontendConf, DescramblerConfig descConfig);
419 AssertionResult filterDataOutputTest();
420
421 std::shared_ptr<ITuner> mService;
422 android::sp<IMediaCasService> mCasService;
423 FrontendTests mFrontendTests;
424 DemuxTests mDemuxTests;
425 FilterTests mFilterTests;
426 DescramblerTests mDescramblerTests;
427 DvrTests mDvrTests;
428};
429
430GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
431
432} // namespace