Skip to content

Commit

Permalink
Unit test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed May 6, 2017
1 parent ccd369b commit 055766c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ ConfigManager::ConfigManager() :

// If we're in development (lmms is not installed) let's get the source and
// binary directories by reading the CMake Cache
QFile cmakeCache(qApp->applicationDirPath() + "/CMakeCache.txt");
QDir appPath = qApp->applicationDirPath();
// If in tests, get parent directory
if (appPath.dirName() == "tests") {
appPath.cdUp();
}
QFile cmakeCache(appPath.absoluteFilePath("CMakeCache.txt"));
if (cmakeCache.exists()) {
cmakeCache.open(QFile::ReadOnly);
QTextStream stream(&cmakeCache);
Expand Down
9 changes: 7 additions & 2 deletions tests/src/core/RelativePathsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ class RelativePathsTest : QTestSuite
private slots:
void RelativePathComparisonTests()
{
QVERIFY(SampleBuffer::tryToMakeRelative(QDir::currentPath() + "/data/samples/drums/kick01.ogg") == "drums/kick01.ogg");
QVERIFY(SampleBuffer::tryToMakeAbsolute("drums/kick01.ogg") == QDir::currentPath() + "/data/samples/drums/kick01.ogg");
QFileInfo fi(ConfigManager::inst()->factorySamplesDir() + "/drums/kick01.ogg");
QVERIFY(fi.exists());

QString absPath = fi.absoluteFilePath();
QString relPath = "drums/kick01.ogg";
QCOMPARE(SampleBuffer::tryToMakeRelative(absPath), relPath);
QCOMPARE(SampleBuffer::tryToMakeAbsolute(relPath), absPath);
}
} RelativePathTests;

Expand Down

0 comments on commit 055766c

Please sign in to comment.