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 | } |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | static AssertionResult success() { |
| 52 | return ::testing::AssertionSuccess(); |
| 53 | } |
| 54 | |
| 55 | AssertionResult 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 | |
| 65 | class 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 | |
| 89 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerLnbAidlTest); |
| 90 | |
| 91 | class 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 | |
| 119 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDemuxAidlTest); |
| 120 | |
| 121 | class 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 Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 147 | void testDelayHint(const FilterConfig& filterConf); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 148 | |
| 149 | DemuxFilterType getLinkageFilterType(int bit) { |
| 150 | DemuxFilterType type; |
| 151 | type.mainType = static_cast<DemuxFilterMainType>(1 << bit); |
| 152 | switch (type.mainType) { |
| 153 | case DemuxFilterMainType::TS: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 154 | type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 155 | DemuxTsFilterType::UNDEFINED); |
| 156 | break; |
| 157 | case DemuxFilterMainType::MMTP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 158 | type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 159 | DemuxMmtpFilterType::UNDEFINED); |
| 160 | break; |
| 161 | case DemuxFilterMainType::IP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 162 | type.subType.set<DemuxFilterSubType::Tag::ipFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 163 | DemuxIpFilterType::UNDEFINED); |
| 164 | break; |
| 165 | case DemuxFilterMainType::TLV: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 166 | type.subType.set<DemuxFilterSubType::Tag::tlvFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 167 | DemuxTlvFilterType::UNDEFINED); |
| 168 | break; |
| 169 | case DemuxFilterMainType::ALP: |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 170 | type.subType.set<DemuxFilterSubType::Tag::alpFilterType>( |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 171 | 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 | |
| 184 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFilterAidlTest); |
| 185 | |
| 186 | class 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 | |
| 220 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest); |
| 221 | |
| 222 | class 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 | |
| 264 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerRecordAidlTest); |
| 265 | |
| 266 | class 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 | |
| 290 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerFrontendAidlTest); |
| 291 | |
| 292 | class 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 | |
| 334 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerBroadcastAidlTest); |
| 335 | |
| 336 | class 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 | |
| 375 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest); |
| 376 | |
| 377 | } // namespace |