diff --git a/tests/ui/modules/Common/InvertedMouseArea.qml b/tests/ui/modules/Common/InvertedMouseArea.qml index 1cf714521..60db8e6e6 100644 --- a/tests/ui/modules/Common/InvertedMouseArea.qml +++ b/tests/ui/modules/Common/InvertedMouseArea.qml @@ -10,6 +10,7 @@ import Utils 1.0 Item { id: item + property bool _mouseAlwaysOutside property var _mouseArea // When emitted, returns a function to test if the click @@ -21,7 +22,9 @@ Item { _mouseArea = builder.createObject() } - _mouseArea.parent = Utils.getTopParent(item) + _mouseArea.parent = Utils.getTopParent(item, true) + _mouseAlwaysOutside = + _mouseArea.parent !== Utils.getTopParent(item) } function _deleteMouseArea () { @@ -59,7 +62,7 @@ Item { positionEvent.accepted = false // Click is outside or not. - if (!Utils.pointIsInItem(this, item, positionEvent)) { + if (_mouseAlwaysOutside || !Utils.pointIsInItem(this, item, positionEvent)) { if (_timeout != null) { // Remove existing timeout to avoid the creation of // many children. diff --git a/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml b/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml index 71fc792ef..b6dc88ff8 100644 --- a/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml +++ b/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml @@ -115,9 +115,8 @@ Item { PropertyChanges { focus: true // Necessary to use `Keys.onEscapePressed`. - opacity: 1 + opacity: 1.0 target: menu - visible: true } } @@ -126,6 +125,10 @@ Item { from: '' to: 'opened' + ScriptAction { + script: menu.visible = true + } + NumberAnimation { duration: PopupStyle.animation.openingDuration easing.type: Easing.InOutQuad @@ -135,7 +138,7 @@ Item { SequentialAnimation { PauseAnimation { - duration: PopupStyle.animation.closingDuration + duration: PopupStyle.animation.openingDuration } ScriptAction { @@ -148,17 +151,10 @@ Item { from: 'opened' to: '' - NumberAnimation { - duration: PopupStyle.animation.openingDuration - easing.type: Easing.InOutQuad - property: 'opacity' - target: menu - } - NumberAnimation { duration: PopupStyle.animation.closingDuration easing.type: Easing.InOutQuad - property: 'visible' // Ugly, use `NumberAnimation` with a bool. + property: 'opacity' target: menu } @@ -168,7 +164,10 @@ Item { } ScriptAction { - script: menuClosed() + script: { + visible = false + menuClosed() + } } } } diff --git a/tests/ui/modules/Common/Popup/DesktopPopup.qml b/tests/ui/modules/Common/Popup/DesktopPopup.qml index 2596416a5..f7962e6f1 100644 --- a/tests/ui/modules/Common/Popup/DesktopPopup.qml +++ b/tests/ui/modules/Common/Popup/DesktopPopup.qml @@ -1,6 +1,8 @@ import QtQuick 2.7 import QtQuick.Window 2.2 +import Common.Styles 1.0 + // =================================================================== Item { @@ -10,13 +12,14 @@ Item { property alias popupY: popup.y default property alias _content: content.data + property bool _isOpen: false function show () { - popup.show() + _isOpen = true } function hide () { - popup.hide() + _isOpen = false } // DO NOT TOUCH THIS PROPERTIES. @@ -34,6 +37,7 @@ Item { id: popup flags: Qt.SplashScreen + opacity: 0 height: _content[0] != null ? _content[0].height : 0 width: _content[0] != null ? _content[0].width : 0 @@ -44,4 +48,56 @@ Item { property var $parent: wrapper } } + + // ----------------------------------------------------------------- + + states: State { + name: 'opened' + when: _isOpen + + PropertyChanges { + opacity: 1.0 + target: popup + } + } + + transitions: [ + Transition { + from: '' + to: 'opened' + + ScriptAction { + script: popup.show() + } + + NumberAnimation { + duration: PopupStyle.animation.openingDuration + easing.type: Easing.InOutQuad + property: 'opacity' + target: popup + } + }, + + Transition { + from: 'opened' + to: '' + + NumberAnimation { + duration: PopupStyle.animation.closingDuration + easing.type: Easing.InOutQuad + property: 'opacity' + target: popup + } + + SequentialAnimation { + PauseAnimation { + duration: PopupStyle.animation.closingDuration + } + + ScriptAction { + script: popup.hide() + } + } + } + ] } diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index 2d517e265..0513ae2fe 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -107,15 +107,16 @@ function clearTimeout (timer) { // ------------------------------------------------------------------- // Returns the top (root) parent of one object. -function getTopParent (object) { - function _getTopParent (object) { - return object.$parent || object.parent +function getTopParent (object, useFakeParent) { + function _getTopParent (object, useFakeParent) { + return (useFakeParent && object.$parent) || object.parent } - var parent = _getTopParent(object) + var parent = _getTopParent(object, useFakeParent) + var p - while (_getTopParent(parent) != null) { - parent = _getTopParent(parent) + while ((p = _getTopParent(parent, useFakeParent)) != null) { + parent = p } return parent