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