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 <memory>
17 #include <iostream>
18 #include "gtest/gtest.h"
19 #include "avcodec_sysevent.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Media {
25 using namespace OHOS::MediaAVCodec;
26 class MediaDfxTest : public testing::Test {
27 public:
SetUpTestCase(void)28     static void SetUpTestCase(void) {};
TearDownTestCase(void)29     static void TearDownTestCase(void) {};
SetUp(void)30     void SetUp(void) {};
TearDown(void)31     void TearDown(void) {};
32 };
33 
34 HWTEST_F(MediaDfxTest, FAULT_DEMUXER_EVENT, TestSize.Level1)
35 {
36     DemuxerFaultInfo dmuxerDfxInfo;
37     dmuxerDfxInfo.appName = "appName";
38     dmuxerDfxInfo.instanceId = "1";
39     dmuxerDfxInfo.callerType = "player_framework";
40     dmuxerDfxInfo.sourceType = 1;
41     dmuxerDfxInfo.containerFormat = "video/mp4v-es;audio/mp4a-latm";
42     dmuxerDfxInfo.streamType = "streamType";
43     dmuxerDfxInfo.errMsg = "errorMessage";
44     FaultDemuxerEventWrite(dmuxerDfxInfo);
45 }
46 
47 HWTEST_F(MediaDfxTest, FAULT_MUXER_EVENT, TestSize.Level1)
48 {
49     MuxerFaultInfo muxerFaultInfo;
50     muxerFaultInfo.appName = "appName";
51     muxerFaultInfo.instanceId = "1";
52     muxerFaultInfo.callerType = "player_framework";
53     muxerFaultInfo.videoCodec = "video/mp4v-es";
54     muxerFaultInfo.audioCodec = "audio/mp4a-latm";
55     muxerFaultInfo.containerFormat = "video/mp4v-es;audio/mp4a-latm";
56     muxerFaultInfo.errMsg = "errorMessage";
57     FaultMuxerEventWrite(muxerFaultInfo);
58 }
59 
60 HWTEST_F(MediaDfxTest, FAULT_AUDIO_CODEC_EVENT, TestSize.Level1)
61 {
62     AudioCodecFaultInfo audioCodecFaultInfo;
63     audioCodecFaultInfo.appName = "appName";
64     audioCodecFaultInfo.instanceId = "1";
65     audioCodecFaultInfo.callerType = "player_framework";
66     audioCodecFaultInfo.audioCodec = "audio/mp4a-latm";
67     audioCodecFaultInfo.errMsg = "errorMessage";
68     FaultAudioCodecEventWrite(audioCodecFaultInfo);
69 }
70 
71 HWTEST_F(MediaDfxTest, FAULT_VIDEO_CODEC_EVENT, TestSize.Level1)
72 {
73     VideoCodecFaultInfo videoCodecFaultInfo;
74     videoCodecFaultInfo.appName = "appName";
75     videoCodecFaultInfo.instanceId = "1";
76     videoCodecFaultInfo.callerType = "player_framework";
77     videoCodecFaultInfo.videoCodec = "video/mp4v-es";
78     videoCodecFaultInfo.errMsg = "errorMessage";
79     FaultVideoCodecEventWrite(videoCodecFaultInfo);
80 }
81 
82 HWTEST_F(MediaDfxTest, FAULT_RECORD_AUDIO_EVENT, TestSize.Level1)
83 {
84     AudioSourceFaultInfo audioSourceFaultInfo;
85     audioSourceFaultInfo.appName = "appName";
86     audioSourceFaultInfo.instanceId = "1";
87     audioSourceFaultInfo.audioSourceType = 1;
88     audioSourceFaultInfo.errMsg = "errorMessage";
89     FaultRecordAudioEventWrite(audioSourceFaultInfo);
90 }
91 }
92 }