Skip to content

Commit

Permalink
add some GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minorua committed Nov 2, 2023
1 parent 5164a5d commit f8f3b61
Show file tree
Hide file tree
Showing 12 changed files with 776 additions and 88 deletions.
4 changes: 3 additions & 1 deletion q3dconst.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Script:
VIEWHELPER = 8
MESHLINE = 9
FETCH = 101
TEST = 201

# Script path (relative from js directory)
PATH = {
Expand All @@ -51,7 +52,8 @@ class Script:
OUTLINE: "threejs/effects/OutlineEffect.js",
VIEWHELPER: "threejs/editor/ViewHelper.js",
MESHLINE: "meshline/THREE.MeshLine.js",
FETCH: "unfetch/unfetch.js"
FETCH: "unfetch/unfetch.js",
TEST: "../tests/gui/test.js"
}


Expand Down
5 changes: 5 additions & 0 deletions q3dwebbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Bridge(QObject):
imageReady = pyqtSignal(int, int, "QImage")
tweenStarted = pyqtSignal(int)
animationStopped = pyqtSignal()
testResultReceived = pyqtSignal(str, bool, str)

def __init__(self, parent=None):
QObject.__init__(self, parent)
Expand Down Expand Up @@ -75,6 +76,10 @@ def onTweenStarted(self, index):
def onAnimationStopped(self):
self.animationStopped.emit()

@pyqtSlot(str, bool, str)
def sendTestResult(self, testName, result, msg):
self.testResultReceived.emit(testName, result, msg)

"""
@pyqtSlot(int, int, result=str)
def mouseUpMessage(self, x, y):
Expand Down
57 changes: 33 additions & 24 deletions q3dwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,23 @@ def setupMenu(self):
self.alwaysOnTopToggled(False)

if DEBUG_MODE:
self.ui.menuDebug = QMenu(self.ui.menubar)
self.ui.menuDebug.setObjectName("menuDebug")
self.ui.menuDebug.setTitle("&Debug")
self.ui.menubar.addAction(self.ui.menuDebug.menuAction())
self.ui.menuDev = QMenu(self.ui.menubar)
self.ui.menuDev.setTitle("&Dev")
self.ui.menubar.addAction(self.ui.menuDev.menuAction())

self.ui.actionTest = QAction(self)
self.ui.actionTest.setText("Run Test")
self.ui.menuDev.addAction(self.ui.actionTest)
self.ui.actionTest.triggered.connect(self.runTest)

self.ui.actionInspector = QAction(self)
self.ui.actionInspector.setObjectName("actionInspector")
self.ui.actionInspector.setText("Web Inspector...")
self.ui.menuDebug.addAction(self.ui.actionInspector)
self.ui.menuDev.addAction(self.ui.actionInspector)
self.ui.actionInspector.triggered.connect(self.ui.webView.showInspector)

self.ui.actionJSInfo = QAction(self)
self.ui.actionJSInfo.setObjectName("actionJSInfo")
self.ui.actionJSInfo.setText("three.js Info...")
self.ui.menuDebug.addAction(self.ui.actionJSInfo)
self.ui.menuDev.addAction(self.ui.actionJSInfo)
self.ui.actionJSInfo.triggered.connect(self.ui.webView.showJSInfo)

def setupConsole(self):
Expand Down Expand Up @@ -300,6 +302,7 @@ def showLayerPropertiesDialog(self, layer):
dialog.propertiesAccepted.connect(self.updateLayerProperties)

dialog.showLayerProperties(layer)
return dialog

# @pyqtSlot(Layer)
def updateLayerProperties(self, layer):
Expand Down Expand Up @@ -392,13 +395,14 @@ def saveAsGLTF(self):
self.ui.statusbar.clearMessage()
self.lastDir = os.path.dirname(filename)

def loadSettings(self):
# file open dialog
directory = self.lastDir or QgsProject.instance().homePath() or QDir.homePath()
filterString = "Settings files (*.qto3settings);;All files (*.*)"
filename, _ = QFileDialog.getOpenFileName(self, "Load Export Settings", directory, filterString)
def loadSettings(self, filename=None):
# open file dialog if filename is not specified
if not filename:
return
directory = self.lastDir or QgsProject.instance().homePath() or QDir.homePath()
filterString = "Settings files (*.qto3settings);;All files (*.*)"
filename, _ = QFileDialog.getOpenFileName(self, "Load Export Settings", directory, filterString)
if not filename:
return

self.ui.treeView.uncheckAll() # hide all 3D objects from the scene
self.ui.treeView.clearLayers()
Expand All @@ -413,16 +417,17 @@ def loadSettings(self):

self.lastDir = os.path.dirname(filename)

def saveSettings(self):
# file save dialog
directory = self.lastDir or QgsProject.instance().homePath() or QDir.homePath()
filename, _ = QFileDialog.getSaveFileName(self, "Save Export Settings", directory, "Settings files (*.qto3settings)")
def saveSettings(self, filename=None):
# open file dialog if filename is not specified
if not filename:
return
directory = self.lastDir or QgsProject.instance().homePath() or QDir.homePath()
filename, _ = QFileDialog.getSaveFileName(self, "Save Export Settings", directory, "Settings files (*.qto3settings)")
if not filename:
return

# append .qto3settings extension if filename doesn't have
if os.path.splitext(filename)[1].lower() != ".qto3settings":
filename += ".qto3settings"
# append .qto3settings extension if filename doesn't have
if os.path.splitext(filename)[1].lower() != ".qto3settings":
filename += ".qto3settings"

self.settings.setAnimationData(self.ui.animationPanel.data())
self.settings.saveSettings(filename)
Expand Down Expand Up @@ -457,6 +462,7 @@ def showScenePropertiesDialog(self):
dialog = PropertiesDialog(self.settings, self.qgisIface, self)
dialog.propertiesAccepted.connect(self.updateSceneProperties)
dialog.showSceneProperties()
return dialog

# @pyqtSlot(dict)
def updateSceneProperties(self, properties):
Expand Down Expand Up @@ -555,6 +561,11 @@ def sendFeedback(self):
def about(self):
QMessageBox.information(self, "Qgis2threejs Plugin", "Plugin version: {0}".format(PLUGIN_VERSION), QMessageBox.Ok)

# Dev menu
def runTest(self):
from Qgis2threejs.tests.gui.test_gui import runTest
runTest(self)


class PropertiesDialog(QDialog):

Expand Down Expand Up @@ -619,7 +630,6 @@ def showLayerProperties(self, layer):
self.setLayerDialogTitle(layer)
self.setLayer(layer)
self.show()
self.exec_()

def setLayerDialogTitle(self, layer):
if layer.mapLayer:
Expand All @@ -636,7 +646,6 @@ def showSceneProperties(self):
self.page = ScenePropertyPage(self, self.settings.sceneProperties(), self.qgisIface.mapCanvas())
self.ui.scrollArea.setWidget(self.page)
self.show()
self.exec_()


class WheelEventFilter(QObject):
Expand Down
2 changes: 1 addition & 1 deletion tests/data/pt4.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pk,label,r,h,WKT
3,cone 3,500,1000,POINT Z (138.6 35 1000)
4,cone 4,500,1000,POINT Z (138.6 35.1 1500)
5,cone 5,,,POINT Z (138.6 35.2 2000)
6,富士山,250,500,POINT Z (138.7300 35.3624 3776)
6,富士山,250,600,POINT Z (138.7300 35.3624 3776)
Loading

0 comments on commit f8f3b61

Please sign in to comment.