1 parent
41599fa82f
commit
0dd6bef715
12 files changed
+161
-64
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QScopeGuard>
|
||||
|
||||
class TestLauncherPaths : public QObject
|
||||
{
|
||||
@@ -22,7 +23,9 @@ private slots:
|
||||
|
||||
void containerPerPlatform()
|
||||
{
|
||||
const QString home = QDir::homePath();
|
||||
// Не QDir::homePath(): на Windows он смотрит в настоящий профиль, а пути
|
||||
// лаунчера в тестах идут от BILAUNCHER_HOME (песочницы).
|
||||
const QString home = QDir::cleanPath(TestEnv::homeDir());
|
||||
#if defined(Q_OS_WIN)
|
||||
QCOMPARE(LauncherPaths::containerDir(), home + QStringLiteral("/AppData/Roaming"));
|
||||
QCOMPARE(LauncherPaths::defaultMinecraftDir(), LauncherPaths::containerDir() + "/.minecraft");
|
||||
@@ -35,6 +38,25 @@ private slots:
|
||||
#endif
|
||||
}
|
||||
|
||||
void homeOverrideFromEnvironment()
|
||||
{
|
||||
const QString saved = qEnvironmentVariable("BILAUNCHER_HOME");
|
||||
const auto restore = qScopeGuard([&] { TestEnv::setEnvPath("BILAUNCHER_HOME", saved); });
|
||||
|
||||
QCOMPARE(LauncherPaths::homeOverride(), QDir::cleanPath(TestEnv::homeDir()));
|
||||
|
||||
const QString other = TestEnv::freshDir("other-home");
|
||||
TestEnv::setEnvPath("BILAUNCHER_HOME", QDir::toNativeSeparators(other));
|
||||
QCOMPARE(LauncherPaths::homeOverride(), QDir::cleanPath(other));
|
||||
QVERIFY(LauncherPaths::rootDir().startsWith(QDir::cleanPath(other) + u'/'));
|
||||
|
||||
// Относительный путь зависел бы от текущей папки — игнорируется, как и пустой.
|
||||
for (const char *ignored : {"relative/home", ""}) {
|
||||
qputenv("BILAUNCHER_HOME", ignored);
|
||||
QVERIFY2(LauncherPaths::homeOverride().isEmpty(), ignored);
|
||||
}
|
||||
}
|
||||
|
||||
void filesLayout_data()
|
||||
{
|
||||
QTest::addColumn<QString>("actual");
|
||||
|
||||
Reference in new issue
Block a user