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