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