Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | using android::sp; |
| 28 | |
| 29 | namespace { |
| 30 | |
| 31 | bool initConfiguration() { |
| 32 | TunerTestingConfigAidlReader1_0::setConfigFilePath(configFilePath); |
| 33 | if (!TunerTestingConfigAidlReader1_0::checkConfigFileExists()) { |
| 34 | return false; |
| 35 | } |
| 36 | initFrontendConfig(); |
| 37 | initFilterConfig(); |
| 38 | initDvrConfig(); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 39 | initTimeFilterConfig(); |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 40 | initDescramblerConfig(); |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 41 | initLnbConfig(); |
| 42 | initDiseqcMsgsConfig(); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 43 | connectHardwaresToTestCases(); |
| 44 | if (!validateConnections()) { |
| 45 | ALOGW("[vts] failed to validate connections."); |
| 46 | return false; |
| 47 | } |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 48 | determineDataFlows(); |
| 49 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 50 | return true; |
| 51 | } |
| 52 | |
| 53 | static AssertionResult success() { |
| 54 | return ::testing::AssertionSuccess(); |
| 55 | } |
| 56 | |
| 57 | AssertionResult 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 Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 67 | void clearIds() { |
| 68 | recordDvrIds.clear(); |
| 69 | audioFilterIds.clear(); |
| 70 | videoFilterIds.clear(); |
| 71 | playbackDvrIds.clear(); |
| 72 | recordFilterIds.clear(); |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame^] | 73 | sectionFilterIds.clear(); |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 76 | class TunerLnbAidlTest : public testing::TestWithParam<std::string> { |
| 77 | public: |
| 78 | virtual void SetUp() override { |
| 79 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 80 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 81 | mService = ITuner::fromBinder(binder); |
| 82 | } else { |
| 83 | mService = nullptr; |
| 84 | } |
| 85 | ASSERT_NE(mService, nullptr); |
| 86 | ASSERT_TRUE(initConfiguration()); |
| 87 | |
| 88 | mLnbTests.setService(mService); |
| 89 | } |
| 90 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 91 | virtual void TearDown() override { |
| 92 | clearIds(); |
| 93 | mService = nullptr; |
| 94 | } |
| 95 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 96 | protected: |
| 97 | static void description(const std::string& description) { |
| 98 | RecordProperty("description", description); |
| 99 | } |
| 100 | |
| 101 | std::shared_ptr<ITuner> mService; |
| 102 | LnbTests mLnbTests; |
| 103 | }; |
| 104 | |
| 105 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest); |
| 106 | |
| 107 | class TunerDemuxAidlTest : public testing::TestWithParam<std::string> { |
| 108 | public: |
| 109 | virtual void SetUp() override { |
| 110 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 111 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 112 | mService = ITuner::fromBinder(binder); |
| 113 | } else { |
| 114 | mService = nullptr; |
| 115 | } |
| 116 | ASSERT_NE(mService, nullptr); |
| 117 | ASSERT_TRUE(initConfiguration()); |
| 118 | |
| 119 | mFrontendTests.setService(mService); |
| 120 | mDemuxTests.setService(mService); |
| 121 | mFilterTests.setService(mService); |
| 122 | } |
| 123 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 124 | virtual void TearDown() override { |
| 125 | clearIds(); |
| 126 | mService = nullptr; |
| 127 | } |
| 128 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 129 | protected: |
| 130 | static void description(const std::string& description) { |
| 131 | RecordProperty("description", description); |
| 132 | } |
| 133 | |
| 134 | std::shared_ptr<ITuner> mService; |
| 135 | FrontendTests mFrontendTests; |
| 136 | DemuxTests mDemuxTests; |
| 137 | FilterTests mFilterTests; |
| 138 | }; |
| 139 | |
| 140 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest); |
| 141 | |
| 142 | class TunerFilterAidlTest : public testing::TestWithParam<std::string> { |
| 143 | public: |
| 144 | virtual void SetUp() override { |
| 145 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 146 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 147 | mService = ITuner::fromBinder(binder); |
| 148 | } else { |
| 149 | mService = nullptr; |
| 150 | } |
| 151 | ASSERT_NE(mService, nullptr); |
| 152 | initConfiguration(); |
| 153 | |
| 154 | mFrontendTests.setService(mService); |
| 155 | mDemuxTests.setService(mService); |
| 156 | mFilterTests.setService(mService); |
| 157 | } |
| 158 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 159 | virtual void TearDown() override { |
| 160 | clearIds(); |
| 161 | mService = nullptr; |
| 162 | } |
| 163 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 164 | protected: |
| 165 | static void description(const std::string& description) { |
| 166 | RecordProperty("description", description); |
| 167 | } |
| 168 | |
| 169 | void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf); |
| 170 | void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf, |
| 171 | FrontendConfig frontendConf); |
| 172 | void testTimeFilter(TimeFilterConfig filterConf); |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 173 | void testDelayHint(const FilterConfig& filterConf); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 174 | |
| 175 | DemuxFilterType getLinkageFilterType(int bit) { |
| 176 | DemuxFilterType type; |
| 177 | type.mainType = static_cast<DemuxFilterMainType>(1 << bit); |
| 178 | switch (type.mainType) { |
| 179 | case DemuxFilterMainType::TS: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 180 | type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 181 | DemuxTsFilterType::UNDEFINED); |
| 182 | break; |
| 183 | case DemuxFilterMainType::MMTP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 184 | type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 185 | DemuxMmtpFilterType::UNDEFINED); |
| 186 | break; |
| 187 | case DemuxFilterMainType::IP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 188 | type.subType.set<DemuxFilterSubType::Tag::ipFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 189 | DemuxIpFilterType::UNDEFINED); |
| 190 | break; |
| 191 | case DemuxFilterMainType::TLV: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 192 | type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 193 | DemuxTlvFilterType::UNDEFINED); |
| 194 | break; |
| 195 | case DemuxFilterMainType::ALP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 196 | type.subType.set<DemuxFilterSubType::Tag::alpFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 197 | DemuxAlpFilterType::UNDEFINED); |
| 198 | break; |
| 199 | default: |
| 200 | break; |
| 201 | } |
| 202 | return type; |
| 203 | } |
| 204 | std::shared_ptr<ITuner> mService; |
| 205 | FrontendTests mFrontendTests; |
| 206 | DemuxTests mDemuxTests; |
| 207 | FilterTests mFilterTests; |
| 208 | }; |
| 209 | |
| 210 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest); |
| 211 | |
| 212 | class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> { |
| 213 | public: |
| 214 | virtual void SetUp() override { |
| 215 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 216 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 217 | mService = ITuner::fromBinder(binder); |
| 218 | } else { |
| 219 | mService = nullptr; |
| 220 | } |
| 221 | ASSERT_NE(mService, nullptr); |
| 222 | ASSERT_TRUE(initConfiguration()); |
| 223 | |
| 224 | mFrontendTests.setService(mService); |
| 225 | mDemuxTests.setService(mService); |
| 226 | mFilterTests.setService(mService); |
| 227 | mDvrTests.setService(mService); |
| 228 | } |
| 229 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 230 | virtual void TearDown() override { |
| 231 | clearIds(); |
| 232 | mService = nullptr; |
| 233 | } |
| 234 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 235 | protected: |
| 236 | static void description(const std::string& description) { |
| 237 | RecordProperty("description", description); |
| 238 | } |
| 239 | |
| 240 | std::shared_ptr<ITuner> mService; |
| 241 | FrontendTests mFrontendTests; |
| 242 | DemuxTests mDemuxTests; |
| 243 | FilterTests mFilterTests; |
| 244 | DvrTests mDvrTests; |
| 245 | |
| 246 | AssertionResult filterDataOutputTest(); |
| 247 | |
| 248 | void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf); |
| 249 | }; |
| 250 | |
| 251 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest); |
| 252 | |
| 253 | class TunerRecordAidlTest : public testing::TestWithParam<std::string> { |
| 254 | public: |
| 255 | virtual void SetUp() override { |
| 256 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 257 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 258 | mService = ITuner::fromBinder(binder); |
| 259 | } else { |
| 260 | mService = nullptr; |
| 261 | } |
| 262 | ASSERT_NE(mService, nullptr); |
| 263 | initConfiguration(); |
| 264 | |
| 265 | mFrontendTests.setService(mService); |
| 266 | mDemuxTests.setService(mService); |
| 267 | mFilterTests.setService(mService); |
| 268 | mDvrTests.setService(mService); |
| 269 | mLnbTests.setService(mService); |
| 270 | } |
| 271 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 272 | virtual void TearDown() override { |
| 273 | clearIds(); |
| 274 | mService = nullptr; |
| 275 | mLnbId = nullptr; |
| 276 | } |
| 277 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 278 | protected: |
| 279 | static void description(const std::string& description) { |
| 280 | RecordProperty("description", description); |
| 281 | } |
| 282 | |
| 283 | void attachSingleFilterToRecordDvrTest(FilterConfig filterConf, FrontendConfig frontendConf, |
| 284 | DvrConfig dvrConf); |
| 285 | void recordSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf, |
| 286 | DvrConfig dvrConf, LnbConfig lnbConf); |
| 287 | void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf, |
| 288 | DvrConfig dvrConf); |
| 289 | |
| 290 | std::shared_ptr<ITuner> mService; |
| 291 | FrontendTests mFrontendTests; |
| 292 | DemuxTests mDemuxTests; |
| 293 | FilterTests mFilterTests; |
| 294 | DvrTests mDvrTests; |
| 295 | LnbTests mLnbTests; |
| 296 | |
| 297 | private: |
| 298 | int32_t* mLnbId = nullptr; |
| 299 | }; |
| 300 | |
| 301 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest); |
| 302 | |
| 303 | class TunerFrontendAidlTest : public testing::TestWithParam<std::string> { |
| 304 | public: |
| 305 | virtual void SetUp() override { |
| 306 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 307 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 308 | mService = ITuner::fromBinder(binder); |
| 309 | } else { |
| 310 | mService = nullptr; |
| 311 | } |
| 312 | ASSERT_NE(mService, nullptr); |
| 313 | initConfiguration(); |
| 314 | |
| 315 | mFrontendTests.setService(mService); |
| 316 | } |
| 317 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 318 | virtual void TearDown() override { |
| 319 | clearIds(); |
| 320 | mService = nullptr; |
| 321 | } |
| 322 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 323 | protected: |
| 324 | static void description(const std::string& description) { |
| 325 | RecordProperty("description", description); |
| 326 | } |
| 327 | |
| 328 | std::shared_ptr<ITuner> mService; |
| 329 | FrontendTests mFrontendTests; |
| 330 | }; |
| 331 | |
| 332 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest); |
| 333 | |
| 334 | class TunerBroadcastAidlTest : 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 | ASSERT_NE(mService, nullptr); |
| 344 | initConfiguration(); |
| 345 | |
| 346 | mFrontendTests.setService(mService); |
| 347 | mDemuxTests.setService(mService); |
| 348 | mFilterTests.setService(mService); |
| 349 | mLnbTests.setService(mService); |
| 350 | mDvrTests.setService(mService); |
| 351 | } |
| 352 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 353 | virtual void TearDown() override { |
| 354 | clearIds(); |
| 355 | mService = nullptr; |
| 356 | mLnbId = nullptr; |
| 357 | } |
| 358 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 359 | protected: |
| 360 | static void description(const std::string& description) { |
| 361 | RecordProperty("description", description); |
| 362 | } |
| 363 | |
| 364 | std::shared_ptr<ITuner> mService; |
| 365 | FrontendTests mFrontendTests; |
| 366 | DemuxTests mDemuxTests; |
| 367 | FilterTests mFilterTests; |
| 368 | LnbTests mLnbTests; |
| 369 | DvrTests mDvrTests; |
| 370 | |
| 371 | AssertionResult filterDataOutputTest(); |
| 372 | |
| 373 | void broadcastSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf); |
| 374 | void broadcastSingleFilterTestWithLnb(FilterConfig filterConf, FrontendConfig frontendConf, |
| 375 | LnbConfig lnbConf); |
| 376 | void mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, FrontendConfig frontendConf); |
| 377 | |
| 378 | private: |
| 379 | int32_t* mLnbId = nullptr; |
| 380 | }; |
| 381 | |
| 382 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest); |
| 383 | |
| 384 | class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> { |
| 385 | public: |
| 386 | virtual void SetUp() override { |
| 387 | if (AServiceManager_isDeclared(GetParam().c_str())) { |
| 388 | ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); |
| 389 | mService = ITuner::fromBinder(binder); |
| 390 | } else { |
| 391 | mService = nullptr; |
| 392 | } |
| 393 | mCasService = IMediaCasService::getService(); |
| 394 | ASSERT_NE(mService, nullptr); |
| 395 | ASSERT_NE(mCasService, nullptr); |
| 396 | ASSERT_TRUE(initConfiguration()); |
| 397 | |
| 398 | mFrontendTests.setService(mService); |
| 399 | mDemuxTests.setService(mService); |
| 400 | mDvrTests.setService(mService); |
| 401 | mDescramblerTests.setService(mService); |
| 402 | mDescramblerTests.setCasService(mCasService); |
| 403 | } |
| 404 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 405 | virtual void TearDown() override { |
| 406 | clearIds(); |
| 407 | mService = nullptr; |
| 408 | } |
| 409 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 410 | protected: |
| 411 | static void description(const std::string& description) { |
| 412 | RecordProperty("description", description); |
| 413 | } |
| 414 | |
| 415 | void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs, |
| 416 | FrontendConfig frontendConf, DescramblerConfig descConfig); |
| 417 | AssertionResult filterDataOutputTest(); |
| 418 | |
| 419 | std::shared_ptr<ITuner> mService; |
| 420 | android::sp<IMediaCasService> mCasService; |
| 421 | FrontendTests mFrontendTests; |
| 422 | DemuxTests mDemuxTests; |
| 423 | FilterTests mFilterTests; |
| 424 | DescramblerTests mDescramblerTests; |
| 425 | DvrTests mDvrTests; |
| 426 | }; |
| 427 | |
| 428 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest); |
| 429 | |
| 430 | } // namespace |