mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 12:28:31 +01:00
Add infrastructure for unit tests.
This commit is contained in:
parent
91958d0fd2
commit
269957e7ca
@ -52,3 +52,5 @@ include_directories(${LASTFM_INCLUDE_DIRS})
|
|||||||
add_subdirectory(3rdparty/qtsingleapplication)
|
add_subdirectory(3rdparty/qtsingleapplication)
|
||||||
add_subdirectory(3rdparty/qxt)
|
add_subdirectory(3rdparty/qxt)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
add_subdirectory(tests)
|
||||||
|
@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 2.6)
|
|||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
set(CLEMENTINE-SOURCES
|
set(CLEMENTINE-SOURCES
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
player.cpp
|
player.cpp
|
||||||
library.cpp
|
library.cpp
|
||||||
@ -151,14 +150,13 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/qtsingleapplication
|
|||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/qxt")
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/qxt")
|
||||||
|
|
||||||
set(EXECUTABLE_OUTPUT_PATH ..)
|
set(EXECUTABLE_OUTPUT_PATH ..)
|
||||||
add_executable(clementine
|
add_library(clementine_lib
|
||||||
MACOSX_BUNDLE
|
|
||||||
${CLEMENTINE-SOURCES}
|
${CLEMENTINE-SOURCES}
|
||||||
${CLEMENTINE-SOURCES-MOC}
|
${CLEMENTINE-SOURCES-MOC}
|
||||||
${CLEMENTINE-SOURCES-UI}
|
${CLEMENTINE-SOURCES-UI}
|
||||||
${CLEMENTINE-SOURCES-RESOURCE}
|
${CLEMENTINE-SOURCES-RESOURCE}
|
||||||
)
|
)
|
||||||
target_link_libraries(clementine
|
target_link_libraries(clementine_lib
|
||||||
${QT_LIBRARIES}
|
${QT_LIBRARIES}
|
||||||
qtsingleapplication
|
qtsingleapplication
|
||||||
qxt
|
qxt
|
||||||
@ -168,11 +166,17 @@ target_link_libraries(clementine
|
|||||||
lastfm
|
lastfm
|
||||||
)
|
)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
target_link_libraries(clementine
|
target_link_libraries(clementine_lib
|
||||||
${GROWL}
|
${GROWL}
|
||||||
)
|
)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
add_dependencies(clementine qtsingleapplication qxt)
|
add_dependencies(clementine_lib qtsingleapplication qxt)
|
||||||
|
|
||||||
|
add_executable(clementine
|
||||||
|
MACOSX_BUNDLE
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(clementine clementine_lib)
|
||||||
|
|
||||||
set_property(TARGET clementine
|
set_property(TARGET clementine
|
||||||
PROPERTY COMPILE_FLAGS
|
PROPERTY COMPILE_FLAGS
|
||||||
|
31
tests/CMakeLists.txt
Normal file
31
tests/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../gtest)
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../gtest/include)
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
|
||||||
|
|
||||||
|
set(GTEST-SOURCES
|
||||||
|
../gtest/src/gtest.cc
|
||||||
|
../gtest/src/gtest-death-test.cc
|
||||||
|
../gtest/src/gtest-filepath.cc
|
||||||
|
../gtest/src/gtest-port.cc
|
||||||
|
../gtest/src/gtest-test-part.cc
|
||||||
|
../gtest/src/gtest-typed-test.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(gtest ${GTEST-SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
set(SONGTEST-SOURCES
|
||||||
|
../gtest/src/gtest_main.cc
|
||||||
|
../src/song.cpp
|
||||||
|
song_test.cpp)
|
||||||
|
|
||||||
|
add_executable(song_test ${SONGTEST-SOURCES})
|
||||||
|
target_link_libraries(song_test clementine_lib gtest)
|
||||||
|
|
||||||
|
add_custom_target(test
|
||||||
|
./song_test
|
||||||
|
WORKING_DIRECTORY ${CURRENT_BINARY_DIR}
|
||||||
|
DEPENDS song_test)
|
34
tests/song_test.cpp
Normal file
34
tests/song_test.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "song.h"
|
||||||
|
#include <lastfm/Track>
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& stream, const QString& str) {
|
||||||
|
stream << str.toStdString();
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class SongTest : public ::testing::Test {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace
|
Loading…
Reference in New Issue
Block a user