From 6aa967f29fed5caa73550f4425b64cd79bee0917 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 29 Aug 2019 14:11:22 -0700 Subject: [PATCH] fixing test code --- interface/src/Application.cpp | 6 +++- .../tests/ui/testLocalFileAccessServer.js | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 scripts/developer/tests/ui/testLocalFileAccessServer.js diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ff3e1e9abe..c575845113 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7507,7 +7507,11 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptEngine if (clientScript) { scriptEngine->registerGlobalObject("Desktop", DependencyManager::get().data()); } else { - scriptEngine->registerGlobalObject("Desktop", new DesktopScriptingInterface(scriptEngine.get(), true)); + auto desktopScriptingInterface = new DesktopScriptingInterface(nullptr, true); + scriptEngine->registerGlobalObject("Desktop", desktopScriptingInterface); + if (QThread::currentThread() != thread()) { + desktopScriptingInterface->moveToThread(thread()); + } } #endif diff --git a/scripts/developer/tests/ui/testLocalFileAccessServer.js b/scripts/developer/tests/ui/testLocalFileAccessServer.js new file mode 100644 index 0000000000..74fd52a216 --- /dev/null +++ b/scripts/developer/tests/ui/testLocalFileAccessServer.js @@ -0,0 +1,30 @@ +"use strict"; + +// Created by Bradley Austin Davis on 2019/08/29 +// Copyright 2013-2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function () { + var QML_URL = "qrc:/qml/hifi/tablet/DynamicWebview.qml" + var LOCAL_FILE_URL = "file:///C:/test-file.html" + + var _this = this; + _this.preload = function (pEntityID) { + var window = Desktop.createWindow(QML_URL, { + title: "Local file access test", + additionalFlags: Desktop.ALWAYS_ON_TOP, + presentationMode: Desktop.PresentationMode.NATIVE, + size: { x: 640, y: 480 }, + visible: true, + position: { x: 100, y: 100 }, + }); + window.sendToQml({ url: LOCAL_FILE_URL }); + }; + + _this.unload = function () { + console.log("QQQ on preload"); + }; +});