aboutsummaryrefslogtreecommitdiff
path: root/xbmc/playlists/test/TestPlayListXSPF.cpp
blob: 574d05d120d55aefdbe1ab2f825221116ac76b3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 *  Copyright (C) 2018 Tyler Szabo
 *  Copyright (C) 2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "FileItem.h"
#include "URL.h"
#include "playlists/PlayListXSPF.h"
#include "test/TestUtils.h"
#include "utils/URIUtils.h"

#include <gtest/gtest.h>

using namespace PLAYLIST;


TEST(TestPlayListXSPF, Load)
{
  std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/test.xspf");
  CPlayListXSPF playlist;
  std::vector<std::string> pathparts;
  std::vector<std::string>::reverse_iterator it;

  EXPECT_TRUE(playlist.Load(filename));

  EXPECT_EQ(playlist.size(), 5);
  EXPECT_STREQ(playlist.GetName().c_str(), "Various Music");


  ASSERT_GT(playlist.size(), 0);
  EXPECT_STREQ(playlist[0]->GetLabel().c_str(), "");
  EXPECT_STREQ(playlist[0]->GetURL().Get().c_str(), "http://example.com/song_1.mp3");


  ASSERT_GT(playlist.size(), 1);
  EXPECT_STREQ(playlist[1]->GetLabel().c_str(), "Relative local file");
  pathparts = URIUtils::SplitPath(playlist[1]->GetPath());
  it = pathparts.rbegin();
  EXPECT_STREQ((*it++).c_str(), "song_2.mp3");
  EXPECT_STREQ((*it++).c_str(), "path_to");
  EXPECT_STREQ((*it++).c_str(), "relative");
  EXPECT_STREQ((*it++).c_str(), "test");
  EXPECT_STREQ((*it++).c_str(), "playlists");
  EXPECT_STREQ((*it++).c_str(), "xbmc");


  ASSERT_GT(playlist.size(), 2);
  EXPECT_STREQ(playlist[2]->GetLabel().c_str(), "Don\xC2\x92t Worry, We\xC2\x92ll Be Watching You");
  pathparts = URIUtils::SplitPath(playlist[2]->GetPath());
  it = pathparts.rbegin();
  EXPECT_STREQ((*it++).c_str(), "09 - Don't Worry, We'll Be Watching You.mp3");
  EXPECT_STREQ((*it++).c_str(), "Making Mirrors");
  EXPECT_STREQ((*it++).c_str(), "Gotye");
  EXPECT_STREQ((*it++).c_str(), "Music");
  EXPECT_STREQ((*it++).c_str(), "jane");
  EXPECT_STREQ((*it++).c_str(), "Users");
  EXPECT_STREQ((*it++).c_str(), "C:");


  ASSERT_GT(playlist.size(), 3);
  EXPECT_STREQ(playlist[3]->GetLabel().c_str(), "Rollin' & Scratchin'");
  pathparts = URIUtils::SplitPath(playlist[3]->GetPath());
  it = pathparts.rbegin();
  EXPECT_STREQ((*it++).c_str(), "08 - Rollin' & Scratchin'.mp3");
  EXPECT_STREQ((*it++).c_str(), "Homework");
  EXPECT_STREQ((*it++).c_str(), "Daft Punk");
  EXPECT_STREQ((*it++).c_str(), "Music");
  EXPECT_STREQ((*it++).c_str(), "jane");
  EXPECT_STREQ((*it++).c_str(), "home");


  ASSERT_GT(playlist.size(), 4);
  EXPECT_STREQ(playlist[4]->GetLabel().c_str(), "");
  EXPECT_STREQ(playlist[4]->GetURL().Get().c_str(), "http://example.com/song_2.mp3");
}