1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DEMUXER_PLUGIN_MANAGER_UNIT_TEST_H 17 #define DEMUXER_PLUGIN_MANAGER_UNIT_TEST_H 18 #include "mock/mock_base_stream_demuxer.h" 19 #include "gtest/gtest.h" 20 #include "demuxer_plugin_manager.h" 21 #include "stream_demuxer.h" 22 #include "plugin/plugin_manager_v2.h" 23 24 namespace OHOS { 25 namespace Media { 26 class DemuxerPluginManagerUnitTest : public testing::Test { 27 public: 28 // SetUpTestCase: Called before all test cases 29 static void SetUpTestCase(void); 30 // TearDownTestCase: Called after all test case 31 static void TearDownTestCase(void); 32 // SetUp: Called before each test cases 33 void SetUp(void); 34 // TearDown: Called after each test cases 35 void TearDown(void); 36 37 protected: 38 std::shared_ptr<DemuxerPluginManager> demuxerPluginManager_{ nullptr }; 39 std::shared_ptr<DataSourceImpl> dataSourceImpl_{ nullptr }; 40 std::shared_ptr<MockBaseStreamDemuxer> streamDemuxer_{ nullptr }; 41 42 private: 43 bool CreateDataSource(const std::string& filePath); 44 bool CreateDemuxerPluginByName(const std::string& typeName, const std::string& filePath, int probSize); 45 bool PluginSelectTracks(); 46 bool PluginReadSample(uint32_t idx, uint32_t& flag); 47 void CountFrames(uint32_t index, uint32_t flag); 48 void SetEosValue(); 49 bool isEOS(std::map<uint32_t, bool>& countFlag); 50 void RemoveValue(); 51 bool ResultAssert(uint32_t frames0, uint32_t frames1, uint32_t keyFrames0, uint32_t keyFrames1); 52 bool PluginReadAllSample(); 53 54 int streamId_ = 0; 55 std::map<uint32_t, uint32_t> frames_; 56 std::map<uint32_t, uint32_t> keyFrames_; 57 std::map<uint32_t, bool> eosFlag_; 58 std::vector<uint32_t> selectedTrackIds_; 59 std::vector<uint8_t> buffer_; 60 61 std::shared_ptr<Media::StreamDemuxer> realStreamDemuxer_{ nullptr }; 62 std::shared_ptr<Media::MediaSource> mediaSource_{ nullptr }; 63 std::shared_ptr<Media::Source> realSource_{ nullptr }; 64 std::shared_ptr<Media::PluginBase> pluginBase_{ nullptr }; 65 }; 66 } // namespace Media 67 } // namespace OHOS 68 #endif