From c226ecaacaad7bc0f05253965c511643f3e59adf Mon Sep 17 00:00:00 2001 From: "B.Melnik" Date: Mon, 18 Oct 2021 14:38:15 +0300 Subject: [PATCH] tests(Components): Add clicked tests for StatusChatInfoToolbar --- base/WindowTestCase.qml | 6 ++++ tests.qrc | 1 + tst_chatinfotoolbar.qml | 80 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tst_chatinfotoolbar.qml diff --git a/base/WindowTestCase.qml b/base/WindowTestCase.qml index de1a960..83a2025 100644 --- a/base/WindowTestCase.qml +++ b/base/WindowTestCase.qml @@ -7,10 +7,16 @@ TestCase { id: root readonly property Window window: baseWindow + readonly property Item windowContent: contentWindow Window { id: baseWindow width: 800 height: 600 + + Item { + id: contentWindow + anchors.fill: parent + } } } diff --git a/tests.qrc b/tests.qrc index dd8d1d3..b2cfc6f 100644 --- a/tests.qrc +++ b/tests.qrc @@ -11,5 +11,6 @@ base/ModalHelpers.qml base/ProfileModelData.qml base/WindowTestCase.qml + tst_chatinfotoolbar.qml diff --git a/tst_chatinfotoolbar.qml b/tst_chatinfotoolbar.qml new file mode 100644 index 0000000..4f18564 --- /dev/null +++ b/tst_chatinfotoolbar.qml @@ -0,0 +1,80 @@ +import QtQuick 2.14 +import QtTest 1.14 + +import "base" + +import StatusQ.Components 0.1 + +import StatusQ.Popups 0.1 + +WindowTestCase { + name: "ChatInfoToolbar test" + + + SignalSpy { + id: clickedSpy + target: infoToolBar + signalName: "chatInfoButtonClicked" + } + + SignalSpy { + id: addClicked + target: infoToolBar + signalName: "addButtonClicked" + } + + StatusChatInfoToolBar { + id: infoToolBar + parent: windowContent + anchors.centerIn: parent + + chatInfoButton.title: "CryptoKitties" + chatInfoButton.subTitle: "128 Members" + chatInfoButton.image.source: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jpg" + popupMenu: StatusPopupMenu { + + StatusMenuItem { + text: "Create channel" + icon.name: "channel" + } + + StatusMenuItem { + text: "Create category" + icon.name: "channel-category" + } + + StatusMenuSeparator {} + + StatusMenuItem { + text: "Invite people" + icon.name: "share-ios" + } + + } + } + + + function initTestCase() { + window.show() + } + + function cleanupTestCase() { + window.close() + } + + function test_clickFunctions() { + // Verify than signal exists + verify(clickedSpy.valid, "Signal " + clickedSpy.signalName + "is not valid") + verify(addClicked.valid, "Signal " + addClicked.signalName + "is not valid") + + // Verify than button clicked + compare(clickedSpy.count, 0) + mouseClick(infoToolBar, 10, 10, Qt.LeftButton) + compare(clickedSpy.count, 1) + + // Verify than add button clicked + compare(addClicked.count, 0) + mouseClick(infoToolBar, infoToolBar.implicitWidth - 10, infoToolBar.implicitHeight / 2) + compare(addClicked.count, 1) + } +}