Clementine-audio-player-Mac.../tests/song_test.cpp

69 lines
1.8 KiB
C++
Raw Normal View History

/* 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/>.
*/
2010-03-01 02:47:50 +01:00
#include "song.h"
#include "fixlastfm.h"
2010-03-01 02:47:50 +01:00
#include <lastfm/Track>
#include "gmock/gmock.h"
2010-03-01 02:47:50 +01:00
#include "gtest/gtest.h"
#include "test_utils.h"
#include "mock_taglib.h"
2010-03-01 02:47:50 +01:00
#include <QTemporaryFile>
2010-03-01 02:47:50 +01:00
namespace {
class SongTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
// Return something from uninteresting mock functions.
testing::DefaultValue<TagLib::String>::Set("foobarbaz");
}
MockFileRefFactory mock_factory_;
2010-03-01 02:47:50 +01:00
};
TEST_F(SongTest, InitsFromLastFM) {
Song song;
lastfm::MutableTrack track;
track.setTitle("Foo");
lastfm::Artist artist("Bar");
track.setArtist(artist);
lastfm::Album album(artist, "Baz");
track.setAlbum(album);
song.InitFromLastFM(track);
EXPECT_EQ("Foo", song.title());
EXPECT_EQ("Baz", song.album());
EXPECT_EQ("Bar", song.artist());
}
TEST_F(SongTest, InitsFromFile) {
QTemporaryFile temp;
temp.open();
mock_factory_.ExpectCall(temp.fileName(), "Foo", "Bar", "Baz");
Song song(&mock_factory_);
song.InitFromFile(temp.fileName(), 42);
EXPECT_EQ("Foo", song.title());
EXPECT_EQ("Bar", song.artist());
EXPECT_EQ("Baz", song.album());
}
2010-03-01 02:47:50 +01:00
} // namespace