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