test(Components.StatusImageCropPanel): basic validation tests for the image crop component

updates #5401
This commit is contained in:
Stefan 2022-04-19 21:47:30 +04:00 committed by Stefan Dunca
parent dcef08f3b3
commit 934db52126
1 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,86 @@
import QtQuick 2.0
import QtTest 1.0
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.TestHelpers 0.1
Item {
width: 400
height: 300
Component {
id: noSourceComponent
StatusImageCropPanel {
anchors.fill: parent
windowStyle: StatusImageCrop.WindowStyle.Rounded
}
}
Component {
id: withSourceComponent
StatusImageCropPanel {
anchors.fill: parent
// TODO: generate test image and break the sandbox dependency
source: `${Qt.resolvedUrl(".")}../../sandbox/demoapp/data/logo-test-image.png`
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 {
id: qmlWarningsTest
name: "CheckQmlWarnings"
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
wait(100)
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
wait(100)
verify(qtOuput.qtOuput().length === 0, `No output expected. Found:\n"${qtOuput.qtOuput()}"\n`)
}
}
MonitorQtOutput {
id: qtOuput
}
}