2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "utils/StreamDetails.h"
23 #include "gtest/gtest.h"
25 TEST(TestStreamDetails, General)
28 CStreamDetailVideo *video = new CStreamDetailVideo();
29 CStreamDetailAudio *audio = new CStreamDetailAudio();
30 CStreamDetailSubtitle *subtitle = new CStreamDetailSubtitle();
32 video->m_iWidth = 1920;
33 video->m_iHeight = 1080;
34 video->m_fAspect = 2.39f;
35 video->m_iDuration = 30;
36 video->m_strCodec = "h264";
38 audio->m_iChannels = 2;
39 audio->m_strCodec = "aac";
40 audio->m_strLanguage = "eng";
42 subtitle->m_strLanguage = "eng";
47 EXPECT_TRUE(a.HasItems());
49 EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::VIDEO));
50 EXPECT_EQ(1, a.GetVideoStreamCount());
51 EXPECT_STREQ("", a.GetVideoCodec().c_str());
52 EXPECT_EQ(0.0f, a.GetVideoAspect());
53 EXPECT_EQ(0, a.GetVideoWidth());
54 EXPECT_EQ(0, a.GetVideoHeight());
55 EXPECT_EQ(0, a.GetVideoDuration());
57 EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::AUDIO));
58 EXPECT_EQ(1, a.GetAudioStreamCount());
60 EXPECT_EQ(0, a.GetStreamCount(CStreamDetail::SUBTITLE));
61 EXPECT_EQ(0, a.GetSubtitleStreamCount());
63 a.AddStream(subtitle);
64 EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::SUBTITLE));
65 EXPECT_EQ(1, a.GetSubtitleStreamCount());
67 a.DetermineBestStreams();
68 EXPECT_STREQ("h264", a.GetVideoCodec().c_str());
69 EXPECT_EQ(2.39f, a.GetVideoAspect());
70 EXPECT_EQ(1920, a.GetVideoWidth());
71 EXPECT_EQ(1080, a.GetVideoHeight());
72 EXPECT_EQ(30, a.GetVideoDuration());
75 TEST(TestStreamDetails, VideoDimsToResolutionDescription)
78 CStreamDetails::VideoDimsToResolutionDescription(1920, 1080));
81 TEST(TestStreamDetails, VideoAspectToAspectDescription)
83 EXPECT_STREQ("2.35", CStreamDetails::VideoAspectToAspectDescription(2.39f));