Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
working-directory: build
env:
# Render analyzer waveform tests to an offscreen buffer
QT_QPA_PLATFORM: ${{ matrix.qt_qpa_platform }}
QT_QPA_PLATFORM: offscreen
GTEST_COLOR: 1
# Only use single thread to prevent *.gcna files from overwriting each other
CTEST_PARALLEL_LEVEL: 1
Expand Down
16 changes: 4 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2824,23 +2824,15 @@ if(BUILD_TESTING)
include(CTest)
include(GoogleTest)
enable_testing()
gtest_add_tests(
TARGET mixxx-test
gtest_discover_tests(
mixxx-test
EXTRA_ARGS --logLevel info
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen"
TEST_LIST testsuite
DISCOVERY_MODE PRE_TEST
)

if(NOT WIN32)
# Default to offscreen rendering during tests.
# This is required if the build system like Fedora koji/mock does not
# allow to pass environment variables into the ctest macro expansion.
set_tests_properties(
${testsuite}
PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen"
)
endif()

if(BUILD_BENCH)
# Benchmarking
add_custom_target(
Expand Down
40 changes: 30 additions & 10 deletions src/test/stemcontrolobjecttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
#include <memory>

#include "control/pollingcontrolproxy.h"
#include "gtest/gtest.h"
#include "mixxxtest.h"
#include "test/signalpathtest.h"

class StemControlTest : public BaseSignalPathTest {
protected:
#define STEM_FILE QStringLiteral("stems/sin_%1.stem.mp4").arg(QString::fromStdString(GetParam()))

namespace {
const std::vector<std::string> supportedCodecs = {
#if !defined(Q_OS_WIN)
"AAC_256kbps_VBR",
#endif
"ALAC_24bit"};
} // namespace

class StemControlFixture : public BaseSignalPathTest,
public ::testing::WithParamInterface<std::string> {
public:
QString getGroupForStem(QStringView deckGroup, int stemNr) {
DEBUG_ASSERT(deckGroup.endsWith(QChar(']')) && stemNr <= 4);
return deckGroup.chopped(1) + QStringLiteral("_Stem") + QChar('0' + stemNr) + QChar(']');
Expand Down Expand Up @@ -41,7 +53,7 @@ class StemControlTest : public BaseSignalPathTest {
m_pEffectsManager->addStem(stemHandleGroup);
}

const QString kStemFileLocationTest = getTestDir().filePath("stems/test.stem.mp4");
const QString kStemFileLocationTest = getTestDir().filePath(STEM_FILE);
TrackPointer pStemFile(Track::newTemporary(kStemFileLocationTest));

loadTrack(m_pMixerDeck1, pStemFile);
Expand Down Expand Up @@ -142,7 +154,7 @@ class StemControlTest : public BaseSignalPathTest {
std::unique_ptr<PollingControlProxy> m_pStemCount;
};

TEST_F(StemControlTest, StemCount) {
TEST_P(StemControlFixture, StemCount) {
Comment thread
acolombier marked this conversation as resolved.
EXPECT_EQ(m_pStemCount->get(), 4.0);

QString kTrackLocationTest = getTestDir().filePath(QStringLiteral("sine-30.wav"));
Expand All @@ -151,14 +163,14 @@ TEST_F(StemControlTest, StemCount) {

EXPECT_EQ(m_pStemCount->get(), 0.0);

kTrackLocationTest = getTestDir().filePath("stems/test.stem.mp4");
kTrackLocationTest = getTestDir().filePath(STEM_FILE);
pTrack = Track::newTemporary(kTrackLocationTest);
loadTrack(m_pMixerDeck1, pTrack);

EXPECT_EQ(m_pStemCount->get(), 4.0);
}

TEST_F(StemControlTest, StemColor) {
TEST_P(StemControlFixture, StemColor) {
EXPECT_EQ(m_pStem1Color->get(), 0xfd << 16 | 0x4a << 8 | 0x4a);
EXPECT_EQ(m_pStem2Color->get(), 0xff << 16 | 0xff << 8 | 0x00);
EXPECT_EQ(m_pStem3Color->get(), 0x00 << 16 | 0xe8 << 8 | 0xe8);
Expand All @@ -173,7 +185,7 @@ TEST_F(StemControlTest, StemColor) {
EXPECT_EQ(m_pStem3Color->get(), -1.0);
EXPECT_EQ(m_pStem4Color->get(), -1.0);

kTrackLocationTest = getTestDir().filePath("stems/test.stem.mp4");
kTrackLocationTest = getTestDir().filePath(STEM_FILE);
pTrack = Track::newTemporary(kTrackLocationTest);
loadTrack(m_pMixerDeck1, pTrack);

Expand All @@ -183,7 +195,7 @@ TEST_F(StemControlTest, StemColor) {
EXPECT_EQ(m_pStem4Color->get(), 0xad << 16 | 0x65 << 8 | 0xff);
}

TEST_F(StemControlTest, DISABLED_Volume) {
TEST_P(StemControlFixture, Volume) {
m_pChannel1->getEngineBuffer()->queueNewPlaypos(
mixxx::audio::FramePos{0}, EngineBuffer::SEEK_STANDARD);
m_pPlay->set(1.0);
Expand Down Expand Up @@ -231,7 +243,7 @@ TEST_F(StemControlTest, DISABLED_Volume) {
QStringLiteral("StemVolumeControlFull"));
}

TEST_F(StemControlTest, VolumeResetOnLoad) {
TEST_P(StemControlFixture, VolumeResetOnLoad) {
m_pStem1Volume->set(0.1);
m_pStem2Volume->set(0.2);
m_pStem3Volume->set(0.3);
Expand Down Expand Up @@ -270,7 +282,7 @@ TEST_F(StemControlTest, VolumeResetOnLoad) {
EXPECT_EQ(m_pStem4Mute->get(), 0.0);
}

TEST_F(StemControlTest, DISABLED_Mute) {
TEST_P(StemControlFixture, Mute) {
m_pChannel1->getEngineBuffer()->queueNewPlaypos(
mixxx::audio::FramePos{0}, EngineBuffer::SEEK_STANDARD);
m_pPlay->set(1.0);
Expand Down Expand Up @@ -316,3 +328,11 @@ TEST_F(StemControlTest, DISABLED_Mute) {
assertBufferMatchesReference(m_pEngineMixer->getMainBuffer(),
QStringLiteral("StemMuteControlFull"));
}

INSTANTIATE_TEST_SUITE_P(
StemControlTest,
StemControlFixture,
::testing::ValuesIn(supportedCodecs),
[](const testing::TestParamInfo<StemControlFixture::ParamType>& info) {
return info.param;
});
Binary file added src/test/stems/sin_ALAC_24bit.stem.mp4
Binary file not shown.
36 changes: 26 additions & 10 deletions src/test/stemtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@

using namespace mixxx;

#define STEM_FILE QStringLiteral("stems/sin_%1.stem.mp4").arg(QString::fromStdString(GetParam()))

namespace {

const std::vector<std::string> supportedCodecs = {
#if !defined(Q_OS_WIN)
"AAC_256kbps_VBR",
#endif
"ALAC_24bit"};

const QList<QString> kStemFiles = {
"01-drum.wav",
"02-bass.wav",
"03-melody.wav",
"04-vocal.wav",
};

class StemTest : public MixxxTest {
class StemFixture : public MixxxTest, public ::testing::WithParamInterface<std::string> {
protected:
void SetUp() override {
ASSERT_TRUE(SoundSourceProxy::isFileTypeSupported("stem.mp4") ||
SoundSourceProxy::registerProviders());
}
};

TEST_F(StemTest, FetchStemInfo) {
TrackPointer pTrack(Track::newTemporary(getTestDir().filePath("stems/test.stem.mp4")));
TEST_P(StemFixture, FetchStemInfo) {
TrackPointer pTrack(Track::newTemporary(getTestDir().filePath(STEM_FILE)));

mixxx::AudioSource::OpenParams config;
config.setChannelCount(mixxx::audio::ChannelCount(2));
Expand All @@ -42,7 +50,7 @@ TEST_F(StemTest, FetchStemInfo) {
ASSERT_EQ(stemInfo.at(3), StemInfo("Vox", QColor(0xad, 0x65, 0xff))); // #ad65ff
}

TEST_F(StemTest, FetchStemEmptyInfo) {
TEST_P(StemFixture, FetchStemEmptyInfo) {
TrackPointer pTrack(Track::newTemporary(
getTestDir().filePath("stems/test_missing_stem_details.stem.mp4")));

Expand All @@ -59,10 +67,10 @@ TEST_F(StemTest, FetchStemEmptyInfo) {
ASSERT_EQ(stemInfo.at(3), StemInfo("Stem #4", QColor(0x56, 0xB4, 0xE9)));
}

TEST_F(StemTest, ReadMainMix) {
TEST_P(StemFixture, ReadMainMix) {
SoundSourceFFmpeg sourceMainMix(
QUrl::fromLocalFile(getTestDir().filePath("stems/mainmix.wav")));
SoundSourceSTEM sourceStem(QUrl::fromLocalFile(getTestDir().filePath("stems/test.stem.mp4")));
SoundSourceSTEM sourceStem(QUrl::fromLocalFile(getTestDir().filePath(STEM_FILE)));

mixxx::AudioSource::OpenParams config;
config.setChannelCount(mixxx::audio::ChannelCount(2));
Expand Down Expand Up @@ -96,14 +104,14 @@ TEST_F(StemTest, ReadMainMix) {
EXPECT_TRUE(0 == std::memcmp(buffer1.data(), buffer1.data(), sizeof(buffer1)));
}

TEST_F(StemTest, ReadEachStem) {
TEST_P(StemFixture, ReadEachStem) {
int stemIdx = 0;
for (auto& stem : kStemFiles) {
SoundSourceFFmpeg sourceStandaloneStem(
QUrl::fromLocalFile(getTestDir().filePath("stems/" + stem)));
SoundSourceSingleSTEM sourceStem(
QUrl::fromLocalFile(
getTestDir().filePath("stems/test.stem.mp4")),
getTestDir().filePath(STEM_FILE)),
stemIdx++);

mixxx::AudioSource::OpenParams config;
Expand Down Expand Up @@ -139,8 +147,8 @@ TEST_F(StemTest, ReadEachStem) {
}
}

TEST_F(StemTest, OpenStem) {
SoundSourceSTEM sourceStem(QUrl::fromLocalFile(getTestDir().filePath("stems/test.stem.mp4")));
TEST_P(StemFixture, OpenStem) {
SoundSourceSTEM sourceStem(QUrl::fromLocalFile(getTestDir().filePath(STEM_FILE)));

mixxx::AudioSource::OpenParams config;
config.setChannelCount(mixxx::audio::ChannelCount(8));
Expand All @@ -152,4 +160,12 @@ TEST_F(StemTest, OpenStem) {
sourceStem.getSignalInfo());
}

INSTANTIATE_TEST_SUITE_P(
StemTest,
StemFixture,
::testing::ValuesIn(supportedCodecs),
[](const testing::TestParamInfo<StemFixture::ParamType>& info) {
return info.param;
});

} // namespace
Loading