2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include "gtest/gtest.h"
25 #include "player_internal.h"
26 #include "unittest/playerTCInfo.hpp"
27 #include "unittest/playerTCWindow.hpp"
29 using namespace playerUTInfo;
31 class PlayerContentsTest : public ::testing::TestWithParam<tcInfos> {
33 virtual void SetUp() override {
34 std::cout << "SetUp()" << std::endl;
35 _tcWindow = std::make_shared<playerTCWindow>();
38 virtual void TearDown() override {
39 std::cout << "TearDown()" << std::endl;
44 std::shared_ptr<playerTCWindow> GetAppWindow() {
49 std::shared_ptr<playerTCWindow> _tcWindow;
52 TEST_P(PlayerContentsTest, contents_test_p) {
59 char *audio_codec = NULL;
60 char *video_codec = NULL;
64 tcInfos _tcInfos = GetParam();
66 auto tcWindow = GetAppWindow();
68 ASSERT_EQ(player_create(&_player), PLAYER_ERROR_NONE);
69 EXPECT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, tcWindow->getEvasObject()), PLAYER_ERROR_NONE);
71 EXPECT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
72 EXPECT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
73 EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
74 EXPECT_EQ(duration, _tcInfos.totalDuration);
76 EXPECT_EQ(player_get_audio_stream_info(_player, &sample_rate, &channel, &bit_rate), PLAYER_ERROR_NONE);
77 EXPECT_EQ(sample_rate, _tcInfos.audio.sampleRate);
78 EXPECT_EQ(channel, _tcInfos.audio.channels);
79 EXPECT_EQ(bit_rate, _tcInfos.audio.bitrate);
81 EXPECT_EQ(player_get_video_stream_info(_player, &fps, &v_bit_rate), PLAYER_ERROR_NONE);
82 EXPECT_EQ(fps, _tcInfos.video.fps);
83 EXPECT_EQ(v_bit_rate, _tcInfos.video.bitrate);
85 EXPECT_EQ(player_get_video_size(_player, &w, &h), PLAYER_ERROR_NONE);
86 EXPECT_EQ(w, _tcInfos.video.width);
87 EXPECT_EQ(h, _tcInfos.video.height);
89 EXPECT_EQ(player_get_codec_info(_player, &audio_codec, &video_codec), PLAYER_ERROR_NONE);
90 std::string audioCodecName = audio_codec;
91 EXPECT_NE(audioCodecName.find(_tcInfos.audio.codecName), std::string::npos);
95 std::string videoCodecName = video_codec;
96 EXPECT_NE(videoCodecName.find(_tcInfos.video.codecName), std::string::npos);
100 EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
101 std::this_thread::sleep_for(std::chrono::milliseconds(5000));
103 EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
105 EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
106 EXPECT_EQ(player_destroy(_player), PLAYER_ERROR_NONE);
110 INSTANTIATE_TEST_SUITE_P(PlayerContentsTestFull, PlayerContentsTest,
111 ::testing::ValuesIn(playerTCInfo("codec").getTCInfos())