~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to tests/plsparser_test.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "test_utils.h"
19
19
#include "gtest/gtest.h"
20
20
 
 
21
#include "core/timeconstants.h"
21
22
#include "playlistparsers/plsparser.h"
22
23
 
23
24
#include <QBuffer>
24
25
#include <QFile>
25
26
#include <QTemporaryFile>
 
27
#include <QUrl>
26
28
#include <QtDebug>
27
29
 
28
30
#include <boost/shared_ptr.hpp>
48
50
 
49
51
  SongList songs = parser_.Load(file.get(), "", QDir("/relative/to/"));
50
52
  ASSERT_EQ(1, songs.length());
51
 
  EXPECT_EQ("/relative/to/filename with spaces.mp3", songs[0].filename());
 
53
  EXPECT_EQ(QUrl("file:///relative/to/filename with spaces.mp3"), songs[0].url());
52
54
  EXPECT_EQ("Title", songs[0].title());
53
55
  EXPECT_EQ(123 * kNsecPerSec, songs[0].length_nanosec());
54
56
}
58
60
 
59
61
  SongList songs = parser_.Load(file.get());
60
62
  ASSERT_EQ(4, songs.length());
61
 
  EXPECT_EQ("http://streamer-dtc-aa05.somafm.com:80/stream/1018", songs[0].filename());
62
 
  EXPECT_EQ("http://streamer-mtc-aa03.somafm.com:80/stream/1018", songs[1].filename());
63
 
  EXPECT_EQ("http://streamer-ntc-aa04.somafm.com:80/stream/1018", songs[2].filename());
64
 
  EXPECT_EQ("http://ice.somafm.com/groovesalad", songs[3].filename());
 
63
  EXPECT_EQ(QUrl("http://streamer-dtc-aa05.somafm.com:80/stream/1018"), songs[0].url());
 
64
  EXPECT_EQ(QUrl("http://streamer-mtc-aa03.somafm.com:80/stream/1018"), songs[1].url());
 
65
  EXPECT_EQ(QUrl("http://streamer-ntc-aa04.somafm.com:80/stream/1018"), songs[2].url());
 
66
  EXPECT_EQ(QUrl("http://ice.somafm.com/groovesalad"), songs[3].url());
65
67
  EXPECT_EQ("SomaFM: Groove Salad (#1 128k mp3): A nicely chilled plate of ambient beats and grooves.", songs[0].title());
66
68
  EXPECT_EQ("SomaFM: Groove Salad (#2 128k mp3): A nicely chilled plate of ambient beats and grooves.", songs[1].title());
67
69
  EXPECT_EQ("SomaFM: Groove Salad (#3 128k mp3): A nicely chilled plate of ambient beats and grooves.", songs[2].title());
74
76
 
75
77
  SongList songs = parser_.Load(file.get());
76
78
  ASSERT_EQ(4, songs.length());
77
 
  EXPECT_EQ("http://streamer-ntc-aa03.somafm.com:80/stream/1021", songs[0].filename());
78
 
  EXPECT_EQ("http://streamer-mtc-aa04.somafm.com:80/stream/1021", songs[1].filename());
79
 
  EXPECT_EQ("http://streamer-dtc-aa05.somafm.com:80/stream/1021", songs[2].filename());
80
 
  EXPECT_EQ("http://ice.somafm.com/secretagent", songs[3].filename());
 
79
  EXPECT_EQ(QUrl("http://streamer-ntc-aa03.somafm.com:80/stream/1021"), songs[0].url());
 
80
  EXPECT_EQ(QUrl("http://streamer-mtc-aa04.somafm.com:80/stream/1021"), songs[1].url());
 
81
  EXPECT_EQ(QUrl("http://streamer-dtc-aa05.somafm.com:80/stream/1021"), songs[2].url());
 
82
  EXPECT_EQ(QUrl("http://ice.somafm.com/secretagent"), songs[3].url());
81
83
  EXPECT_EQ("SomaFM: Secret Agent (#1 128k mp3): The soundtrack for your stylish, mysterious, dangerous life. For Spies and PIs too!", songs[0].title());
82
84
  EXPECT_EQ("SomaFM: Secret Agent (#2 128k mp3): The soundtrack for your stylish, mysterious, dangerous life. For Spies and PIs too!", songs[1].title());
83
85
  EXPECT_EQ("SomaFM: Secret Agent (#3 128k mp3): The soundtrack for your stylish, mysterious, dangerous life. For Spies and PIs too!", songs[2].title());
87
89
 
88
90
TEST_F(PLSParserTest, SaveAndLoad) {
89
91
  Song one;
90
 
  one.set_filename("http://www.example.com/foo.mp3");
 
92
  one.set_url(QUrl("http://www.example.com/foo.mp3"));
91
93
  one.set_title("Foo, with, some, commas");
92
94
 
93
95
  Song two;
94
 
  two.set_filename("relative/bar.mp3");
 
96
  two.set_url(QUrl("relative/bar.mp3"));
95
97
  two.set_title("Bar");
96
98
  two.set_length_nanosec(123 * kNsecPerSec);
97
99
 
106
108
  songs = parser_.Load(&temp, "", QDir("/meep"));
107
109
 
108
110
  ASSERT_EQ(2, songs.count());
109
 
  EXPECT_EQ(one.filename(), songs[0].filename());
110
 
  EXPECT_EQ("/meep/relative/bar.mp3", songs[1].filename());
 
111
  EXPECT_EQ(one.url(), songs[0].url());
 
112
  EXPECT_EQ(QUrl("file:///meep/relative/bar.mp3"), songs[1].url());
111
113
  EXPECT_EQ(one.title(), songs[0].title());
112
114
  EXPECT_EQ(two.title(), songs[1].title());
113
115
  EXPECT_EQ(one.length_nanosec(), songs[0].length_nanosec());