1fa7767c5Sopenharmony_ci/*
2fa7767c5Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License.
5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at
6fa7767c5Sopenharmony_ci *
7fa7767c5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fa7767c5Sopenharmony_ci *
9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and
13fa7767c5Sopenharmony_ci * limitations under the License.
14fa7767c5Sopenharmony_ci */
15fa7767c5Sopenharmony_ci
16fa7767c5Sopenharmony_ci#include "gtest/gtest.h"
17fa7767c5Sopenharmony_ci#include <pipeline/core/event.h>
18fa7767c5Sopenharmony_ci#include <pipeline/core/type_define.h>
19fa7767c5Sopenharmony_ci#include "pipeline/filters/common/plugin_utils.h"
20fa7767c5Sopenharmony_ci
21fa7767c5Sopenharmony_cinamespace OHOS {
22fa7767c5Sopenharmony_cinamespace Media {
23fa7767c5Sopenharmony_cinamespace Test {
24fa7767c5Sopenharmony_ciusing namespace OHOS::Media::Pipeline;
25fa7767c5Sopenharmony_ciusing namespace testing::ext;
26fa7767c5Sopenharmony_ci
27fa7767c5Sopenharmony_ciHWTEST(TestMeta, get_byte_per_sample, TestSize.Level1)
28fa7767c5Sopenharmony_ci{
29fa7767c5Sopenharmony_ci    uint8_t bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S64);
30fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
31fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S64P);
32fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
33fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U64);
34fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
35fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U64P);
36fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
37fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::F64);
38fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
39fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::F64P);
40fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 8);
41fa7767c5Sopenharmony_ci
42fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::F32);
43fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
44fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::F32P);
45fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
46fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S32);
47fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
48fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S32P);
49fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
50fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U32);
51fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
52fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U32P);
53fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 4);
54fa7767c5Sopenharmony_ci
55fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S24);
56fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 3);
57fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S24P);
58fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 3);
59fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U24);
60fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 3);
61fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U24P);
62fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 3);
63fa7767c5Sopenharmony_ci
64fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S16);
65fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 2);
66fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S16P);
67fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 2);
68fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U16);
69fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 2);
70fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U16P);
71fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 2);
72fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S8);
73fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 1);
74fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::S8P);
75fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 1);
76fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U8);
77fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 1);
78fa7767c5Sopenharmony_ci    bytes = GetBytesPerSample(Plugin::AudioSampleFormat::U8P);
79fa7767c5Sopenharmony_ci    ASSERT_EQ(bytes, 1);
80fa7767c5Sopenharmony_ci}
81fa7767c5Sopenharmony_ci
82fa7767c5Sopenharmony_ciHWTEST(TestMeta, return_type_if_type_is_existed, TestSize.Level1)
83fa7767c5Sopenharmony_ci{
84fa7767c5Sopenharmony_ci    EventType eventType = EventType::EVENT_READY;
85fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_READY");
86fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_AUDIO_PROGRESS;
87fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_AUDIO_PROGRESS");
88fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_VIDEO_PROGRESS;
89fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_VIDEO_PROGRESS");
90fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_COMPLETE;
91fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_COMPLETE");
92fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_ERROR;
93fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_ERROR");
94fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_PLUGIN_ERROR;
95fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_PLUGIN_ERROR");
96fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_PLUGIN_EVENT;
97fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_PLUGIN_EVENT");
98fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_BUFFERING;
99fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_BUFFERING");
100fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_BUFFER_PROGRESS;
101fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_BUFFER_PROGRESS");
102fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_DECODER_ERROR;
103fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_DECODER_ERROR");
104fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_RESOLUTION_CHANGE;
105fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_RESOLUTION_CHANGE");
106fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_VIDEO_RENDERING_START;
107fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_VIDEO_RENDERING_START");
108fa7767c5Sopenharmony_ci    eventType = EventType::EVENT_IS_LIVE_STREAM;
109fa7767c5Sopenharmony_ci    ASSERT_STREQ(GetEventName(eventType), "EVENT_IS_LIVE_STREAM");
110fa7767c5Sopenharmony_ci}
111fa7767c5Sopenharmony_ci} // namespace Test
112fa7767c5Sopenharmony_ci} // namespace Media
113fa7767c5Sopenharmony_ci} // namespace OHOS
114