[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / utils / test / TestStreamDetails.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
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)
8  *  any later version.
9  *
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.
14  *
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/>.
18  *
19  */
20
21 #include "utils/StreamDetails.h"
22
23 #include "gtest/gtest.h"
24
25 TEST(TestStreamDetails, General)
26 {
27   CStreamDetails a;
28   CStreamDetailVideo *video = new CStreamDetailVideo();
29   CStreamDetailAudio *audio = new CStreamDetailAudio();
30   CStreamDetailSubtitle *subtitle = new CStreamDetailSubtitle();
31
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";
37
38   audio->m_iChannels = 2;
39   audio->m_strCodec = "aac";
40   audio->m_strLanguage = "eng";
41
42   subtitle->m_strLanguage = "eng";
43
44   a.AddStream(video);
45   a.AddStream(audio);
46
47   EXPECT_TRUE(a.HasItems());
48
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());
56
57   EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::AUDIO));
58   EXPECT_EQ(1, a.GetAudioStreamCount());
59
60   EXPECT_EQ(0, a.GetStreamCount(CStreamDetail::SUBTITLE));
61   EXPECT_EQ(0, a.GetSubtitleStreamCount());
62
63   a.AddStream(subtitle);
64   EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::SUBTITLE));
65   EXPECT_EQ(1, a.GetSubtitleStreamCount());
66
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());
73 }
74
75 TEST(TestStreamDetails, VideoDimsToResolutionDescription)
76 {
77   EXPECT_STREQ("1080",
78                CStreamDetails::VideoDimsToResolutionDescription(1920, 1080));
79 }
80
81 TEST(TestStreamDetails, VideoAspectToAspectDescription)
82 {
83   EXPECT_STREQ("2.35", CStreamDetails::VideoAspectToAspectDescription(2.39f));
84 }