| 1 |
/* |
| 2 |
* Copyright (C) 2018 Tyler Szabo |
| 3 |
* Copyright (C) 2018 Team Kodi |
| 4 |
* This file is part of Kodi - https://kodi.tv |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 7 |
* See LICENSES/README.md for more information. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "FileItem.h" |
| 11 |
#include "URL.h" |
| 12 |
#include "playlists/PlayListXSPF.h" |
| 13 |
#include "test/TestUtils.h" |
| 14 |
#include "utils/URIUtils.h" |
| 15 |
|
| 16 |
#include <gtest/gtest.h> |
| 17 |
|
| 18 |
using namespace PLAYLIST; |
| 19 |
|
| 20 |
|
| 21 |
TEST(TestPlayListXSPF, Load) |
| 22 |
{ |
| 23 |
std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/test.xspf"); |
| 24 |
CPlayListXSPF playlist; |
| 25 |
std::vector<std::string> pathparts; |
| 26 |
std::vector<std::string>::reverse_iterator it; |
| 27 |
|
| 28 |
EXPECT_TRUE(playlist.Load(filename)); |
| 29 |
|
| 30 |
EXPECT_EQ(playlist.size(), 5); |
| 31 |
EXPECT_STREQ(playlist.GetName().c_str(), "Various Music"); |
| 32 |
|
| 33 |
|
| 34 |
ASSERT_GT(playlist.size(), 0); |
| 35 |
EXPECT_STREQ(playlist[0]->GetLabel().c_str(), ""); |
| 36 |
EXPECT_STREQ(playlist[0]->GetURL().Get().c_str(), "http://example.com/song_1.mp3"); |
| 37 |
|
| 38 |
|
| 39 |
ASSERT_GT(playlist.size(), 1); |
| 40 |
EXPECT_STREQ(playlist[1]->GetLabel().c_str(), "Relative local file"); |
| 41 |
pathparts = URIUtils::SplitPath(playlist[1]->GetPath()); |
| 42 |
it = pathparts.rbegin(); |
| 43 |
EXPECT_STREQ((*it++).c_str(), "song_2.mp3"); |
| 44 |
EXPECT_STREQ((*it++).c_str(), "path_to"); |
| 45 |
EXPECT_STREQ((*it++).c_str(), "relative"); |
| 46 |
EXPECT_STREQ((*it++).c_str(), "test"); |
| 47 |
EXPECT_STREQ((*it++).c_str(), "playlists"); |
| 48 |
EXPECT_STREQ((*it++).c_str(), "xbmc"); |
| 49 |
|
| 50 |
|
| 51 |
ASSERT_GT(playlist.size(), 2); |
| 52 |
EXPECT_STREQ(playlist[2]->GetLabel().c_str(), "Don\xC2\x92t Worry, We\xC2\x92ll Be Watching You"); |
| 53 |
pathparts = URIUtils::SplitPath(playlist[2]->GetPath()); |
| 54 |
it = pathparts.rbegin(); |
| 55 |
EXPECT_STREQ((*it++).c_str(), "09 - Don't Worry, We'll Be Watching You.mp3"); |
| 56 |
EXPECT_STREQ((*it++).c_str(), "Making Mirrors"); |
| 57 |
EXPECT_STREQ((*it++).c_str(), "Gotye"); |
| 58 |
EXPECT_STREQ((*it++).c_str(), "Music"); |
| 59 |
EXPECT_STREQ((*it++).c_str(), "jane"); |
| 60 |
EXPECT_STREQ((*it++).c_str(), "Users"); |
| 61 |
EXPECT_STREQ((*it++).c_str(), "C:"); |
| 62 |
|
| 63 |
|
| 64 |
ASSERT_GT(playlist.size(), 3); |
| 65 |
EXPECT_STREQ(playlist[3]->GetLabel().c_str(), "Rollin' & Scratchin'"); |
| 66 |
pathparts = URIUtils::SplitPath(playlist[3]->GetPath()); |
| 67 |
it = pathparts.rbegin(); |
| 68 |
EXPECT_STREQ((*it++).c_str(), "08 - Rollin' & Scratchin'.mp3"); |
| 69 |
EXPECT_STREQ((*it++).c_str(), "Homework"); |
| 70 |
EXPECT_STREQ((*it++).c_str(), "Daft Punk"); |
| 71 |
EXPECT_STREQ((*it++).c_str(), "Music"); |
| 72 |
EXPECT_STREQ((*it++).c_str(), "jane"); |
| 73 |
EXPECT_STREQ((*it++).c_str(), "home"); |
| 74 |
|
| 75 |
|
| 76 |
ASSERT_GT(playlist.size(), 4); |
| 77 |
EXPECT_STREQ(playlist[4]->GetLabel().c_str(), ""); |
| 78 |
EXPECT_STREQ(playlist[4]->GetURL().Get().c_str(), "http://example.com/song_2.mp3"); |
| 79 |
} |