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 #include <thread> 17 #include "gtest/gtest.h" 18 #include "avcodec_xcollie.h" 19 #include "avcodec_errors.h" 20 21 using namespace testing::ext; 22 using namespace OHOS::MediaAVCodec; 23 24 namespace { 25 constexpr uint32_t SLEEP_TIME = 1'000'000; // 1s 26 } 27 28 namespace OHOS::MediaAVCodec { 29 class XCollieTestSuilt : public testing::Test { 30 public: SetUpTestCase(void)31 static void SetUpTestCase(void) {}; TearDownTestCase(void)32 static void TearDownTestCase(void) {}; SetUp(void)33 void SetUp(void) {}; TearDown(void)34 void TearDown(void) {}; 35 }; 36 37 HWTEST_F(XCollieTestSuilt, INTERFACE_TEST, TestSize.Level1) 38 { 39 COLLIE_LISTEN(usleep(SLEEP_TIME), "CollieTest", true, false, 5); 40 CLIENT_COLLIE_LISTEN(usleep(SLEEP_TIME), "CollieTest"); 41 } 42 43 HWTEST_F(XCollieTestSuilt, DUMP_TEST, TestSize.Level1) 44 { 45 // Test for no dumper 46 int32_t ret = AVCodecXCollie::GetInstance().Dump(0); 47 ASSERT_EQ(ret, AVCS_ERR_OK); 48 49 std::thread task([] COLLIE_LISTEN(usleep(SLEEP_TIME), "CollieTest", true, false, 5)); 50 usleep(20'000); // 20'000: 20ms 51 ret = AVCodecXCollie::GetInstance().Dump(0); 52 ASSERT_EQ(ret, AVCS_ERR_OK); 53 54 if (task.joinable()) { 55 task.join(); 56 } 57 } 58 }