From 73419e417a77f2274723b46664adb0e682c3d5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 15 May 2023 09:31:36 -0400 Subject: [PATCH] recordbox: fix focus policy on record box The focus policy was broken and this patch fix also the tests due to an incorrect conversationModel. Change-Id: I9e7f76b0dff80548d3b92296f22bdd7b848ee931 --- src/app/conversationlistmodelbase.h | 2 +- src/app/mainview/components/RecordBox.qml | 17 +++++-- tests/qml/src/tst_RecordBox.qml | 56 +++++++++++++++++++++++ 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 tests/qml/src/tst_RecordBox.qml diff --git a/src/app/conversationlistmodelbase.h b/src/app/conversationlistmodelbase.h index 23dc90071..b2e488d1d 100644 --- a/src/app/conversationlistmodelbase.h +++ b/src/app/conversationlistmodelbase.h @@ -80,6 +80,6 @@ protected: using Role = ConversationList::Role; // Convenience pointer to be pulled from lrcinstance - ConversationModel* model_; + ConversationModel* model_ {nullptr}; QString accountId_; }; diff --git a/src/app/mainview/components/RecordBox.qml b/src/app/mainview/components/RecordBox.qml index c18db8851..1e1aca668 100644 --- a/src/app/mainview/components/RecordBox.qml +++ b/src/app/mainview/components/RecordBox.qml @@ -149,6 +149,7 @@ Popup { PushButton { id: cancelBtn + objectName: "cancelBtn" z: 1 normalColor: "transparent" @@ -164,6 +165,7 @@ Popup { anchors.top: box.top anchors.margins: 8 + focusPolicy: Qt.TabFocus onClicked: { closeRecorder(); updateState(RecordBox.States.INIT); @@ -253,7 +255,7 @@ Popup { PushButton { id: recordButton - + objectName: "recordButton" Layout.alignment: Qt.AlignCenter preferredSize: btnSize @@ -264,6 +266,7 @@ Popup { source: JamiResources.fiber_manual_record_24dp_svg imageColor: JamiTheme.recordIconColor + focusPolicy: Qt.TabFocus onClicked: { updateState(RecordBox.States.RECORDING); if (!root.isPhoto) @@ -273,7 +276,7 @@ Popup { PushButton { id: screenshotBtn - + objectName: "screenshotBtn" Layout.alignment: Qt.AlignCenter preferredSize: btnSize @@ -286,6 +289,7 @@ Popup { source: JamiResources.fiber_manual_record_24dp_svg imageColor: UtilsAdapter.luma(JamiTheme.backgroundColor) ? "white" : JamiTheme.redColor + focusPolicy: Qt.TabFocus onClicked: { root.photo = videoProvider.captureVideoFrame(VideoDevices.getDefaultDevice()); updateState(RecordBox.States.REC_SUCCESS); @@ -294,7 +298,7 @@ Popup { PushButton { id: btnStop - + objectName: "btnStop" Layout.alignment: Qt.AlignCenter preferredSize: btnSize @@ -307,6 +311,7 @@ Popup { border.width: 1 border.color: imageColor + focusPolicy: Qt.TabFocus onClicked: { if (!root.isPhoto) stopRecording(); @@ -316,7 +321,7 @@ Popup { PushButton { id: btnRestart - + objectName: "btnRestart" Layout.alignment: Qt.AlignCenter preferredSize: btnSize @@ -329,6 +334,7 @@ Popup { border.width: 1 border.color: imageColor + focusPolicy: Qt.TabFocus onClicked: { if (!root.isPhoto) stopRecording(); @@ -338,7 +344,7 @@ Popup { PushButton { id: btnSend - + objectName: "btnSend" Layout.alignment: Qt.AlignCenter preferredSize: btnSize @@ -350,6 +356,7 @@ Popup { border.width: 1 border.color: imageColor + focusPolicy: Qt.TabFocus onClicked: { if (!root.isPhoto) { stopRecording(); diff --git a/tests/qml/src/tst_RecordBox.qml b/tests/qml/src/tst_RecordBox.qml new file mode 100644 index 000000000..b5a0c1fb3 --- /dev/null +++ b/tests/qml/src/tst_RecordBox.qml @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 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 QtQuick.Layouts + +import QtTest + +import "../../../src/app/" +import "../../../src/app/mainview/components" + +ColumnLayout { + id: root + + spacing: 0 + width: 300 + height: 300 + + RecordBox { + id: uut + + TestCase { + name: "Take picture" + when: windowShown + + function test_takePicture() { + // Open the recorder and take a picture + uut.openRecorder(true) + + compare(uut.state, RecordBox.States.INIT) + + var screenshotBtn = findChild(uut, "screenshotBtn") + screenshotBtn.clicked() + + compare(uut.state, RecordBox.States.REC_SUCCESS) + + uut.closeRecorder() + } + } + } +} -- GitLab