diff --git a/src/xine-engine.cpp b/src/xine-engine.cpp index 7a02a747c..d8aef7970 100644 --- a/src/xine-engine.cpp +++ b/src/xine-engine.cpp @@ -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() *****"; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ddec86909..4ff247856 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) diff --git a/tests/songplaylistitem_test.cpp b/tests/songplaylistitem_test.cpp new file mode 100644 index 000000000..8528fc88c --- /dev/null +++ b/tests/songplaylistitem_test.cpp @@ -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 . +*/ + +#include "songplaylistitem.h" +#include "test_utils.h" + +#include +#include + +#include +#include +#include + +namespace { + +class SongPlaylistItemTest : public ::testing::TestWithParam { + 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 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 +