summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--logic/Env.cpp17
-rw-r--r--logic/Env.h12
-rw-r--r--logic/updater/UpdateChecker.cpp41
-rw-r--r--tests/CMakeLists.txt7
-rw-r--r--tests/TestUtil.h22
-rw-r--r--tests/tst_DownloadUpdateTask.cpp2
-rw-r--r--tests/tst_UpdateChecker.cpp5
-rw-r--r--tests/tst_gradlespecifier.cpp6
-rw-r--r--tests/tst_inifile.cpp4
-rw-r--r--tests/tst_pathutils.cpp2
-rw-r--r--tests/tst_userutils.cpp2
12 files changed, 55 insertions, 67 deletions
diff --git a/.travis.yml b/.travis.yml
index 9dbf7e3d..978c97e9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,6 @@ before_script:
- cmake -DCMAKE_PREFIX_PATH=/opt/qt52/lib/cmake ..
script:
- make -j4
- - make test
+ - make test ARGS="-V"
notifications:
email: false
diff --git a/logic/Env.cpp b/logic/Env.cpp
index de93ded3..daf17d65 100644
--- a/logic/Env.cpp
+++ b/logic/Env.cpp
@@ -4,11 +4,12 @@
#include <QNetworkProxy>
#include <QNetworkAccessManager>
#include "logger/QsLog.h"
-#include "MultiMC.h"
+
+#include <QDebug>
Env::Env()
{
- // null
+ m_qnam = std::make_shared<QNetworkAccessManager>();
}
void Env::destroy()
@@ -23,6 +24,18 @@ Env& Env::Env::getInstance()
return instance;
}
+std::shared_ptr< HttpMetaCache > Env::metacache()
+{
+ Q_ASSERT(m_metacache != nullptr);
+ return m_metacache;
+}
+
+std::shared_ptr< QNetworkAccessManager > Env::qnam()
+{
+ return m_qnam;
+}
+
+
void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
{
m_metacache.reset(new HttpMetaCache("metacache"));
diff --git a/logic/Env.h b/logic/Env.h
index 523c51f0..3d560a29 100644
--- a/logic/Env.h
+++ b/logic/Env.h
@@ -22,15 +22,9 @@ public:
// call when Qt stuff is being torn down
void destroy();
- std::shared_ptr<QNetworkAccessManager> qnam()
- {
- return m_qnam;
- }
-
- std::shared_ptr<HttpMetaCache> metacache()
- {
- return m_metacache;
- }
+ std::shared_ptr<QNetworkAccessManager> qnam();
+
+ std::shared_ptr<HttpMetaCache> metacache();
/// init the cache. FIXME: possible future hook point
void initHttpMetaCache(QString rootPath, QString staticDataPath);
diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp
index cd0b3c72..8ac84bf1 100644
--- a/logic/updater/UpdateChecker.cpp
+++ b/logic/updater/UpdateChecker.cpp
@@ -15,11 +15,10 @@
#include "UpdateChecker.h"
-#include "logger/QsLog.h"
-
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
+#include <QDebug>
#define API_VERSION 0
#define CHANLIST_FORMAT 0
@@ -46,13 +45,13 @@ bool UpdateChecker::hasChannels() const
void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
{
- QLOG_DEBUG() << "Checking for updates.";
+ qDebug() << "Checking for updates.";
// If the channel list hasn't loaded yet, load it and defer checking for updates until
// later.
if (!m_chanListLoaded)
{
- QLOG_DEBUG() << "Channel list isn't loaded yet. Loading channel list and deferring "
+ qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring "
"update check.";
m_checkUpdateWaiting = true;
m_deferredUpdateChannel = updateChannel;
@@ -62,7 +61,7 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
if (m_updateChecking)
{
- QLOG_DEBUG() << "Ignoring update check request. Already checking for updates.";
+ qDebug() << "Ignoring update check request. Already checking for updates.";
return;
}
@@ -77,9 +76,12 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
m_repoUrl = entry.url;
}
+ qDebug() << "m_repoUrl = " << m_repoUrl;
+
// If we didn't find our channel, error.
if (m_repoUrl.isEmpty())
{
+ qCritical() << "m_repoUrl is empty!";
emit updateCheckFailed();
return;
}
@@ -97,7 +99,7 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
{
- QLOG_DEBUG() << "Finished downloading repo index. Checking for new versions.";
+ qDebug() << "Finished downloading repo index. Checking for new versions.";
QJsonParseError jsonError;
QByteArray data;
@@ -111,7 +113,7 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
if (jsonError.error != QJsonParseError::NoError || !jsonDoc.isObject())
{
- QLOG_ERROR() << "Failed to parse GoUpdate repository index. JSON error"
+ qCritical() << "Failed to parse GoUpdate repository index. JSON error"
<< jsonError.errorString() << "at offset" << jsonError.offset;
return;
}
@@ -122,12 +124,12 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
int apiVersion = object.value("ApiVersion").toVariant().toInt(&success);
if (apiVersion != API_VERSION || !success)
{
- QLOG_ERROR() << "Failed to check for updates. API version mismatch. We're using"
+ qCritical() << "Failed to check for updates. API version mismatch. We're using"
<< API_VERSION << "server has" << apiVersion;
return;
}
- QLOG_DEBUG() << "Processing repository version list.";
+ qDebug() << "Processing repository version list.";
QJsonObject newestVersion;
QJsonArray versions = object.value("Versions").toArray();
for (QJsonValue versionVal : versions)
@@ -145,7 +147,7 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
int newBuildNumber = newestVersion.value("Id").toVariant().toInt();
if (newBuildNumber != m_currentBuild)
{
- QLOG_DEBUG() << "Found newer version with ID" << newBuildNumber;
+ qDebug() << "Found newer version with ID" << newBuildNumber;
// Update!
emit updateAvailable(m_repoUrl, newestVersion.value("Name").toVariant().toString(),
newBuildNumber);
@@ -160,18 +162,17 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
void UpdateChecker::updateCheckFailed()
{
- // TODO: log errors better
- QLOG_ERROR() << "Update check failed for reasons unknown.";
+ qCritical() << "Update check failed for reasons unknown.";
}
void UpdateChecker::updateChanList(bool notifyNoUpdate)
{
- QLOG_DEBUG() << "Loading the channel list.";
+ qDebug() << "Loading the channel list.";
if (m_channelListUrl.isEmpty())
{
- QLOG_ERROR() << "Failed to update channel list. No channel list URL set."
- << "If you'd like to use MultiMC's update system, please pass the channel "
+ qCritical() << "Failed to update channel list. No channel list URL set."
+ << "If you'd like to use MultiMC's update system, please pass the channel "
"list URL to CMake at compile time.";
return;
}
@@ -201,7 +202,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
if (jsonError.error != QJsonParseError::NoError)
{
// TODO: Report errors to the user.
- QLOG_ERROR() << "Failed to parse channel list JSON:" << jsonError.errorString() << "at"
+ qCritical() << "Failed to parse channel list JSON:" << jsonError.errorString() << "at"
<< jsonError.offset;
return;
}
@@ -212,7 +213,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
int formatVersion = object.value("format_version").toVariant().toInt(&success);
if (formatVersion != CHANLIST_FORMAT || !success)
{
- QLOG_ERROR()
+ qCritical()
<< "Failed to check for updates. Channel list format version mismatch. We're using"
<< CHANLIST_FORMAT << "server has" << formatVersion;
return;
@@ -230,7 +231,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
channelObj.value("url").toVariant().toString()};
if (entry.id.isEmpty() || entry.name.isEmpty() || entry.url.isEmpty())
{
- QLOG_ERROR() << "Channel list entry with empty ID, name, or URL. Skipping.";
+ qCritical() << "Channel list entry with empty ID, name, or URL. Skipping.";
continue;
}
loadedChannels.append(entry);
@@ -241,7 +242,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
m_chanListLoading = false;
m_chanListLoaded = true;
- QLOG_INFO() << "Successfully loaded UpdateChecker channel list.";
+ qDebug() << "Successfully loaded UpdateChecker channel list.";
// If we're waiting to check for updates, do that now.
if (m_checkUpdateWaiting)
@@ -253,7 +254,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
void UpdateChecker::chanListDownloadFailed()
{
m_chanListLoading = false;
- QLOG_ERROR() << "Failed to download channel list.";
+ qCritical() << "Failed to download channel list.";
emit channelListLoaded();
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7afb3f80..2f6b1a63 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
# run the unit tests with `make test`
-find_package(Qt5 COMPONENTS Test Core Network Widgets)
+find_package(Qt5 COMPONENTS Test Core Network)
include_directories(${MMC_SRC})
@@ -13,7 +13,7 @@ macro(add_unit_test name)
endif()
endforeach()
add_executable(tst_${name} ${srcs})
- qt5_use_modules(tst_${name} Test Core Network Widgets)
+ qt5_use_modules(tst_${name} Test Core Network)
target_link_libraries(tst_${name} MultiMC_common)
list(APPEND MultiMC_TESTS tst_${name})
add_test(NAME ${name} COMMAND tst_${name})
@@ -30,7 +30,7 @@ add_unit_test(UpdateChecker tst_UpdateChecker.cpp)
add_unit_test(DownloadUpdateTask tst_DownloadUpdateTask.cpp)
# Tests END #
-
+
set(COVERAGE_SOURCE_DIRS
${MMC_SRC}/logic/*
${MMC_SRC}/logic/auth/*
@@ -88,6 +88,7 @@ if(MultiMC_CODE_COVERAGE)
endif(MultiMC_CODE_COVERAGE)
set(MultiMC_TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data")
+message("${CMAKE_CURRENT_BINARY_DIR}/data")
if(UNIX)
# on unix we get the third / from the filename
set(MultiMC_TEST_DATA_PATH "file://${MultiMC_TEST_DATA_PATH}")
diff --git a/tests/TestUtil.h b/tests/TestUtil.h
index 87a910d9..5b0741b8 100644
--- a/tests/TestUtil.h
+++ b/tests/TestUtil.h
@@ -5,8 +5,6 @@
#include <QTest>
#include <QDir>
-#include "MultiMC.h"
-
#include "test_config.h"
class TestsInternal
@@ -27,23 +25,3 @@ public:
#define MULTIMC_GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file))
#define MULTIMC_GET_TEST_FILE_UTF8(file) TestsInternal::readFileUtf8(QFINDTESTDATA(file))
-#ifdef Q_OS_LINUX
-#define _MMC_EXTRA_ARGV , "-platform", "offscreen"
-#define _MMC_EXTRA_ARGC 2
-#else
-#define _MMC_EXTRA_ARGV
-#define _MMC_EXTRA_ARGC 0
-#endif
-
-
-
-#define QTEST_GUILESS_MAIN_MULTIMC(TestObject) \
-int main(int argc, char *argv[]) \
-{ \
- const char *argv_[] = { argv[0] _MMC_EXTRA_ARGV }; \
- int argc_ = 1 + _MMC_EXTRA_ARGC; \
- MultiMC app(argc_, const_cast<char**>(argv_), true); \
- app.setAttribute(Qt::AA_Use96Dpi, true); \
- TestObject tc; \
- return QTest::qExec(&tc, argc, argv); \
-}
diff --git a/tests/tst_DownloadUpdateTask.cpp b/tests/tst_DownloadUpdateTask.cpp
index 8d8905b5..88c4d3d8 100644
--- a/tests/tst_DownloadUpdateTask.cpp
+++ b/tests/tst_DownloadUpdateTask.cpp
@@ -268,6 +268,6 @@ slots:
}
};
-QTEST_GUILESS_MAIN_MULTIMC(DownloadUpdateTaskTest)
+QTEST_GUILESS_MAIN(DownloadUpdateTaskTest)
#include "tst_DownloadUpdateTask.moc"
diff --git a/tests/tst_UpdateChecker.cpp b/tests/tst_UpdateChecker.cpp
index 49a4a6a3..75c5dcdd 100644
--- a/tests/tst_UpdateChecker.cpp
+++ b/tests/tst_UpdateChecker.cpp
@@ -140,7 +140,8 @@ slots:
checker.updateChanList(false);
QVERIFY(channelListLoadedSpy.wait());
- checker.m_channels[0].url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("tests/data/")).toString();
+ qDebug() << "CWD:" << QDir::current().absolutePath();
+ checker.m_channels[0].url = findTestDataUrl("tests/data/");
checker.checkForUpdate(channel, false);
@@ -151,6 +152,6 @@ slots:
}
};
-QTEST_GUILESS_MAIN_MULTIMC(UpdateCheckerTest)
+QTEST_GUILESS_MAIN(UpdateCheckerTest)
#include "tst_UpdateChecker.moc"
diff --git a/tests/tst_gradlespecifier.cpp b/tests/tst_gradlespecifier.cpp
index 69dd54f7..56c29b85 100644
--- a/tests/tst_gradlespecifier.cpp
+++ b/tests/tst_gradlespecifier.cpp
@@ -32,7 +32,7 @@ slots:
QFETCH(QString, through);
QString converted = GradleSpecifier(through);
-
+
QCOMPARE(converted, through);
}
@@ -50,7 +50,7 @@ slots:
QFETCH(QString, expected);
QString converted = GradleSpecifier(spec).toPath();
-
+
QCOMPARE(converted, expected);
}
void test_Negative_data()
@@ -72,6 +72,6 @@ slots:
}
};
-QTEST_GUILESS_MAIN_MULTIMC(GradleSpecifierTest)
+QTEST_GUILESS_MAIN(GradleSpecifierTest)
#include "tst_gradlespecifier.moc"
diff --git a/tests/tst_inifile.cpp b/tests/tst_inifile.cpp
index 93930ae9..6bec32f5 100644
--- a/tests/tst_inifile.cpp
+++ b/tests/tst_inifile.cpp
@@ -33,11 +33,11 @@ slots:
QString there = INIFile::escape(through);
QString back = INIFile::unescape(there);
-
+
QCOMPARE(back, through);
}
};
-QTEST_GUILESS_MAIN_MULTIMC(IniFileTest)
+QTEST_GUILESS_MAIN(IniFileTest)
#include "tst_inifile.moc"
diff --git a/tests/tst_pathutils.cpp b/tests/tst_pathutils.cpp
index a1310d00..eed5b560 100644
--- a/tests/tst_pathutils.cpp
+++ b/tests/tst_pathutils.cpp
@@ -69,6 +69,6 @@ slots:
}
};
-QTEST_GUILESS_MAIN_MULTIMC(PathUtilsTest)
+QTEST_GUILESS_MAIN(PathUtilsTest)
#include "tst_pathutils.moc"
diff --git a/tests/tst_userutils.cpp b/tests/tst_userutils.cpp
index 3bc980c0..893e064e 100644
--- a/tests/tst_userutils.cpp
+++ b/tests/tst_userutils.cpp
@@ -66,6 +66,6 @@ slots:
};
-QTEST_GUILESS_MAIN_MULTIMC(UserUtilsTest)
+QTEST_GUILESS_MAIN(UserUtilsTest)
#include "tst_userutils.moc"