Disable any tests that use Song::InitFromFile for now

This commit is contained in:
David Sansome 2012-01-08 20:09:44 +00:00
parent 626ce20ec0
commit 12daf6bf43
7 changed files with 23 additions and 166 deletions

View File

@ -8,8 +8,13 @@ else(USE_SYSTEM_GMOCK)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest)
endif(USE_SYSTEM_GMOCK)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_BINARY_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/ext/clementine-tagreader)
include_directories(${CMAKE_SOURCE_DIR}/ext/libclementine-common)
include_directories(${CMAKE_SOURCE_DIR}/ext/libclementine-tagreader)
include_directories(${CMAKE_BINARY_DIR}/ext/libclementine-tagreader)
include_directories(${QT_QTTEST_INCLUDE_DIR})
if(HAVE_LIBGPOD)
@ -45,14 +50,15 @@ if(NOT USE_SYSTEM_GMOCK)
set(GMOCK_LIBRARIES gmock gtest)
endif(NOT USE_SYSTEM_GMOCK)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=0)
set(TESTUTILS-SOURCES
mock_networkaccessmanager.cpp
mock_taglib.cpp
mock_playlistitem.cpp
test_utils.cpp
testobjectdecorators.cpp
${CMAKE_SOURCE_DIR}/ext/clementine-tagreader/fmpsparser.cpp
)
set(TESTUTILS-MOC-HEADERS
@ -114,24 +120,24 @@ endmacro (add_test_file)
add_test_file(albumcovermanager_test.cpp true)
add_test_file(asxparser_test.cpp false)
add_test_file(asxiniparser_test.cpp false)
add_test_file(cueparser_test.cpp false)
#add_test_file(cueparser_test.cpp false)
add_test_file(database_test.cpp false)
add_test_file(fileformats_test.cpp false)
#add_test_file(fileformats_test.cpp false)
add_test_file(fmpsparser_test.cpp false)
add_test_file(librarybackend_test.cpp false)
add_test_file(librarymodel_test.cpp true)
add_test_file(m3uparser_test.cpp false)
#add_test_file(m3uparser_test.cpp false)
add_test_file(mergedproxymodel_test.cpp false)
add_test_file(organiseformat_test.cpp false)
add_test_file(playlist_test.cpp true)
add_test_file(plsparser_test.cpp false)
#add_test_file(plsparser_test.cpp false)
add_test_file(scopedtransaction_test.cpp false)
add_test_file(songloader_test.cpp false)
#add_test_file(songloader_test.cpp false)
add_test_file(songplaylistitem_test.cpp false)
add_test_file(song_test.cpp false)
add_test_file(translations_test.cpp false)
add_test_file(utilities_test.cpp false)
add_test_file(xspfparser_test.cpp false)
#add_test_file(xspfparser_test.cpp false)
if(LINUX AND HAVE_DBUS)
add_test_file(mpris1_test.cpp true)

View File

@ -19,7 +19,6 @@
#include "gmock/gmock-matchers.h"
#include "gtest/gtest.h"
#include "test_utils.h"
#include "mock_taglib.h"
#include "core/timeconstants.h"
#include "playlistparsers/cueparser.h"
@ -28,10 +27,6 @@
class CueParserTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
testing::DefaultValue<TagLib::String>::Set("foobarbaz");
}
CueParserTest()
: parser_(NULL) {
}
@ -52,7 +47,6 @@ class CueParserTest : public ::testing::Test {
}
CueParser parser_;
MockFileRefFactory taglib_;
};
TEST_F(CueParserTest, ParsesASong) {

View File

@ -18,7 +18,7 @@
#include "test_utils.h"
#include "gtest/gtest.h"
#include "core/fmpsparser.h"
#include "fmpsparser.h"
#include <QtDebug>

View File

@ -18,7 +18,6 @@
#include "gmock/gmock-matchers.h"
#include "gtest/gtest.h"
#include "test_utils.h"
#include "mock_taglib.h"
#include "core/timeconstants.h"
#include "playlistparsers/m3uparser.h"
@ -30,16 +29,11 @@ using ::testing::HasSubstr;
class M3UParserTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
testing::DefaultValue<TagLib::String>::Set("foobarbaz");
}
M3UParserTest()
: parser_(NULL) {
}
M3UParser parser_;
MockFileRefFactory taglib_;
};
TEST_F(M3UParserTest, ParsesMetadata) {

View File

@ -1,57 +0,0 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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 "mock_taglib.h"
#include <QFile>
using ::testing::Return;
MockFile::MockFile(TagLib::Tag* tag, const QString& filename)
: TagLib::File(QFile::encodeName(filename).constData()),
tag_(tag) {
}
TagLib::Tag* MockFile::tag() const {
return tag_.get();
}
TagLib::AudioProperties* MockFile::audioProperties() const {
return NULL;
}
bool MockFile::save() {
return true;
}
void MockFileRefFactory::ExpectCall(const QString& filename,
const QString& title,
const QString& artist,
const QString& album) {
MockTag* tag = new MockTag;
EXPECT_CALL(*tag, title()).WillRepeatedly(Return(title.toStdString()));
EXPECT_CALL(*tag, artist()).WillRepeatedly(Return(artist.toStdString()));
EXPECT_CALL(*tag, album()).WillRepeatedly(Return(album.toStdString()));
tags_[filename] = tag;
}
TagLib::FileRef* MockFileRefFactory::GetFileRef(const QString& filename) {
MockTag* tag = tags_.take(filename);
MockFile* file = new MockFile(tag, filename);
TagLib::FileRef* fileref = new TagLib::FileRef(file);
return fileref;
}

View File

@ -1,77 +0,0 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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/>.
*/
#ifndef MOCK_TAGLIB_H
#define MOCK_TAGLIB_H
#include "gmock/gmock.h"
#include <QMap>
#include <fileref.h>
#include <tag.h>
#include <boost/scoped_ptr.hpp>
#include "core/song.h"
class MockTag : public TagLib::Tag {
public:
MOCK_CONST_METHOD0(title, TagLib::String());
MOCK_CONST_METHOD0(artist, TagLib::String());
MOCK_CONST_METHOD0(album, TagLib::String());
MOCK_CONST_METHOD0(comment, TagLib::String());
MOCK_CONST_METHOD0(genre, TagLib::String());
MOCK_METHOD1(setTitle, void(const TagLib::String&));
MOCK_METHOD1(setArtist, void(const TagLib::String&));
MOCK_METHOD1(setAlbum, void(const TagLib::String&));
MOCK_METHOD1(setComment, void(const TagLib::String&));
MOCK_METHOD1(setGenre, void(const TagLib::String&));
MOCK_CONST_METHOD0(year, uint());
MOCK_CONST_METHOD0(track, uint());
MOCK_METHOD1(setYear, void(uint));
MOCK_METHOD1(setTrack, void(uint));
};
class MockFile : public TagLib::File {
public:
MockFile(TagLib::Tag* tag, const QString& filename);
virtual TagLib::Tag* tag() const;
virtual TagLib::AudioProperties* audioProperties() const;
virtual bool save();
protected:
boost::scoped_ptr<TagLib::Tag> tag_;
};
class MockFileRefFactory : public FileRefFactory {
public:
void ExpectCall(const QString& filename,
const QString& title,
const QString& artist,
const QString& album);
protected:
virtual TagLib::FileRef* GetFileRef(const QString& filename);
QMap<QString, MockTag*> tags_;
};
#endif // MOCK_TAGLIB_H

View File

@ -27,7 +27,6 @@
#include "gtest/gtest.h"
#include "test_utils.h"
#include "mock_taglib.h"
#include <QTemporaryFile>
#include <QTextCodec>
@ -42,8 +41,6 @@ class SongTest : public ::testing::Test {
// Return something from uninteresting mock functions.
testing::DefaultValue<TagLib::String>::Set("foobarbaz");
}
MockFileRefFactory mock_factory_;
};
@ -64,7 +61,7 @@ TEST_F(SongTest, InitsFromLastFM) {
}
#endif // HAVE_LIBLASTFM
TEST_F(SongTest, InitsFromFile) {
/*TEST_F(SongTest, InitsFromFile) {
QTemporaryFile temp;
temp.open();
mock_factory_.ExpectCall(temp.fileName(), "Foo", "Bar", "Baz");
@ -73,7 +70,7 @@ TEST_F(SongTest, InitsFromFile) {
EXPECT_EQ("Foo", song.title());
EXPECT_EQ("Bar", song.artist());
EXPECT_EQ("Baz", song.album());
}
}*/
TEST_F(SongTest, DetectsWindows1251) {
char cp1251[] = { 0xc2, 0xfb, 0xe4, 0xfb, 0xf5, 0xe0, 0xe9, 0x00 }; // Выдыхай
@ -146,7 +143,7 @@ TEST_F(SongTest, FixesUtf8MungedIntoLatin1) {
EXPECT_EQ(QString::fromUtf8("Esthers"), fixed);
}
TEST_F(SongTest, TakesMajorityVote) {
/*TEST_F(SongTest, TakesMajorityVote) {
const char w1251[] = { 0xca, 0xe8, 0xed, 0xee, '\0' }; // Кино
// Actually windows-1251 but gets detected as windows-1252.
const char w1252[] = { 0xcf, '.', 0xc7, '.', '\0' }; // П.Э.
@ -183,7 +180,7 @@ TEST_F(SongTest, DecodesUtf8AsUtf8) {
QString fixed = Song::Decode(str, codec);
ASSERT_EQ(1, fixed.length());
EXPECT_EQ(QString::fromUtf8(""), fixed);
}
}*/
TEST_F(SongTest, DecodesAmbiguousLatin1AndWindows1252) {
const char latin1[] = { 0x53, 0x75, 0x64, 0xe1, 0x66, 0x72, 0x69, 0x63, 0x61, 0x00 };
@ -193,7 +190,7 @@ TEST_F(SongTest, DecodesAmbiguousLatin1AndWindows1252) {
EXPECT_EQ(QString::fromUtf8("Sudáfrica"), fixed);
}
TEST_F(SongTest, FMPSRating) {
/*TEST_F(SongTest, FMPSRating) {
TemporaryResource r(":/testdata/fmpsrating.mp3");
Song song;
song.InitFromFile(r.fileName(), -1);
@ -233,6 +230,6 @@ TEST_F(SongTest, FMPSPlayCountBoth) {
Song song;
song.InitFromFile(r.fileName(), -1);
EXPECT_EQ(123, song.playcount());
}
}*/
} // namespace