blob: d6b852f62a51f192cee2177bc239f0d7ff4ddaeb [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();
72 audioFilterIds.clear();
73 videoFilterIds.clear();
74 playbackDvrIds.clear();
75 recordFilterIds.clear();
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000076 sectionFilterIds.clear();
Frankie Lizcano5b29f502022-07-06 22:09:42 +000077}
78
Hongguang600a6ae2021-07-08 18:51:51 -070079class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
80 public:
81 virtual void SetUp() override {
82 if (AServiceManager_isDeclared(GetParam().c_str())) {
83 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
84 mService = ITuner::fromBinder(binder);
85 } else {
86 mService = nullptr;
87 }
88 ASSERT_NE(mService, nullptr);
89 ASSERT_TRUE(initConfiguration());
90
91 mLnbTests.setService(mService);
92 }
93
Frankie Lizcano5b29f502022-07-06 22:09:42 +000094 virtual void TearDown() override {
95 clearIds();
96 mService = nullptr;
97 }
98
Hongguang600a6ae2021-07-08 18:51:51 -070099 protected:
100 static void description(const std::string& description) {
101 RecordProperty("description", description);
102 }
103
104 std::shared_ptr<ITuner> mService;
105 LnbTests mLnbTests;
106};
107
108GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
109
110class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
111 public:
112 virtual void SetUp() override {
113 if (AServiceManager_isDeclared(GetParam().c_str())) {
114 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
115 mService = ITuner::fromBinder(binder);
116 } else {
117 mService = nullptr;
118 }
119 ASSERT_NE(mService, nullptr);
120 ASSERT_TRUE(initConfiguration());
121
122 mFrontendTests.setService(mService);
123 mDemuxTests.setService(mService);
124 mFilterTests.setService(mService);
125 }
126
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000127 virtual void TearDown() override {
128 clearIds();
129 mService = nullptr;
130 }
131
Hongguang600a6ae2021-07-08 18:51:51 -0700132 protected:
133 static void description(const std::string& description) {
134 RecordProperty("description", description);
135 }
136
137 std::shared_ptr<ITuner> mService;
138 FrontendTests mFrontendTests;
139 DemuxTests mDemuxTests;
140 FilterTests mFilterTests;
141};
142
143GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
144
145class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
146 public:
147 virtual void SetUp() override {
148 if (AServiceManager_isDeclared(GetParam().c_str())) {
149 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
150 mService = ITuner::fromBinder(binder);
151 } else {
152 mService = nullptr;
153 }
154 ASSERT_NE(mService, nullptr);
155 initConfiguration();
156
157 mFrontendTests.setService(mService);
158 mDemuxTests.setService(mService);
159 mFilterTests.setService(mService);
160 }
161
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000162 virtual void TearDown() override {
163 clearIds();
164 mService = nullptr;
165 }
166
Hongguang600a6ae2021-07-08 18:51:51 -0700167 protected:
168 static void description(const std::string& description) {
169 RecordProperty("description", description);
170 }
171
172 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
173 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
174 FrontendConfig frontendConf);
175 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100176 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700177
178 DemuxFilterType getLinkageFilterType(int bit) {
179 DemuxFilterType type;
180 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
181 switch (type.mainType) {
182 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700183 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700184 DemuxTsFilterType::UNDEFINED);
185 break;
186 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700187 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700188 DemuxMmtpFilterType::UNDEFINED);
189 break;
190 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700191 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700192 DemuxIpFilterType::UNDEFINED);
193 break;
194 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700195 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700196 DemuxTlvFilterType::UNDEFINED);
197 break;
198 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700199 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700200 DemuxAlpFilterType::UNDEFINED);
201 break;
202 default:
203 break;
204 }
205 return type;
206 }
207 std::shared_ptr<ITuner> mService;
208 FrontendTests mFrontendTests;
209 DemuxTests mDemuxTests;
210 FilterTests mFilterTests;
211};
212
213GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
214
215class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
216 public:
217 virtual void SetUp() override {
218 if (AServiceManager_isDeclared(GetParam().c_str())) {
219 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
220 mService = ITuner::fromBinder(binder);
221 } else {
222 mService = nullptr;
223 }
224 ASSERT_NE(mService, nullptr);
225 ASSERT_TRUE(initConfiguration());
226
227 mFrontendTests.setService(mService);
228 mDemuxTests.setService(mService);
229 mFilterTests.setService(mService);
230 mDvrTests.setService(mService);
231 }
232
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000233 virtual void TearDown() override {
234 clearIds();
235 mService = nullptr;
236 }
237
Hongguang600a6ae2021-07-08 18:51:51 -0700238 protected:
239 static void description(const std::string& description) {
240 RecordProperty("description", description);
241 }
242
243 std::shared_ptr<ITuner> mService;
244 FrontendTests mFrontendTests;
245 DemuxTests mDemuxTests;
246 FilterTests mFilterTests;
247 DvrTests mDvrTests;
248
249 AssertionResult filterDataOutputTest();
250
251 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
252};
253
254GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
255
256class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
257 public:
258 virtual void SetUp() override {
259 if (AServiceManager_isDeclared(GetParam().c_str())) {
260 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
261 mService = ITuner::fromBinder(binder);
262 } else {
263 mService = nullptr;
264 }
265 ASSERT_NE(mService, nullptr);
266 initConfiguration();
267
268 mFrontendTests.setService(mService);
269 mDemuxTests.setService(mService);
270 mFilterTests.setService(mService);
271 mDvrTests.setService(mService);
272 mLnbTests.setService(mService);
273 }
274
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000275 virtual void TearDown() override {
276 clearIds();
277 mService = nullptr;
278 mLnbId = nullptr;
279 }
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:
301 int32_t* mLnbId = nullptr;
302};
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);
316 initConfiguration();
317
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);
347 initConfiguration();
348
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;
359 mLnbId = nullptr;
360 }
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:
382 int32_t* mLnbId = nullptr;
383};
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