1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Fix loading songs with a # (or other URL special characters) in the name. Fixes issue #117

This commit is contained in:
David Sansome 2010-03-27 15:53:02 +00:00
parent c0a323b5ff
commit 0e4fb1b789
3 changed files with 70 additions and 1 deletions

View File

@ -254,7 +254,7 @@ XineEngine::load( const QUrl &url, bool isStream )
qDebug() << "Before xine_open() *****";
if( xine_open( m_stream, QFile::encodeName( url.toString() ) ) )
if( xine_open( m_stream, url.toEncoded() ) )
{
qDebug() << "After xine_open() *****";

View File

@ -82,3 +82,4 @@ add_test_file(albumcoverfetcher_test.cpp false)
add_test_file(xspfparser_test.cpp false)
add_test_file(library_test.cpp false)
add_test_file(albumcovermanager_test.cpp true)
add_test_file(songplaylistitem_test.cpp false)

View File

@ -0,0 +1,68 @@
/* This file is part of Clementine.
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "songplaylistitem.h"
#include "test_utils.h"
#include <gtest/gtest.h>
#include <boost/scoped_ptr.hpp>
#include <QTemporaryFile>
#include <QFileInfo>
#include <QtDebug>
namespace {
class SongPlaylistItemTest : public ::testing::TestWithParam<const char*> {
protected:
SongPlaylistItemTest() : temp_file_(GetParam()) {}
void SetUp() {
// SongPlaylistItem::Url() checks if the file exists, so we need a real file
temp_file_.open();
absolute_file_name_ = QFileInfo(temp_file_.fileName()).absoluteFilePath();
song_.Init("Title", "Artist", "Album", 123);
song_.set_filename(absolute_file_name_);
item_.reset(new SongPlaylistItem(song_));
}
Song song_;
QTemporaryFile temp_file_;
QString absolute_file_name_;
boost::scoped_ptr<SongPlaylistItem> item_;
};
INSTANTIATE_TEST_CASE_P(RealFiles, SongPlaylistItemTest, testing::Values(
"normalfile.mp3",
"file with spaces.mp3",
"file with # hash.mp3",
"file with ? question.mp3"
));
TEST_P(SongPlaylistItemTest, Url) {
QUrl expected;
expected.setScheme("file");
expected.setPath(absolute_file_name_);
EXPECT_EQ(expected, item_->Url());
}
} //namespace