diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 148 | ||||
-rw-r--r-- | tests/TestUtil.h | 27 | ||||
-rw-r--r-- | tests/copy_tests.cmake | 13 | ||||
-rw-r--r-- | tests/data/1.json | 6 | ||||
-rw-r--r-- | tests/data/2.json | 4 | ||||
-rw-r--r-- | tests/data/channels.json | 4 | ||||
-rw-r--r-- | tests/test.manifest | 27 | ||||
-rw-r--r-- | tests/test.rc | 28 | ||||
-rw-r--r-- | tests/test_config.h.in | 3 | ||||
-rw-r--r-- | tests/tst_BaseWonkoEntityLocalLoadTask.cpp | 15 | ||||
-rw-r--r-- | tests/tst_BaseWonkoEntityRemoteLoadTask.cpp | 15 | ||||
-rw-r--r-- | tests/tst_UpdateChecker.cpp | 5 | ||||
-rw-r--r-- | tests/tst_WonkoVersionList.cpp | 15 |
13 files changed, 92 insertions, 218 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 12fa4108..667aecd1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,66 +1,82 @@ -# run the unit tests with `make test` -find_package(Qt5Test) - -add_custom_target(test_data) - -unset(MultiMC_TESTS) -macro(add_unit_test name) - unset(srcs) - foreach(arg ${testname} ${ARGN}) - list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/${arg}) - endforeach() - if(WIN32) - list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc) - endif() - add_executable(tst_${name} ${srcs}) - add_dependencies(tst_${name} test_data) - target_link_libraries(tst_${name} MultiMC_logic) - qt5_use_modules(tst_${name} Test Core Network) - list(APPEND MultiMC_TESTS tst_${name}) - add_test(NAME ${name} COMMAND tst_${name}) -endmacro() - -# Tests BEGIN # - -add_unit_test(gradlespecifier tst_gradlespecifier.cpp) -add_unit_test(userutils tst_userutils.cpp) -add_unit_test(modutils tst_modutils.cpp) -add_unit_test(inifile tst_inifile.cpp) -add_unit_test(FileSystem tst_FileSystem.cpp) -add_unit_test(Library tst_Library.cpp) -add_unit_test(UpdateChecker tst_UpdateChecker.cpp) -add_unit_test(DownloadTask tst_DownloadTask.cpp) -add_unit_test(filematchers tst_filematchers.cpp) -add_unit_test(ModList tst_ModList.cpp) -# add_unit_test(Resource tst_Resource.cpp) -add_unit_test(GZip tst_GZip.cpp) -add_unit_test(JavaVersion tst_JavaVersion.cpp) -add_unit_test(ParseUtils tst_ParseUtils.cpp) -add_unit_test(MojangVersionFormat tst_MojangVersionFormat.cpp) -add_unit_test(BaseWonkoEntityLocalLoadTask tst_BaseWonkoEntityLocalLoadTask.cpp) -add_unit_test(BaseWonkoEntityRemoteLoadTask tst_BaseWonkoEntityRemoteLoadTask.cpp) -add_unit_test(WonkoVersionList tst_WonkoVersionList.cpp) -add_unit_test(WonkoIndex tst_WonkoIndex.cpp) - -# Tests END # - - -set(MultiMC_TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data") -set(MultiMC_TEST_DATA_PATH_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/data") -set(MultiMC_TEST_DATA_PATH_SOURCE_RAW "${CMAKE_CURRENT_SOURCE_DIR}/data_raw") - -if(UNIX) - # on unix we get the third / from the filename - set(MultiMC_TEST_DATA_URL "file://${MultiMC_TEST_DATA_PATH}") -else() - # we don't on windows, so we have to add it ourselves - set(MultiMC_TEST_DATA_URL "file:///${MultiMC_TEST_DATA_PATH}") -endif() - -# clean and replace test data -add_custom_command( - TARGET test_data - COMMAND ${CMAKE_COMMAND} -DMultiMC_TEST_DATA_URL=${MultiMC_TEST_DATA_URL} -DMultiMC_TEST_DATA_PATH=${MultiMC_TEST_DATA_PATH} -DMultiMC_TEST_DATA_PATH_SOURCE=${MultiMC_TEST_DATA_PATH_SOURCE} -DMultiMC_TEST_DATA_PATH_SOURCE_RAW=${MultiMC_TEST_DATA_PATH_SOURCE_RAW} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_tests.cmake -) - -configure_file(test_config.h.in test_config.h @ONLY) +include(UnitTest) + +add_unit_test(gradlespecifier + SOURCES tst_gradlespecifier.cpp + LIBS MultiMC_logic + ) + +add_unit_test(userutils + SOURCES tst_userutils.cpp + LIBS MultiMC_logic + ) + +add_unit_test(modutils + SOURCES tst_modutils.cpp + LIBS MultiMC_logic + ) + +add_unit_test(inifile + SOURCES tst_inifile.cpp + LIBS MultiMC_logic + ) + +add_unit_test(FileSystem + SOURCES tst_FileSystem.cpp + LIBS MultiMC_logic + ) + +add_unit_test(Library + SOURCES tst_Library.cpp + LIBS MultiMC_logic + ) + +add_unit_test(UpdateChecker + SOURCES tst_UpdateChecker.cpp + LIBS MultiMC_logic + DATA data + ) + +add_unit_test(DownloadTask + SOURCES tst_DownloadTask.cpp + LIBS MultiMC_logic + DATA data_raw + ) + +add_unit_test(filematchers + SOURCES tst_filematchers.cpp + LIBS MultiMC_logic + ) + +add_unit_test(ModList + SOURCES tst_ModList.cpp + LIBS MultiMC_logic + ) + +# add_unit_test(Resource +# SOURCES tst_Resource.cpp +# ) + +add_unit_test(GZip + SOURCES tst_GZip.cpp + LIBS MultiMC_logic + ) + +add_unit_test(JavaVersion + SOURCES tst_JavaVersion.cpp + LIBS MultiMC_logic + ) + +add_unit_test(ParseUtils + SOURCES tst_ParseUtils.cpp + LIBS MultiMC_logic + ) + +add_unit_test(MojangVersionFormat + SOURCES tst_MojangVersionFormat.cpp + LIBS MultiMC_logic + ) + +add_unit_test(WonkoIndex + SOURCES tst_WonkoIndex.cpp + LIBS MultiMC_logic + ) diff --git a/tests/TestUtil.h b/tests/TestUtil.h deleted file mode 100644 index 5b0741b8..00000000 --- a/tests/TestUtil.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include <QFile> -#include <QCoreApplication> -#include <QTest> -#include <QDir> - -#include "test_config.h" - -class TestsInternal -{ -public: - static QByteArray readFile(const QString &fileName) - { - QFile f(fileName); - f.open(QFile::ReadOnly); - return f.readAll(); - } - static QString readFileUtf8(const QString &fileName) - { - return QString::fromUtf8(readFile(fileName)); - } -}; - -#define MULTIMC_GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file)) -#define MULTIMC_GET_TEST_FILE_UTF8(file) TestsInternal::readFileUtf8(QFINDTESTDATA(file)) - diff --git a/tests/copy_tests.cmake b/tests/copy_tests.cmake deleted file mode 100644 index 0af7f730..00000000 --- a/tests/copy_tests.cmake +++ /dev/null @@ -1,13 +0,0 @@ -file(GLOB data_files "${MultiMC_TEST_DATA_PATH_SOURCE}/*") -foreach(data_file ${data_files}) - get_filename_component(filename ${data_file} NAME) - configure_file( - ${data_file} - ${MultiMC_TEST_DATA_PATH}/${filename} - @ONLY - NEWLINE_STYLE LF - ) -endforeach() - -file(GLOB raw_data_files "${MultiMC_TEST_DATA_PATH_SOURCE_RAW}/*") -file(COPY ${raw_data_files} DESTINATION ${MultiMC_TEST_DATA_PATH}/) diff --git a/tests/data/1.json b/tests/data/1.json index 7eda1618..3dd189e5 100644 --- a/tests/data/1.json +++ b/tests/data/1.json @@ -8,7 +8,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_URL@/fileOneA" + "Url": "@TEST_DATA_URL@/fileOneA" } ], "Executable": true, @@ -20,7 +20,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_URL@/fileTwo" + "Url": "@TEST_DATA_URL@/fileTwo" } ], "Executable": false, @@ -32,7 +32,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_URL@/fileThree" + "Url": "@TEST_DATA_URL@/fileThree" } ], "Executable": false, diff --git a/tests/data/2.json b/tests/data/2.json index de7d0e07..a7ba7029 100644 --- a/tests/data/2.json +++ b/tests/data/2.json @@ -8,7 +8,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_URL@/fileOneB" + "Url": "@TEST_DATA_URL@/fileOneB" } ], "Executable": true, @@ -20,7 +20,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_URL@/fileTwo" + "Url": "@TEST_DATA_URL@/fileTwo" } ], "Executable": false, diff --git a/tests/data/channels.json b/tests/data/channels.json index 10eede82..b46c64c8 100644 --- a/tests/data/channels.json +++ b/tests/data/channels.json @@ -5,13 +5,13 @@ "id": "develop", "name": "Develop", "description": "The channel called \"develop\"", - "url": "@MultiMC_TEST_DATA_URL@" + "url": "@TEST_DATA_URL@" }, { "id": "stable", "name": "Stable", "description": "It's stable at least", - "url": "@MultiMC_TEST_DATA_URL@" + "url": "@TEST_DATA_URL@" }, { "id": "42", diff --git a/tests/test.manifest b/tests/test.manifest deleted file mode 100644 index 8b4dbb98..00000000 --- a/tests/test.manifest +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> - <assemblyIdentity name="MultiMC.Test.0" type="win32" version="5.0.0.0" /> - <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> - <security> - <requestedPrivileges> - <requestedExecutionLevel level="asInvoker" uiAccess="false"/> - </requestedPrivileges> - </security> - </trustInfo> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/> - </dependentAssembly> - </dependency> - <description>Custom Minecraft launcher for managing multiple installs.</description> - <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> - <application> - <!--The ID below indicates app support for Windows Vista --> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> - <!--The ID below indicates app support for Windows 7 --> - <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> - <!--The ID below indicates app support for Windows Developer Preview / Windows 8 --> - <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> - </application> - </compatibility> -</assembly>
\ No newline at end of file diff --git a/tests/test.rc b/tests/test.rc deleted file mode 100644 index a288dba6..00000000 --- a/tests/test.rc +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include <windows.h> - -1 RT_MANIFEST "test.manifest" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,0,0,0 -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_APP -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "MultiMC Contributors" - VALUE "FileDescription", "Testcase" - VALUE "FileVersion", "1.0.0.0" - VALUE "ProductName", "MultiMC Testcase" - VALUE "ProductVersion", "5" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0000, 0x04b0 // Unicode - END -END diff --git a/tests/test_config.h.in b/tests/test_config.h.in deleted file mode 100644 index cf59f3e2..00000000 --- a/tests/test_config.h.in +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define MultiMC_TEST_DATA_URL "@MultiMC_TEST_DATA_URL@" diff --git a/tests/tst_BaseWonkoEntityLocalLoadTask.cpp b/tests/tst_BaseWonkoEntityLocalLoadTask.cpp deleted file mode 100644 index 74da222a..00000000 --- a/tests/tst_BaseWonkoEntityLocalLoadTask.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <QTest> -#include "TestUtil.h" - -#include "wonko/tasks/BaseWonkoEntityLocalLoadTask.h" - -class BaseWonkoEntityLocalLoadTaskTest : public QObject -{ - Q_OBJECT -private -slots: -}; - -QTEST_GUILESS_MAIN(BaseWonkoEntityLocalLoadTaskTest) - -#include "tst_BaseWonkoEntityLocalLoadTask.moc" diff --git a/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp b/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp deleted file mode 100644 index 3a12e04e..00000000 --- a/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <QTest> -#include "TestUtil.h" - -#include "wonko/tasks/BaseWonkoEntityRemoteLoadTask.h" - -class BaseWonkoEntityRemoteLoadTaskTest : public QObject -{ - Q_OBJECT -private -slots: -}; - -QTEST_GUILESS_MAIN(BaseWonkoEntityRemoteLoadTaskTest) - -#include "tst_BaseWonkoEntityRemoteLoadTask.moc" diff --git a/tests/tst_UpdateChecker.cpp b/tests/tst_UpdateChecker.cpp index de1ad718..3a0d3781 100644 --- a/tests/tst_UpdateChecker.cpp +++ b/tests/tst_UpdateChecker.cpp @@ -8,6 +8,7 @@ Q_DECLARE_METATYPE(UpdateChecker::ChannelListEntry) bool operator==(const UpdateChecker::ChannelListEntry &e1, const UpdateChecker::ChannelListEntry &e2) { + qDebug() << e1.url << "vs" << e2.url; return e1.id == e2.id && e1.name == e2.name && e1.description == e2.description && @@ -76,8 +77,8 @@ slots: << true << true << (QList<UpdateChecker::ChannelListEntry>() - << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", MultiMC_TEST_DATA_URL} - << UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", MultiMC_TEST_DATA_URL} + << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", findTestDataUrl("tests/data")} + << UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", findTestDataUrl("tests/data")} << UpdateChecker::ChannelListEntry{"42", "The Channel", "This is the channel that is going to answer all of your questions", "https://dent.me/tea"}); } void tst_ChannelListParsing() diff --git a/tests/tst_WonkoVersionList.cpp b/tests/tst_WonkoVersionList.cpp deleted file mode 100644 index 7cb21df7..00000000 --- a/tests/tst_WonkoVersionList.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <QTest> -#include "TestUtil.h" - -#include "wonko/WonkoVersionList.h" - -class WonkoVersionListTest : public QObject -{ - Q_OBJECT -private -slots: -}; - -QTEST_GUILESS_MAIN(WonkoVersionListTest) - -#include "tst_WonkoVersionList.moc" |