From 6003d007b8ed37dc8447d87a0eb5b352600fb5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Simon=20Fauteux-Chapleau?= <francois-simon.fauteux-chapleau@savoirfairelinux.com> Date: Wed, 10 Jan 2024 15:20:21 -0500 Subject: [PATCH] tests/qml: add basic test for OngoingCallPage GitLab: #1483 Change-Id: Ib8932ec76519c52547a27e29b095fc60b0e46876 --- src/app/mainview/components/CallOverlay.qml | 2 + src/app/mainview/components/MainOverlay.qml | 6 +- .../mainview/components/OngoingCallPage.qml | 2 + tests/qml/src/tst_OngoingCallPage.qml | 94 +++++++++++++++++++ 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 tests/qml/src/tst_OngoingCallPage.qml diff --git a/src/app/mainview/components/CallOverlay.qml b/src/app/mainview/components/CallOverlay.qml index 020509348..b50e54193 100644 --- a/src/app/mainview/components/CallOverlay.qml +++ b/src/app/mainview/components/CallOverlay.qml @@ -144,6 +144,8 @@ Item { MainOverlay { id: mainOverlay + objectName: "mainOverlay" + anchors.fill: parent Connections { diff --git a/src/app/mainview/components/MainOverlay.qml b/src/app/mainview/components/MainOverlay.qml index 3238850d3..07545b99e 100644 --- a/src/app/mainview/components/MainOverlay.qml +++ b/src/app/mainview/components/MainOverlay.qml @@ -193,7 +193,7 @@ Item { radius: height / 2 color: JamiTheme.recordIconColor - SequentialAnimation on color { + SequentialAnimation on color { loops: Animation.Infinite running: recordingRect.visible ColorAnimation { @@ -257,6 +257,8 @@ Item { CallActionBar { id: __callActionBar + objectName: "callActionBar" + anchors { bottom: parent.bottom bottomMargin: 26 @@ -268,7 +270,7 @@ Item { visible: root.opacity } - Behavior on opacity { + Behavior on opacity { NumberAnimation { duration: JamiTheme.overlayFadeDuration } diff --git a/src/app/mainview/components/OngoingCallPage.qml b/src/app/mainview/components/OngoingCallPage.qml index fb4023624..9da40a6a0 100644 --- a/src/app/mainview/components/OngoingCallPage.qml +++ b/src/app/mainview/components/OngoingCallPage.qml @@ -305,6 +305,8 @@ Rectangle { CallOverlay { id: callOverlay + objectName: "callOverlay" + anchors.fill: parent function toggleConversation() { diff --git a/tests/qml/src/tst_OngoingCallPage.qml b/tests/qml/src/tst_OngoingCallPage.qml new file mode 100644 index 000000000..f1a57532e --- /dev/null +++ b/tests/qml/src/tst_OngoingCallPage.qml @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2024 Savoir-faire Linux Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls +import QtTest + +import net.jami.Models 1.1 +import net.jami.Constants 1.1 + +import "../../../src/app/" +import "../../../src/app/mainview/components" + +OngoingCallPage { + id: uut + + width: 800 + height: 600 + + property QtObject appWindow + property ViewManager viewManager: ViewManager { + } + property ViewCoordinator viewCoordinator: ViewCoordinator { + viewManager: uut.viewManager + } + + TestCase { + name: "Check basic visibility of action bar during a call" + when: windowShown // Mouse events can only be handled + // after the window has been shown. + + property var callOverlay + property var mainOverlay + + function initTestCase() { + callOverlay = findChild(uut, "callOverlay") + mainOverlay = findChild(callOverlay, "mainOverlay") + + // The CallActionBar on the OngoingCallPage starts out invisible and + // is made visible whenever the user moves their mouse. + // This is implemented via an event filter in the CallOverlayModel + // class. The event filter is created when the MainOverlay becomes + // visible. In the actual Jami application, this happens when a call + // is started, but we need to toggle the visiblity manually here + // because the MainOverlay is visible at the beginning of the test. + appWindow = uut.Window.window + mainOverlay.visible = false + mainOverlay.visible = true + + // Calling mouseMove() will generate warnings if we don't call init first. + viewCoordinator.init(uut) + } + + function test_checkBasicVisibility() { + var callActionBar = findChild(mainOverlay, "callActionBar") + + // The primary and secondary actions in the CallActionBar are currently being added + // one by one (not using a loop) to CallOverlayModel in the Component.onCompleted + // block of CallActionBar.qml. The two lines below are meant as a sanity check + // that no action has been forgotten. + compare(callActionBar.primaryActions.length, CallOverlayModel.primaryModel().rowCount()) + compare(callActionBar.secondaryActions.length, CallOverlayModel.secondaryModel().rowCount()) + + compare(callActionBar.visible, false) + mouseMove(uut) + + // We need to wait for the fade-in animation of the CallActionBar to be completed + // before we check that it's visible. + var waitTime = JamiTheme.overlayFadeDuration + 100 + // Make sure we have time to check that the CallActioinBar is visible before it fades out: + verify(waitTime + 100 < JamiTheme.overlayFadeDelay) + // Note: The CallActionBar is supposed to stay visible for a few seconds. If the above + // check fails, then this means that either overlayFadeDuration or overlayFadeDelay + // got changed to a value that's way too high/low. + + wait(waitTime) + compare(callActionBar.visible, true) + } + } +} \ No newline at end of file -- GitLab