Skip to content

Commit

Permalink
Traktor S3: Add tests for controller script
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed May 30, 2021
1 parent 4edb4a1 commit 3c621c1
Show file tree
Hide file tree
Showing 8 changed files with 774 additions and 22 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ add_executable(mixxx-test
src/test/metadatatest.cpp
src/test/metaknob_link_test.cpp
src/test/midicontrollertest.cpp
src/test/controllers/Traktor_Kontrol_S3_test.cpp
src/test/mixxxtest.cpp
src/test/movinginterquartilemean_test.cpp
src/test/nativeeffects_test.cpp
Expand Down
38 changes: 19 additions & 19 deletions res/controllers/Traktor Kontrol S3.hid.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<MixxxControllerPreset mixxxVersion="2.3.0" schemaVersion="1">
<info>
<name>Traktor Kontrol S3</name>
<author>Owen Williams</author>
<description>HID Mapping for Traktor Kontrol S3</description>
<wiki>https://github.com/mixxxdj/mixxx/wiki/Native-Instruments-Traktor-Kontrol-S3</wiki>
<forums>https://mixxx.discourse.group/t/native-instruments-traktor-s3-mapping/18502/4</forums>
<devices>
<product protocol="hid" vendor_id="0x17cc" product_id="0x1900" usage_page="0xff01" usage="0x1" interface_number="0x3" />
</devices>
</info>
<controller id="Traktor">
<scriptfiles>
<file filename="common-hid-packet-parser.js" functionprefix="" />
<file filename="Traktor-Kontrol-S3-hid-scripts.js" functionprefix="TraktorS3" />
</scriptfiles>
</controller>
</MixxxControllerPreset>
<?xml version="1.0" encoding="UTF-8"?>
<MixxxControllerPreset mixxxVersion="2.3.0" schemaVersion="1">
<info>
<name>Traktor Kontrol S3</name>
<author>Owen Williams</author>
<description>HID Mapping for Traktor Kontrol S3</description>
<wiki>https://github.com/mixxxdj/mixxx/wiki/Native-Instruments-Traktor-Kontrol-S3</wiki>
<forums>https://mixxx.discourse.group/t/native-instruments-traktor-s3-mapping/18502/4</forums>
<devices>
<product protocol="hid" vendor_id="0x17cc" product_id="0x1900" usage_page="0xff01" usage="0x1" interface_number="0x3" />
</devices>
</info>
<controller id="Traktor">
<scriptfiles>
<file filename="common-hid-packet-parser.js" functionprefix="" />
<file filename="Traktor-Kontrol-S3-hid-scripts.js" functionprefix="TraktorS3" />
</scriptfiles>
</controller>
</MixxxControllerPreset>
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ bool ControllerScriptEngineLegacy::evaluateScriptFile(const QFileInfo& scriptFil
return true;
}

QJSValue ControllerScriptEngineLegacy::evaluateCodeString(
const QString& program, const QString& fileName, int lineNumber) {
VERIFY_OR_DEBUG_ASSERT(m_pJSEngine) {
return QJSValue::UndefinedValue;
}
return m_pJSEngine->evaluate(program, fileName, lineNumber);
}

QJSValue ControllerScriptEngineLegacy::wrapArrayBufferCallback(const QJSValue& callback) {
return m_makeArrayBufferWrapperFunction.call(QJSValueList{callback});
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ class ControllerScriptEngineLegacy : public ControllerScriptEngineBase {
m_scriptFiles = scripts;
}

private:
protected:
friend class ControllerTest;
bool evaluateScriptFile(const QFileInfo& scriptFile);
QJSValue evaluateCodeString(const QString& program,
const QString& fileName = QString(),
int lineNumber = 1);

private:
void shutdown() override;

QJSValue wrapArrayBufferCallback(const QJSValue& callback);
Expand Down
Loading

0 comments on commit 3c621c1

Please sign in to comment.