Files
status-app/ui/StatusQ/tests/TestComponents/tst_StatusImageCropPanel.qml
Lukáš Tinkl 125a56502d chore: remove the sandbox tool
- it is fully superseded now by Storybook
- port the missing sandbox pages to storybook
- remove StatusQ components that had been solely used by sandbox
- fixup the build scripts and tests

Fixes #18768
2025-09-10 11:29:48 +02:00

97 lines
2.6 KiB
QML

import QtQuick
import QtTest
import StatusQ.Components
import StatusQ.Controls
import StatusQ.TestHelpers
Item {
id: root
width: 400
height: 300
Component {
id: noSourceComponent
StatusImageCropPanel {
anchors.fill: parent
windowStyle: StatusImageCrop.WindowStyle.Rounded
}
}
property url testImageUrl: `${Qt.resolvedUrl(".")}../../src/assets/png/status-preparing.png`
Component {
id: withSourceComponent
StatusImageCropPanel {
anchors.fill: parent
source: root.testImageUrl
windowStyle: StatusImageCrop.WindowStyle.Rectangular
Component.onCompleted: setCropRect(Qt.rect(10, 0, sourceSize.width - 20, sourceSize.height))
}
}
Loader {
id: testLoader
anchors.fill: parent
active: false
}
TestCase {
name: "StatusImageCropPanel"
when: windowShown
//
// Test guards
function init() {
qtOuput.restartCapturing()
}
function cleanup() {
testLoader.active = false
}
//
// Tests
function test_no_source_initialization() {
testLoader.sourceComponent = noSourceComponent
testLoader.active = true
verify(waitForRendering(testLoader.item))
testLoader.active = false
verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`)
}
function test_with_source_initialization() {
testLoader.sourceComponent = withSourceComponent
testLoader.active = true
verify(waitForRendering(testLoader.item))
testLoader.active = false
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`)
}
}
MonitorQtOutput {
id: qtOuput
}
}