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