diff --git a/ui/StatusQ/src/StatusQ/Controls/StatusImageCrop.qml b/ui/StatusQ/src/StatusQ/Controls/StatusImageCrop.qml index 257a05f8ee..e30d61e424 100644 --- a/ui/StatusQ/src/StatusQ/Controls/StatusImageCrop.qml +++ b/ui/StatusQ/src/StatusQ/Controls/StatusImageCrop.qml @@ -150,11 +150,15 @@ Item { The new rect will be adjusted to account for the zoom [1, StatusImageCrop::maxZoomScale] + \note the source image must be set and \c sourceSize valid otherwise, an error is logged to \c console \note If the new rect has a diferent area the crop window will adjust to the new AR */ function setCropRect(newRect /*rect*/) { if(newRect.width === 0 || newRect.height === 0) return + if(root.sourceSize.width === 0 || root.sourceSize.height === 0) + console.error("Wrong source size. Ensure source is set") + let n = newRect const s = root.sourceSize let nZoom = d.currentZoom(s, Qt.size(n.width, n.height)) diff --git a/ui/StatusQ/tests/TestComponents/tst_test-StatusImageCropPanel.qml b/ui/StatusQ/tests/TestComponents/tst_test-StatusImageCropPanel.qml index 88f98b0186..e2e611f985 100644 --- a/ui/StatusQ/tests/TestComponents/tst_test-StatusImageCropPanel.qml +++ b/ui/StatusQ/tests/TestComponents/tst_test-StatusImageCropPanel.qml @@ -7,6 +7,7 @@ import StatusQ.Controls 0.1 import StatusQ.TestHelpers 0.1 Item { + id: root width: 400 height: 300 @@ -20,6 +21,8 @@ Item { } } + property url testImageUrl: `${Qt.resolvedUrl(".")}../../sandbox/demoapp/data/logo-test-image.png` + Component { id: withSourceComponent @@ -27,7 +30,7 @@ Item { anchors.fill: parent // TODO: generate test image and break the sandbox dependency - source: `${Qt.resolvedUrl(".")}../../sandbox/demoapp/data/logo-test-image.png` + source: root.testImageUrl windowStyle: StatusImageCrop.WindowStyle.Rectangular Component.onCompleted: setCropRect(Qt.rect(10, 0, sourceSize.width - 20, sourceSize.height)) } @@ -43,7 +46,7 @@ Item { TestCase { id: qmlWarningsTest - name: "CheckQmlWarnings" + name: "StatusImageCropPanel" when: windowShown @@ -66,7 +69,6 @@ Item { testLoader.active = true verify(waitForRendering(testLoader.item)) testLoader.active = false - wait(100) verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) } @@ -75,7 +77,19 @@ Item { testLoader.active = true verify(waitForRendering(testLoader.item)) testLoader.active = false - wait(100) + verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) + } + + function test_setCrop_error_if_no_source_regression() { + testLoader.sourceComponent = noSourceComponent + testLoader.active = true + verify(waitForRendering(testLoader.item)) + testLoader.item.setCropRect(Qt.rect(10, 10, 300, 300)) + verify(qtOuput.qtOuput().length !== 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) + qtOuput.restartCapturing() + testLoader.item.source = root.testImageUrl + verify(waitForRendering(testLoader.item)) + testLoader.active = false verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) } } diff --git a/ui/StatusQ/tests/TestControls/tst_test-StatusBaseInput.qml b/ui/StatusQ/tests/TestControls/tst_test-StatusBaseInput.qml index b842445ea4..762b0ccd7d 100644 --- a/ui/StatusQ/tests/TestControls/tst_test-StatusBaseInput.qml +++ b/ui/StatusQ/tests/TestControls/tst_test-StatusBaseInput.qml @@ -19,7 +19,7 @@ Item { TestCase { id: testCase - name: "CheckQmlWarnings" + name: "StatusBaseInput" when: windowShown diff --git a/ui/StatusQ/tests/TestControls/tst_test-StatusImageCrop.qml b/ui/StatusQ/tests/TestControls/tst_test-StatusImageCrop.qml index fd85c73165..3bd1e3d006 100644 --- a/ui/StatusQ/tests/TestControls/tst_test-StatusImageCrop.qml +++ b/ui/StatusQ/tests/TestControls/tst_test-StatusImageCrop.qml @@ -42,7 +42,7 @@ Item { TestCase { id: qmlWarningsTest - name: "CheckQmlWarnings" + name: "StatusImageCrop-CheckQmlWarnings" when: windowShown @@ -65,7 +65,6 @@ Item { testLoader.active = true verify(waitForRendering(testLoader.item)) testLoader.active = false - wait(100) verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) } @@ -74,7 +73,6 @@ Item { testLoader.active = true verify(waitForRendering(testLoader.item)) testLoader.active = false - wait(100) verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`) } } @@ -89,7 +87,7 @@ Item { } TestCase { - name: "TestFunctionality" + name: "StatusImageCrop-Functionality" // // Test guards diff --git a/ui/StatusQ/tests/TestControls/tst_test-StatusInput.qml b/ui/StatusQ/tests/TestControls/tst_test-StatusInput.qml index c87af502cf..6428e98e6c 100644 --- a/ui/StatusQ/tests/TestControls/tst_test-StatusInput.qml +++ b/ui/StatusQ/tests/TestControls/tst_test-StatusInput.qml @@ -91,7 +91,7 @@ Item { TestCase { id: qmlWarnTC - name: "CheckQmlWarnings" + name: "StatusInput" when: windowShown