Showing the changes to interface/src/scripting/TestScriptingInterface.cpp (1 of 23 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <QtCore/QLoggingCategory> |
| 12 | 12 | #include <QtCore/QThread> |
| 13 | 13 | |
| 14 | +#include <shared/QtHelpers.h> | |
| 14 | 15 | #include <DependencyManager.h> |
| 15 | 16 | #include <Trace.h> |
| 16 | 17 | #include <StatTracker.h> |
| @@ -57,20 +58,25 @@ void TestScriptingInterface::waitIdle() { · 40 unmodified lines | ||
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | bool TestScriptingInterface::loadTestScene(QString scene) { |
| 61 | + if (QThread::currentThread() != thread()) { | |
| 62 | + bool result; | |
| 63 | + hifi::qt::blockingInvokeMethod(this, "loadTestScene", Q_RETURN_ARG(bool, result), Q_ARG(QString, scene)); | |
| 64 | + return result; | |
| 65 | + } | |
| 66 | + | |
| 60 | 67 | static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/"; |
| 61 | 68 | static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/"; |
| 62 | 69 | static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/"; |
| 63 | 70 | static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/"; |
| 64 | − return DependencyManager::get<OffscreenUi>()->returnFromUiThread([scene]()->QVariant { | |
| 65 | − DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/"); | |
| 66 | − auto tree = qApp->getEntities()->getTree(); | |
| 67 | − auto treeIsClient = tree->getIsClient(); | |
| 68 | − // Force the tree to accept the load regardless of permissions | |
| 69 | − tree->setIsClient(false); | |
| 70 | − auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json"); | |
| 71 | − tree->setIsClient(treeIsClient); | |
| 72 | − return result; | |
| 73 | − }).toBool(); | |
| 71 | + | |
| 72 | + DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/"); | |
| 73 | + auto tree = qApp->getEntities()->getTree(); | |
| 74 | + auto treeIsClient = tree->getIsClient(); | |
| 75 | + // Force the tree to accept the load regardless of permissions | |
| 76 | + tree->setIsClient(false); | |
| 77 | + auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json"); | |
| 78 | + tree->setIsClient(treeIsClient); | |
| 79 | + return result; | |
| 74 | 80 | } |
| 75 | 81 | |
| 76 | 82 | bool TestScriptingInterface::startTracing(QString logrules) { |