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