From 17399dcdb530626896f31d678a4392bb6dc445bd Mon Sep 17 00:00:00 2001 From: Antoine C Date: Sun, 19 May 2024 16:36:44 +0100 Subject: [PATCH] Add mapping resource by struct instead or arg --- src/controllers/defs_controllers.h | 1 - src/controllers/legacycontrollermapping.h | 57 +---- .../legacycontrollermappingfilehandler.cpp | 25 +- .../controller_mapping_file_handler_test.cpp | 227 +++++++++--------- 4 files changed, 140 insertions(+), 170 deletions(-) diff --git a/src/controllers/defs_controllers.h b/src/controllers/defs_controllers.h index 7e3471671b97..5872f3953a86 100644 --- a/src/controllers/defs_controllers.h +++ b/src/controllers/defs_controllers.h @@ -25,5 +25,4 @@ inline QString userMappingsPath(UserSettingsPointer pConfig) { #define HID_MAPPING_EXTENSION ".hid.xml" #define MIDI_MAPPING_EXTENSION ".midi.xml" #define BULK_MAPPING_EXTENSION ".bulk.xml" -#define REQUIRED_SCRIPT_FILE "common-controller-scripts.js" #define XML_SCHEMA_VERSION "1" diff --git a/src/controllers/legacycontrollermapping.h b/src/controllers/legacycontrollermapping.h index e82cece758ff..3c74c7c85889 100644 --- a/src/controllers/legacycontrollermapping.h +++ b/src/controllers/legacycontrollermapping.h @@ -65,15 +65,13 @@ class LegacyControllerMapping { #endif }; - ScriptFileInfo() - : builtin(false) { - } - - QString name; - QString identifier; - QFileInfo file; - Type type; - bool builtin; + QString name; // Name of the script file to add. + QString identifier; // The script's function prefix with Javascript OR + // the screen identifier this QML should be run for + // (or empty string). + QFileInfo file; // A FileInfo object pointing to the script file. + Type type; // A ScriptFileInfo::Type the specify script file type. + bool builtin; // If this is true, the script won't be written to the XML. }; // TODO (xxx): this is a temporary solution to address devices that don't @@ -126,24 +124,9 @@ class LegacyControllerMapping { #endif /// Adds a script file to the list of controller scripts for this mapping. - /// @param filename Name of the script file to add. - /// @param identifier The script's function prefix with Javascript OR the - /// screen identifier this QML should be run for (or empty string). - /// @param file A FileInfo object pointing to the script file. - /// @param type A ScriptFileInfo::Type the specify script file type. - /// @param builtin If this is true, the script won't be written to the XML. - virtual void addScriptFile(const QString& name, - const QString& identifier, - const QFileInfo& file, - ScriptFileInfo::Type type = ScriptFileInfo::Type::Javascript, - bool builtin = false) { - ScriptFileInfo info; - info.name = name; - info.identifier = identifier; - info.file = file; - info.type = type; - info.builtin = builtin; - m_scripts.append(info); + /// @param info The script info to add. + virtual void addScriptFile(ScriptFileInfo info) { + m_scripts.append(std::move(info)); setDirty(true); } @@ -233,24 +216,8 @@ class LegacyControllerMapping { /// @param endian the pixel endian format /// @param reversedColor whether or not the RGB is swapped BGR /// @param rawData whether or not the screen is allowed to reserve bare data, not transformed - virtual void addScreenInfo(const QString& identifier, - const QSize& size, - uint targetFps, - uint msaa, - std::chrono::milliseconds splashoff, - QImage::Format pixelFormat, - LegacyControllerMapping::ScreenInfo::ColorEndian endian, - bool reversedColor, - bool rawData) { - m_screens.append(ScreenInfo{identifier, - size, - targetFps, - msaa, - splashoff, - pixelFormat, - endian, - reversedColor, - rawData}); + virtual void addScreenInfo(ScreenInfo info) { + m_screens.append(std::move(info)); setDirty(true); } diff --git a/src/controllers/legacycontrollermappingfilehandler.cpp b/src/controllers/legacycontrollermappingfilehandler.cpp index 9ca61b0f0bd7..dbcd8e23bba9 100644 --- a/src/controllers/legacycontrollermappingfilehandler.cpp +++ b/src/controllers/legacycontrollermappingfilehandler.cpp @@ -27,6 +27,8 @@ QMap namespace { const mixxx::Logger kLogger("LegacyControllerMappingFileHandler"); +const QString kRequiredScriptFile = QStringLiteral("common-controller-scripts.js"); + #ifdef MIXXX_USE_QML /// Find a module directory (QML) in the mapping or system path. @@ -165,7 +167,8 @@ bool parseAndAddScreenDefinition(const QDomElement& screen, LegacyControllerMapp } kLogger.debug() << "Adding screen" << identifier; - mapping->addScreenInfo(identifier, + mapping->addScreenInfo(LegacyControllerMapping::ScreenInfo{ + identifier, QSize(width, height), targetFps, msaa, @@ -173,7 +176,7 @@ bool parseAndAddScreenDefinition(const QDomElement& screen, LegacyControllerMapp pixelFormat, endian, reversedColor, - rawData); + rawData}); return true; } #endif @@ -374,11 +377,12 @@ void LegacyControllerMappingFileHandler::addScriptFilesToMapping( .firstChildElement("file"); // Default currently required file - mapping->addScriptFile(REQUIRED_SCRIPT_FILE, + mapping->addScriptFile(LegacyControllerMapping::ScriptFileInfo{ + kRequiredScriptFile, "", - findScriptFile(mapping, REQUIRED_SCRIPT_FILE, systemMappingsPath), + findScriptFile(mapping, kRequiredScriptFile, systemMappingsPath), LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true); + true}); // Look for additional ones while (!scriptFile.isNull()) { @@ -387,10 +391,12 @@ void LegacyControllerMappingFileHandler::addScriptFilesToMapping( if (file.suffix() == "qml") { #ifdef MIXXX_USE_QML QString identifier = scriptFile.attribute("identifier", ""); - mapping->addScriptFile(filename, + mapping->addScriptFile(LegacyControllerMapping::ScriptFileInfo{ + filename, identifier, file, - LegacyControllerMapping::ScriptFileInfo::Type::Qml); + LegacyControllerMapping::ScriptFileInfo::Type::Qml, + false}); #else kLogger.warning() << "Unsupported render scene for file" << file.filePath() @@ -399,10 +405,11 @@ void LegacyControllerMappingFileHandler::addScriptFilesToMapping( #endif } else { QString functionPrefix = scriptFile.attribute("functionprefix", ""); - mapping->addScriptFile(filename, + mapping->addScriptFile(LegacyControllerMapping::ScriptFileInfo{filename, functionPrefix, file, - LegacyControllerMapping::ScriptFileInfo::Type::Javascript); + LegacyControllerMapping::ScriptFileInfo::Type::Javascript, + false}); } scriptFile = scriptFile.nextSiblingElement("file"); } diff --git a/src/test/controller_mapping_file_handler_test.cpp b/src/test/controller_mapping_file_handler_test.cpp index e2913f3db2a6..57dd8594f347 100644 --- a/src/test/controller_mapping_file_handler_test.cpp +++ b/src/test/controller_mapping_file_handler_test.cpp @@ -12,6 +12,7 @@ #include "util/time.h" using ::testing::_; +using ::testing::FieldsAre; class LegacyControllerMappingFileHandlerTest : public LegacyControllerMappingFileHandler, @@ -47,23 +48,11 @@ class MockLegacyControllerMapping : public LegacyControllerMapping { public: MOCK_METHOD(void, addScriptFile, - (const QString& name, - const QString& identifier, - const QFileInfo& file, - ScriptFileInfo::Type type, - bool builtin), + (LegacyControllerMapping::ScriptFileInfo info), (override)); MOCK_METHOD(void, addScreenInfo, - (const QString& identifier, - const QSize& size, - uint targetFps, - uint msaa, - std::chrono::milliseconds splashoff, - QImage::Format pixelFormat, - LegacyControllerMapping::ScreenInfo::ColorEndian endian, - bool reversedColors, - bool rawData), + (LegacyControllerMapping::ScreenInfo info), (override)); MOCK_METHOD(void, addModule, (const QFileInfo& dirinfo, bool builtin), (override)); @@ -92,19 +81,19 @@ TEST_F(LegacyControllerMappingFileHandlerTest, canParseSimpleMapping) { auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScriptFile(QString("DummyDeviceDefaultScreen.js"), + addScriptFile(FieldsAre(QString("DummyDeviceDefaultScreen.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - false)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + false))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_CALL(*mapping, addModule(_, _)).Times(0); addScriptFilesToMapping( @@ -132,20 +121,20 @@ TEST_F(LegacyControllerMappingFileHandlerTest, canParseScreenMapping) { auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScriptFile(QString("DummyDeviceDefaultScreen.qml"), + addScriptFile(FieldsAre(QString("DummyDeviceDefaultScreen.qml"), QString(""), QFileInfo("/dummy/path/DummyDeviceDefaultScreen.qml"), LegacyControllerMapping::ScriptFileInfo::Type::Qml, - false)); + false))); EXPECT_CALL(*mapping, - addScreenInfo(QString("main"), + addScreenInfo(FieldsAre(QString("main"), QSize(480, 360), 20, 1, @@ -153,7 +142,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, canParseScreenMapping) { QImage::Format_RGBA8888, LegacyControllerMapping::ScreenInfo::ColorEndian::Little, false, - false)); + false))); EXPECT_CALL(*mapping, addModule(QFileInfo("/dummy/path/foobar"), false)); addScriptFilesToMapping( @@ -176,12 +165,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingTargetFPS) { auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, 20, _, _, _, _, _, _)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, 20, _, _, _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -201,12 +190,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingTargetFPS) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + true))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG(QtWarningMsg, QString("Invalid target FPS. Target FPS must be between 1 and %0") .arg(kMaxTargetFps)); @@ -229,16 +218,16 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingTargetFPS) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"targetFps\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, QString("Invalid target FPS. Target FPS must be between 1 and %0") @@ -262,13 +251,13 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingTargetFPS) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, QString("Invalid target FPS. Target FPS must be between 1 and %0") @@ -292,16 +281,16 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingTargetFPS) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"targetFps\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, QString("Invalid target FPS. Target FPS must be between 1 and %0") @@ -328,12 +317,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingSize) { auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, QSize(10, 10), _, _, _, _, _, _, _)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, QSize(10, 10), _, _, _, _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -353,12 +342,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingSize) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + true))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Invalid screen size. Screen size must have a width and height above 1 pixel"); @@ -381,15 +370,15 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingSize) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"height\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Invalid screen size. Screen size must have a width and height above 1 pixel"); @@ -412,15 +401,15 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingSize) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"height\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Invalid screen size. Screen size must have a width and height above 1 pixel"); @@ -443,12 +432,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingSize) { mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + true))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Invalid screen size. Screen size must have a width and height above 1 pixel"); @@ -478,12 +467,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, QImage::Format_RGB888, _, _, _)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, QImage::Format_RGB888, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -502,12 +491,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, QImage::Format_RGB16, _, _, _)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, QImage::Format_RGB16, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -526,12 +515,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + true))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Unsupported pixel format \"FOOBAR\""); @@ -554,13 +543,13 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScreenInfo(_, + addScreenInfo(FieldsAre(_, _, _, _, @@ -568,7 +557,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) _, LegacyControllerMapping::ScreenInfo::ColorEndian::Little, _, - _)); + _))); addScriptFilesToMapping( doc.documentElement(), @@ -587,13 +576,13 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScreenInfo(_, + addScreenInfo(FieldsAre(_, _, _, _, @@ -601,7 +590,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) _, LegacyControllerMapping::ScreenInfo::ColorEndian::Little, _, - _)); + _))); addScriptFilesToMapping( doc.documentElement(), @@ -620,13 +609,13 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScreenInfo(_, + addScreenInfo(FieldsAre(_, _, _, _, @@ -634,7 +623,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) _, LegacyControllerMapping::ScreenInfo::ColorEndian::Big, _, - _)); + _))); addScriptFilesToMapping( doc.documentElement(), @@ -653,12 +642,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingBitFormatDefinition) mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, _)).Times(0); + true))); + EXPECT_CALL(*mapping, addScreenInfo(_)).Times(0); EXPECT_LOG_MSG( QtWarningMsg, "Unknown endian format \"enormous\""); @@ -694,17 +683,17 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraBoolPropertiesD mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); if (expectedWarning++) { EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"reversed\" as a " "boolean in the screen definition.")); } - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, false, _)); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, _, _, false, _))); addScriptFilesToMapping( doc.documentElement(), @@ -726,12 +715,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraBoolPropertiesD mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, true, _)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, _, _, true, _))); addScriptFilesToMapping( doc.documentElement(), @@ -755,12 +744,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraBoolPropertiesD mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, false)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, _, _, _, false))); if (expectedWarning++) { EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"raw\" as a boolean in " @@ -787,12 +776,12 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraBoolPropertiesD mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, _, _, _, _, true)); + true))); + EXPECT_CALL(*mapping, addScreenInfo(FieldsAre(_, _, _, _, _, _, _, _, true))); addScriptFilesToMapping( doc.documentElement(), @@ -817,12 +806,14 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, std::chrono::milliseconds(0), _, _, _, _)); + true))); + EXPECT_CALL(*mapping, + addScreenInfo(FieldsAre( + _, _, _, _, std::chrono::milliseconds(0), _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -841,12 +832,14 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, std::chrono::milliseconds(500), _, _, _, _)); + true))); + EXPECT_CALL(*mapping, + addScreenInfo(FieldsAre( + _, _, _, _, std::chrono::milliseconds(500), _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -865,13 +858,13 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScreenInfo(_, + addScreenInfo(FieldsAre(_, _, _, _, @@ -879,7 +872,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe _, _, _, - _)); + _))); EXPECT_LOG_MSG( QtWarningMsg, QString("Invalid splashoff duration. Splashoff duration must " @@ -905,15 +898,17 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"splashoff\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, std::chrono::milliseconds(0), _, _, _, _)); + EXPECT_CALL(*mapping, + addScreenInfo(FieldsAre( + _, _, _, _, std::chrono::milliseconds(0), _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -932,15 +927,17 @@ TEST_F(LegacyControllerMappingFileHandlerTest, screenMappingExtraIntPropertiesDe mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_LOG_MSG(QtWarningMsg, QString("Unable to parse the field \"splashoff\" as an unsigned " "integer in the screen definition.")); - EXPECT_CALL(*mapping, addScreenInfo(_, _, _, _, std::chrono::milliseconds(0), _, _, _, _)); + EXPECT_CALL(*mapping, + addScreenInfo(FieldsAre( + _, _, _, _, std::chrono::milliseconds(0), _, _, _, _))); addScriptFilesToMapping( doc.documentElement(), @@ -969,26 +966,26 @@ TEST_F(LegacyControllerMappingFileHandlerTest, canParseHybridMapping) { auto mapping = std::make_shared(); // This file always gets added EXPECT_CALL(*mapping, - addScriptFile(QString(REQUIRED_SCRIPT_FILE), + addScriptFile(FieldsAre(QString("common-controller-scripts.js"), QString(""), _, // gmock seems unable to assert QFileInfo LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - true)); + true))); EXPECT_CALL(*mapping, - addScriptFile(QString("DummyDeviceDefaultScreen.qml"), + addScriptFile(FieldsAre(QString("DummyDeviceDefaultScreen.qml"), QString(""), QFileInfo("/dummy/path/DummyDeviceDefaultScreen.qml"), LegacyControllerMapping::ScriptFileInfo::Type::Qml, - false)); + false))); EXPECT_CALL(*mapping, - addScriptFile(QString("LegacyScript.js"), + addScriptFile(FieldsAre(QString("LegacyScript.js"), QString(""), QFileInfo("/dummy/path/LegacyScript.js"), LegacyControllerMapping::ScriptFileInfo::Type::Javascript, - false)); + false))); EXPECT_CALL(*mapping, - addScreenInfo(QString("main"), + addScreenInfo(FieldsAre(QString("main"), QSize(480, 360), 20, 1, @@ -996,7 +993,7 @@ TEST_F(LegacyControllerMappingFileHandlerTest, canParseHybridMapping) { QImage::Format_RGBA8888, LegacyControllerMapping::ScreenInfo::ColorEndian::Little, false, - false)); + false))); EXPECT_CALL(*mapping, addModule(QFileInfo("/dummy/path/foobar"), false)); addScriptFilesToMapping(