1 /*
2 * Copyright 2020 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 #include "DemuxTests.h"
18 #include "DescramblerTests.h"
19 #include "FrontendTests.h"
20 #include "LnbTests.h"
21
22 using android::hardware::tv::tuner::V1_0::DataFormat;
23 using android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
24 using android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
25 using android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
26 using android::hardware::tv::tuner::V1_0::IDescrambler;
27
success()28 static AssertionResult success() {
29 return ::testing::AssertionSuccess();
30 }
31
32 namespace {
33
initConfiguration()34 bool initConfiguration() {
35 TunerTestingConfigReader1_0::setConfigFilePath(configFilePath);
36 if (!TunerTestingConfigReader1_0::checkConfigFileExists()) {
37 return false;
38 }
39 initFrontendConfig();
40 initFilterConfig();
41 initDvrConfig();
42 initLnbConfig();
43 initTimeFilterConfig();
44 initDescramblerConfig();
45 connectHardwaresToTestCases();
46 if (!validateConnections()) {
47 ALOGW("[vts] failed to validate connections.");
48 return false;
49 }
50 return true;
51 }
52
filterDataOutputTestBase(FilterTests & tests)53 AssertionResult filterDataOutputTestBase(FilterTests& tests) {
54 // Data Verify Module
55 std::map<uint32_t, sp<FilterCallback>>::iterator it;
56 std::map<uint32_t, sp<FilterCallback>> filterCallbacks = tests.getFilterCallbacks();
57 for (it = filterCallbacks.begin(); it != filterCallbacks.end(); it++) {
58 it->second->testFilterDataOutput();
59 }
60 return success();
61 }
62
63 class TunerFrontendHidlTest : public testing::TestWithParam<std::string> {
64 public:
SetUp()65 virtual void SetUp() override {
66 mService = ITuner::getService(GetParam());
67 ASSERT_NE(mService, nullptr);
68 ASSERT_TRUE(initConfiguration());
69
70 mFrontendTests.setService(mService);
71 }
72
73 protected:
description(const std::string & description)74 static void description(const std::string& description) {
75 RecordProperty("description", description);
76 }
77
78 sp<ITuner> mService;
79 FrontendTests mFrontendTests;
80 };
81
82 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendHidlTest);
83
84 class TunerLnbHidlTest : public testing::TestWithParam<std::string> {
85 public:
SetUp()86 virtual void SetUp() override {
87 mService = ITuner::getService(GetParam());
88 ASSERT_NE(mService, nullptr);
89 ASSERT_TRUE(initConfiguration());
90
91 mLnbTests.setService(mService);
92 }
93
94 protected:
description(const std::string & description)95 static void description(const std::string& description) {
96 RecordProperty("description", description);
97 }
98
99 sp<ITuner> mService;
100 LnbTests mLnbTests;
101 };
102
103 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbHidlTest);
104
105 class TunerDemuxHidlTest : public testing::TestWithParam<std::string> {
106 public:
SetUp()107 virtual void SetUp() override {
108 mService = ITuner::getService(GetParam());
109 ASSERT_NE(mService, nullptr);
110 ASSERT_TRUE(initConfiguration());
111
112 mFrontendTests.setService(mService);
113 mDemuxTests.setService(mService);
114 mFilterTests.setService(mService);
115 }
116
117 protected:
description(const std::string & description)118 static void description(const std::string& description) {
119 RecordProperty("description", description);
120 }
121
122 sp<ITuner> mService;
123 FrontendTests mFrontendTests;
124 DemuxTests mDemuxTests;
125 FilterTests mFilterTests;
126 };
127
128 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxHidlTest);
129
130 class TunerFilterHidlTest : public testing::TestWithParam<std::string> {
131 public:
SetUp()132 virtual void SetUp() override {
133 mService = ITuner::getService(GetParam());
134 ASSERT_NE(mService, nullptr);
135 ASSERT_TRUE(initConfiguration());
136
137 mFrontendTests.setService(mService);
138 mDemuxTests.setService(mService);
139 mFilterTests.setService(mService);
140 }
141
142 protected:
description(const std::string & description)143 static void description(const std::string& description) {
144 RecordProperty("description", description);
145 }
146
147 void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
148 void testTimeFilter(TimeFilterConfig filterConf);
149
getLinkageFilterType(int bit)150 DemuxFilterType getLinkageFilterType(int bit) {
151 DemuxFilterType type;
152 type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
153 switch (type.mainType) {
154 case DemuxFilterMainType::TS:
155 type.subType.tsFilterType(DemuxTsFilterType::UNDEFINED);
156 break;
157 case DemuxFilterMainType::MMTP:
158 type.subType.mmtpFilterType(DemuxMmtpFilterType::UNDEFINED);
159 break;
160 case DemuxFilterMainType::IP:
161 type.subType.ipFilterType(DemuxIpFilterType::UNDEFINED);
162 break;
163 case DemuxFilterMainType::TLV:
164 type.subType.tlvFilterType(DemuxTlvFilterType::UNDEFINED);
165 break;
166 case DemuxFilterMainType::ALP:
167 type.subType.alpFilterType(DemuxAlpFilterType::UNDEFINED);
168 break;
169 }
170 return type;
171 }
172
173 sp<ITuner> mService;
174 FrontendTests mFrontendTests;
175 DemuxTests mDemuxTests;
176 FilterTests mFilterTests;
177 };
178
179 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterHidlTest);
180
181 class TunerBroadcastHidlTest : public testing::TestWithParam<std::string> {
182 public:
SetUp()183 virtual void SetUp() override {
184 mService = ITuner::getService(GetParam());
185 ASSERT_NE(mService, nullptr);
186 ASSERT_TRUE(initConfiguration());
187
188 mFrontendTests.setService(mService);
189 mDemuxTests.setService(mService);
190 mFilterTests.setService(mService);
191 mLnbTests.setService(mService);
192 mDvrTests.setService(mService);
193 }
194
195 protected:
description(const std::string & description)196 static void description(const std::string& description) {
197 RecordProperty("description", description);
198 }
199
200 sp<ITuner> mService;
201 FrontendTests mFrontendTests;
202 DemuxTests mDemuxTests;
203 FilterTests mFilterTests;
204 LnbTests mLnbTests;
205 DvrTests mDvrTests;
206
207 AssertionResult filterDataOutputTest();
208
209 void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf);
210 void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
211 LnbConfig lnbConf);
212
213 private:
214 uint32_t* mLnbId = nullptr;
215 };
216
217 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastHidlTest);
218
219 class TunerPlaybackHidlTest : public testing::TestWithParam<std::string> {
220 public:
SetUp()221 virtual void SetUp() override {
222 mService = ITuner::getService(GetParam());
223 ASSERT_NE(mService, nullptr);
224 ASSERT_TRUE(initConfiguration());
225
226 mFrontendTests.setService(mService);
227 mDemuxTests.setService(mService);
228 mFilterTests.setService(mService);
229 mDvrTests.setService(mService);
230 }
231
232 protected:
description(const std::string & description)233 static void description(const std::string& description) {
234 RecordProperty("description", description);
235 }
236
237 sp<ITuner> mService;
238 FrontendTests mFrontendTests;
239 DemuxTests mDemuxTests;
240 FilterTests mFilterTests;
241 DvrTests mDvrTests;
242
243 AssertionResult filterDataOutputTest();
244
245 void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
246 };
247
248 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackHidlTest);
249
250 class TunerRecordHidlTest : public testing::TestWithParam<std::string> {
251 public:
SetUp()252 virtual void SetUp() override {
253 mService = ITuner::getService(GetParam());
254 ASSERT_NE(mService, nullptr);
255 ASSERT_TRUE(initConfiguration());
256
257 mFrontendTests.setService(mService);
258 mDemuxTests.setService(mService);
259 mFilterTests.setService(mService);
260 mDvrTests.setService(mService);
261 mLnbTests.setService(mService);
262 }
263
264 protected:
description(const std::string & description)265 static void description(const std::string& description) {
266 RecordProperty("description", description);
267 }
268
269 void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf,
270 DvrConfig dvrConf);
271 void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
272 DvrConfig dvrConf);
273 void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf,
274 DvrConfig dvrConf, LnbConfig lnbConf);
275
276 sp<ITuner> mService;
277 FrontendTests mFrontendTests;
278 DemuxTests mDemuxTests;
279 FilterTests mFilterTests;
280 DvrTests mDvrTests;
281 LnbTests mLnbTests;
282
283 private:
284 uint32_t* mLnbId = nullptr;
285 };
286
287 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordHidlTest);
288
289 class TunerDescramblerHidlTest : public testing::TestWithParam<std::string> {
290 public:
SetUp()291 virtual void SetUp() override {
292 mService = ITuner::getService(GetParam());
293 mCasService = IMediaCasService::getService();
294 ASSERT_NE(mService, nullptr);
295 ASSERT_NE(mCasService, nullptr);
296 ASSERT_TRUE(initConfiguration());
297
298 mFrontendTests.setService(mService);
299 mDemuxTests.setService(mService);
300 mDvrTests.setService(mService);
301 mDescramblerTests.setService(mService);
302 mDescramblerTests.setCasService(mCasService);
303 }
304
305 protected:
description(const std::string & description)306 static void description(const std::string& description) {
307 RecordProperty("description", description);
308 }
309
310 void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
311 FrontendConfig frontendConf, DescramblerConfig descConfig);
312 AssertionResult filterDataOutputTest();
313
314 sp<ITuner> mService;
315 sp<IMediaCasService> mCasService;
316 FrontendTests mFrontendTests;
317 DemuxTests mDemuxTests;
318 FilterTests mFilterTests;
319 DescramblerTests mDescramblerTests;
320 DvrTests mDvrTests;
321 };
322
323 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerHidlTest);
324 } // namespace
325