blob: 34aaad92ece5f0beaa4f4c4cfa0e0f43e1bb2d72 [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();
Hongguang600a6ae2021-07-08 18:51:51 -070041 connectHardwaresToTestCases();
42 if (!validateConnections()) {
43 ALOGW("[vts] failed to validate connections.");
44 return false;
45 }
46 return true;
47}
48
49static AssertionResult success() {
50 return ::testing::AssertionSuccess();
51}
52
53AssertionResult filterDataOutputTestBase(FilterTests& tests) {
54 // Data Verify Module
55 std::map<int64_t, std::shared_ptr<FilterCallback>>::iterator it;
56 std::map<int64_t, std::shared_ptr<FilterCallback>> filterCallbacks = tests.getFilterCallbacks();
57 for (it = filterCallbacks.begin(); it != filterCallbacks.end(); it++) {
58 it->second->testFilterDataOutput();
59 }
60 return success();
61}
62
63class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
64 public:
65 virtual void SetUp() override {
66 if (AServiceManager_isDeclared(GetParam().c_str())) {
67 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
68 mService = ITuner::fromBinder(binder);
69 } else {
70 mService = nullptr;
71 }
72 ASSERT_NE(mService, nullptr);
73 ASSERT_TRUE(initConfiguration());
74
75 mLnbTests.setService(mService);
76 }
77
78 protected:
79 static void description(const std::string& description) {
80 RecordProperty("description", description);
81 }
82
83 std::shared_ptr<ITuner> mService;
84 LnbTests mLnbTests;
85};
86
87GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest);
88
89class TunerDemuxAidlTest : public testing::TestWithParam<std::string> {
90 public:
91 virtual void SetUp() override {
92 if (AServiceManager_isDeclared(GetParam().c_str())) {
93 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
94 mService = ITuner::fromBinder(binder);
95 } else {
96 mService = nullptr;
97 }
98 ASSERT_NE(mService, nullptr);
99 ASSERT_TRUE(initConfiguration());
100
101 mFrontendTests.setService(mService);
102 mDemuxTests.setService(mService);
103 mFilterTests.setService(mService);
104 }
105
106 protected:
107 static void description(const std::string& description) {
108 RecordProperty("description", description);
109 }
110
111 std::shared_ptr<ITuner> mService;
112 FrontendTests mFrontendTests;
113 DemuxTests mDemuxTests;
114 FilterTests mFilterTests;
115};
116
117GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest);
118
119class TunerFilterAidlTest : public testing::TestWithParam<std::string> {
120 public:
121 virtual void SetUp() override {
122 if (AServiceManager_isDeclared(GetParam().c_str())) {
123 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
124 mService = ITuner::fromBinder(binder);
125 } else {
126 mService = nullptr;
127 }
128 ASSERT_NE(mService, nullptr);
129 initConfiguration();
130
131 mFrontendTests.setService(mService);
132 mDemuxTests.setService(mService);
133 mFilterTests.setService(mService);
134 }
135
136 protected:
137 static void description(const std::string& description) {
138 RecordProperty("description", description);
139 }
140
141 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
142 void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
143 FrontendConfig frontendConf);
144 void testTimeFilter(TimeFilterConfig filterConf);
Patrick Rohr1586d212021-11-23 00:40:56 +0100145 void testDelayHint(const FilterConfig& filterConf);
Hongguang600a6ae2021-07-08 18:51:51 -0700146
147 DemuxFilterType getLinkageFilterType(int bit) {
148 DemuxFilterType type;
149 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
150 switch (type.mainType) {
151 case DemuxFilterMainType::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700152 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700153 DemuxTsFilterType::UNDEFINED);
154 break;
155 case DemuxFilterMainType::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700156 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700157 DemuxMmtpFilterType::UNDEFINED);
158 break;
159 case DemuxFilterMainType::IP:
Hongguangce1e30d2021-08-02 21:55:44 -0700160 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700161 DemuxIpFilterType::UNDEFINED);
162 break;
163 case DemuxFilterMainType::TLV:
Hongguangce1e30d2021-08-02 21:55:44 -0700164 type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700165 DemuxTlvFilterType::UNDEFINED);
166 break;
167 case DemuxFilterMainType::ALP:
Hongguangce1e30d2021-08-02 21:55:44 -0700168 type.subType.set<DemuxFilterSubType::Tag::alpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700169 DemuxAlpFilterType::UNDEFINED);
170 break;
171 default:
172 break;
173 }
174 return type;
175 }
176 std::shared_ptr<ITuner> mService;
177 FrontendTests mFrontendTests;
178 DemuxTests mDemuxTests;
179 FilterTests mFilterTests;
180};
181
182GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest);
183
184class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
185 public:
186 virtual void SetUp() override {
187 if (AServiceManager_isDeclared(GetParam().c_str())) {
188 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
189 mService = ITuner::fromBinder(binder);
190 } else {
191 mService = nullptr;
192 }
193 ASSERT_NE(mService, nullptr);
194 ASSERT_TRUE(initConfiguration());
195
196 mFrontendTests.setService(mService);
197 mDemuxTests.setService(mService);
198 mFilterTests.setService(mService);
199 mDvrTests.setService(mService);
200 }
201
202 protected:
203 static void description(const std::string& description) {
204 RecordProperty("description", description);
205 }
206
207 std::shared_ptr<ITuner> mService;
208 FrontendTests mFrontendTests;
209 DemuxTests mDemuxTests;
210 FilterTests mFilterTests;
211 DvrTests mDvrTests;
212
213 AssertionResult filterDataOutputTest();
214
215 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
216};
217
218GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
219
220class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
221 public:
222 virtual void SetUp() override {
223 if (AServiceManager_isDeclared(GetParam().c_str())) {
224 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
225 mService = ITuner::fromBinder(binder);
226 } else {
227 mService = nullptr;
228 }
229 ASSERT_NE(mService, nullptr);
230 initConfiguration();
231
232 mFrontendTests.setService(mService);
233 mDemuxTests.setService(mService);
234 mFilterTests.setService(mService);
235 mDvrTests.setService(mService);
236 mLnbTests.setService(mService);
237 }
238
239 protected:
240 static void description(const std::string& description) {
241 RecordProperty("description", description);
242 }
243
244 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
245 DvrConfig dvrConf);
246 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
247 DvrConfig dvrConf, LnbConfig lnbConf);
248 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
249 DvrConfig dvrConf);
250
251 std::shared_ptr<ITuner> mService;
252 FrontendTests mFrontendTests;
253 DemuxTests mDemuxTests;
254 FilterTests mFilterTests;
255 DvrTests mDvrTests;
256 LnbTests mLnbTests;
257
258 private:
259 int32_t* mLnbId = nullptr;
260};
261
262GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest);
263
264class TunerFrontendAidlTest : public testing::TestWithParam<std::string> {
265 public:
266 virtual void SetUp() override {
267 if (AServiceManager_isDeclared(GetParam().c_str())) {
268 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
269 mService = ITuner::fromBinder(binder);
270 } else {
271 mService = nullptr;
272 }
273 ASSERT_NE(mService, nullptr);
274 initConfiguration();
275
276 mFrontendTests.setService(mService);
277 }
278
279 protected:
280 static void description(const std::string& description) {
281 RecordProperty("description", description);
282 }
283
284 std::shared_ptr<ITuner> mService;
285 FrontendTests mFrontendTests;
286};
287
288GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest);
289
290class TunerBroadcastAidlTest : public testing::TestWithParam<std::string> {
291 public:
292 virtual void SetUp() override {
293 if (AServiceManager_isDeclared(GetParam().c_str())) {
294 ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
295 mService = ITuner::fromBinder(binder);
296 } else {
297 mService = nullptr;
298 }
299 ASSERT_NE(mService, nullptr);
300 initConfiguration();
301
302 mFrontendTests.setService(mService);
303 mDemuxTests.setService(mService);
304 mFilterTests.setService(mService);
305 mLnbTests.setService(mService);
306 mDvrTests.setService(mService);
307 }
308
309 protected:
310 static void description(const std::string& description) {
311 RecordProperty("description", description);
312 }
313
314 std::shared_ptr<ITuner> mService;
315 FrontendTests mFrontendTests;
316 DemuxTests mDemuxTests;
317 FilterTests mFilterTests;
318 LnbTests mLnbTests;
319 DvrTests mDvrTests;
320
321 AssertionResult filterDataOutputTest();
322
323 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
324 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
325 LnbConfig lnbConf);
326 void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf);
327
328 private:
329 int32_t* mLnbId = nullptr;
330};
331
332GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest);
333
334class TunerDescramblerAidlTest : 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 mCasService = IMediaCasService::getService();
344 ASSERT_NE(mService, nullptr);
345 ASSERT_NE(mCasService, nullptr);
346 ASSERT_TRUE(initConfiguration());
347
348 mFrontendTests.setService(mService);
349 mDemuxTests.setService(mService);
350 mDvrTests.setService(mService);
351 mDescramblerTests.setService(mService);
352 mDescramblerTests.setCasService(mCasService);
353 }
354
355 protected:
356 static void description(const std::string& description) {
357 RecordProperty("description", description);
358 }
359
360 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
361 FrontendConfig frontendConf, DescramblerConfig descConfig);
362 AssertionResult filterDataOutputTest();
363
364 std::shared_ptr<ITuner> mService;
365 android::sp<IMediaCasService> mCasService;
366 FrontendTests mFrontendTests;
367 DemuxTests mDemuxTests;
368 FilterTests mFilterTests;
369 DescramblerTests mDescramblerTests;
370 DvrTests mDvrTests;
371};
372
373GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
374
375} // namespace