History

Implement test scene loading

Brad Davis committed 9 years ago

Commit be6b0981 parent e58623b1 file · +15 −18Browse files

Showing the changes to interface/src/scripting/TestScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/TestScriptingInterface.cpp+15−18
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <DependencyManager.h>
1515 #include <Trace.h>
1616 #include <StatTracker.h>
17+#include <OffscreenUi.h>
1718
1819 #include "Application.h"
1920
@@ -54,24 +55,20 @@ void TestScriptingInterface::waitIdle() { · 34 unmodified lines
5455 }
5556
5657 bool TestScriptingInterface::loadTestScene(QString scene) {
57− // FIXME implement
58− // qApp->postLambdaEvent([isClient] {
59− // auto tree = qApp->getEntityClipboard();
60− // tree->setIsClient(isClient);
61− // });
62− /*
63− Test.setClientTree(false);
64− Resources.overrideUrlPrefix("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
65− if (!Clipboard.importEntities(TEST_SCENES_ROOT + scene + ".json")) {
66− return false;
67− }
68− var position = { x: 0, y: 0, z: 0 };
69− var pastedEntityIDs = Clipboard.pasteEntities(position);
70− for (var id in pastedEntityIDs) {
71− print("QQQ ID imported " + id);
72− }
73− */
74− return false;
58+ static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/";
59+ static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/";
60+ static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";
61+ static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";
62+ return DependencyManager::get<OffscreenUi>()->returnFromUiThread([scene]()->QVariant {
63+ ResourceManager::setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
64+ auto tree = qApp->getEntities()->getTree();
65+ auto treeIsClient = tree->getIsClient();
66+ // Force the tree to accept the load regardless of permissions
67+ tree->setIsClient(false);
68+ auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");
69+ tree->setIsClient(treeIsClient);
70+ return result;
71+ }).toBool();
7572 }
7673
7774 bool TestScriptingInterface::startTracing(QString logrules) {