mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 12:52:46 +02:00
Fixed vector math, added simple test for it
This commit is contained in:
parent
a6de0f06d7
commit
4e4e695ca4
4 changed files with 18 additions and 9 deletions
|
@ -460,7 +460,8 @@ bool ScriptEngineV8::castValueToVariant(const V8ScriptValue& v8Val, QVariant& de
|
||||||
}
|
}
|
||||||
// last chance, just convert it to a variant
|
// last chance, just convert it to a variant
|
||||||
// V8TODO
|
// V8TODO
|
||||||
Q_ASSERT(false);
|
qDebug() << "Converting: " << *v8::String::Utf8Value(_v8Isolate, val->ToDetailString(getConstContext()).ToLocalChecked())
|
||||||
|
<< "to variant. Destination type: " << QMetaType::typeName(destTypeId);
|
||||||
//dest = val->ToVariant();
|
//dest = val->ToVariant();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (setup_testcase_dependencies)
|
macro (setup_testcase_dependencies)
|
||||||
|
# V8TODO: replace most link_hifi_libraries with include_hifi_library_headers
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared test-utils script-engine networking)
|
link_hifi_libraries(shared test-utils script-engine networking octree avatars entities model-networking material-networking model-serializers graphics gpu ktx shaders hfm image procedural)
|
||||||
|
|
||||||
package_libraries_for_deployment()
|
package_libraries_for_deployment()
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "StatTracker.h"
|
#include "StatTracker.h"
|
||||||
|
|
||||||
#include "NodeList.h"
|
#include "NodeList.h"
|
||||||
|
#include "../../../libraries/entities/src/EntityScriptingInterface.h"
|
||||||
|
//#include "../../../libraries/entities/src/EntityScriptingInterface.h"
|
||||||
|
|
||||||
QTEST_MAIN(ScriptEngineTests)
|
QTEST_MAIN(ScriptEngineTests)
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ void ScriptEngineTests::initTestCase() {
|
||||||
DependencyManager::set<ResourceRequestObserver>();
|
DependencyManager::set<ResourceRequestObserver>();
|
||||||
DependencyManager::set<StatTracker>();
|
DependencyManager::set<StatTracker>();
|
||||||
DependencyManager::set<ScriptInitializers>();
|
DependencyManager::set<ScriptInitializers>();
|
||||||
|
DependencyManager::set<EntityScriptingInterface>(true);
|
||||||
|
|
||||||
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
|
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
|
||||||
QVERIFY(!ac.isNull());
|
QVERIFY(!ac.isNull());
|
||||||
|
@ -75,8 +77,8 @@ void ScriptEngineTests::scriptTest() {
|
||||||
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
|
QSharedPointer<ScriptEngines> ac = DependencyManager::get<ScriptEngines>();
|
||||||
QVERIFY(!ac.isNull());
|
QVERIFY(!ac.isNull());
|
||||||
|
|
||||||
|
// TODO: can we execute test scripts in serial way rather than parallel
|
||||||
QDir testScriptsDir("tests");
|
/*QDir testScriptsDir("tests");
|
||||||
QStringList testScripts = testScriptsDir.entryList(QStringList() << "*.js", QDir::Files);
|
QStringList testScripts = testScriptsDir.entryList(QStringList() << "*.js", QDir::Files);
|
||||||
testScripts.sort();
|
testScripts.sort();
|
||||||
|
|
||||||
|
@ -84,14 +86,15 @@ void ScriptEngineTests::scriptTest() {
|
||||||
script = "tests/" + script;
|
script = "tests/" + script;
|
||||||
qInfo() << "Running test script: " << script;
|
qInfo() << "Running test script: " << script;
|
||||||
ac->loadOneScript(script);
|
ac->loadOneScript(script);
|
||||||
}
|
}*/
|
||||||
|
ac->loadOneScript("tests/script-engine/tests/003_vector_math.js");
|
||||||
|
|
||||||
qDebug() << ac->getRunning();
|
qDebug() << ac->getRunning();
|
||||||
|
|
||||||
|
// TODO: if I don't have infinite loop here, it exits before scripts finish. It also reports: QSignalSpy: No such signal: 'scriptCountChanged'
|
||||||
while (true) {
|
for (int n = 0; n > -1; n++) {
|
||||||
QSignalSpy spy(ac.get(), SIGNAL(scriptCountChanged));
|
QSignalSpy spy(ac.get(), SIGNAL(scriptCountChanged));
|
||||||
spy.wait(3000000);
|
spy.wait(1000);
|
||||||
qDebug() << "Signal happened";
|
qDebug() << "Signal happened";
|
||||||
}
|
}
|
||||||
//spy.wait(5000);
|
//spy.wait(5000);
|
||||||
|
|
4
tests/script-engine/src/tests/003_vector_math.js
Normal file
4
tests/script-engine/src/tests/003_vector_math.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
print(JSON.stringify(this));
|
||||||
|
var v1 = { x: 1, y: 0, z: 0 };
|
||||||
|
var v2 = { x: 1, y: 0, z: 0 };
|
||||||
|
print(JSON.stringify(Vec3.sum(v1,v2)));
|
Loading…
Reference in a new issue