Debian Codegraph @

xbmc/playlists/test/TestPlayListB4S.cpp

raw
1 /*
2 * Copyright (C) 2023 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "FileItem.h"
10 #include "URL.h"
11 #include "music/tags/MusicInfoTag.h"
12 #include "playlists/PlayListB4S.h"
13 #include "test/TestUtils.h"
14 #include "utils/URIUtils.h"
15
16 #include <fstream>
17 #include <gtest/gtest.h>
18
19 using namespace PLAYLIST;
20
21
22 TEST(TestPlayListB4S, LoadData)
23 {
24 const std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/test.b4s");
25 CPlayListB4S playlist;
26
27 std::filebuf fb;
28 if (!fb.open(filename, std::ios::in))
29 {
30 // Test Failure
31 EXPECT_TRUE(false);
32 }
33
34 std::istream is(&fb);
35 EXPECT_TRUE(playlist.LoadData(is));
36 fb.close();
37
38 EXPECT_EQ(playlist.size(), 3);
39 EXPECT_STREQ(playlist.GetName().c_str(), "Playlist 001");
40
41 EXPECT_STREQ(playlist[1]->GetLabel().c_str(), "demo 2");
42 // It would be nice to test path, however cross platform handling makes this difficult
43 // windows strips the leading /
44 //EXPECT_STREQ(playlist[2]->GetPath().c_str(), "/Users/Shared/test.mp3");
45
46 const CFileItemPtr item {playlist[2]};
47 EXPECT_EQ(item->GetMusicInfoTag()->GetDuration(), 264);
48 }