forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mixxxdj#12995 from acolombier/chore/add-setting-to…
…-traktor-s4mk3 feat: add setting definition for Traktor S4 MK3
- Loading branch information
Showing
6 changed files
with
779 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/test/controllers/controller_columnid_regression_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
This test case is used to ensure that hardcoded CO value in the the settings | ||
definition matches with Mixxx value and will help detecting regression if they | ||
are ever updated. | ||
Currently, the S4 MK3 is referencing library column ID in its setting, so this | ||
test ensure that the value always matches with the Mixxx spec. New controllers | ||
can be added by duplicated the `ensureS4MK3` case and adapt as needed | ||
*/ | ||
#include "controllers/legacycontrollermapping.h" | ||
#include "controllers/legacycontrollermappingfilehandler.h" | ||
#include "library/trackmodel.h" | ||
#include "test/mixxxtest.h" | ||
#include "util/time.h" | ||
|
||
class ControllerLibraryColumnIDRegressionTest : public MixxxTest { | ||
protected: | ||
void SetUp() override { | ||
mixxx::Time::setTestMode(true); | ||
mixxx::Time::setTestElapsedTime(mixxx::Duration::fromMillis(10)); | ||
} | ||
|
||
void TearDown() override { | ||
mixxx::Time::setTestMode(false); | ||
} | ||
|
||
static QHash<QString, TrackModel::SortColumnId> COLUMN_MAPPING; | ||
}; | ||
|
||
QHash<QString, TrackModel::SortColumnId> | ||
ControllerLibraryColumnIDRegressionTest::COLUMN_MAPPING = { | ||
{"Artist", TrackModel::SortColumnId::Artist}, | ||
{"Title", TrackModel::SortColumnId::Title}, | ||
{"Album", TrackModel::SortColumnId::Album}, | ||
{"Album Artist", TrackModel::SortColumnId::AlbumArtist}, | ||
{"Year", TrackModel::SortColumnId::Year}, | ||
{"Genre", TrackModel::SortColumnId::Genre}, | ||
{"Composer", TrackModel::SortColumnId::Composer}, | ||
{"Grouping", TrackModel::SortColumnId::Grouping}, | ||
{"Track Number", TrackModel::SortColumnId::TrackNumber}, | ||
{"File Type", TrackModel::SortColumnId::FileType}, | ||
{"Native Location", TrackModel::SortColumnId::NativeLocation}, | ||
{"Comment", TrackModel::SortColumnId::Comment}, | ||
{"Duration", TrackModel::SortColumnId::Duration}, | ||
{"Bitrate", TrackModel::SortColumnId::BitRate}, | ||
{"BPM", TrackModel::SortColumnId::Bpm}, | ||
{"Replay Gain", TrackModel::SortColumnId::ReplayGain}, | ||
{"Datetime Added", TrackModel::SortColumnId::DateTimeAdded}, | ||
{"Times Played", TrackModel::SortColumnId::TimesPlayed}, | ||
{"Rating", TrackModel::SortColumnId::Rating}, | ||
{"Key", TrackModel::SortColumnId::Key}, | ||
// More mapping can be added here if needed. | ||
// NOTE: If some of the missing value are referenced in a | ||
// controller setting, test case will fail. | ||
}; | ||
|
||
TEST_F(ControllerLibraryColumnIDRegressionTest, ensureS4MK3) { | ||
std::shared_ptr<LegacyControllerMapping> pMapping = | ||
LegacyControllerMappingFileHandler::loadMapping( | ||
QFileInfo("res/controllers/Traktor Kontrol S4 MK3.hid.xml"), QDir()); | ||
EXPECT_TRUE(pMapping); | ||
auto settings = pMapping->getSettings(); | ||
EXPECT_TRUE(!settings.isEmpty()); | ||
|
||
const int expectedSettingCount = 6; // Number of settings using library count. | ||
int count = 0; | ||
for (const auto& setting : settings) { | ||
if (!setting->variableName().startsWith("librarySortableColumns")) { | ||
continue; | ||
} | ||
auto pEnum = std::dynamic_pointer_cast<LegacyControllerEnumSetting>(setting); | ||
EXPECT_TRUE(pEnum); | ||
for (const auto& opt : pEnum->options()) { | ||
EXPECT_EQ(static_cast<int>(COLUMN_MAPPING[std::get<0>(opt)]), std::get<1>(opt).toInt()); | ||
} | ||
count++; | ||
} | ||
EXPECT_EQ(count, expectedSettingCount); | ||
} |