Warning, /frameworks/kirigami/autotests/tst_basiclistitem_tooltip.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 as QQC2 0009 import org.kde.kirigami 2.20 as Kirigami 0010 import QtTest 1.15 0011 0012 // Note about tooltips: they set `visible: true` as soon as they start enter 0013 // animation, and stay that way until exit animation completes. Actual 0014 // tooltip instance's visible state is not the same as QQC2.ToolTip.visible 0015 // attached property value. 0016 // Delays (timeouts) in tests are slightly increased to mitigate possible races. 0017 TestCase { 0018 name: "BasicListItemToolTip" 0019 visible: true 0020 when: windowShown 0021 0022 width: ui.implicitWidth 0023 height: ui.implicitHeight 0024 0025 BasicListItem_ToolTip_Test { 0026 id: ui 0027 anchors.fill: parent 0028 } 0029 0030 function test_bothNotElided() { 0031 mouseMove(ui.itemBothNotElided, ui.itemBothNotElided.width / 2, ui.itemBothNotElided.height / 2); 0032 wait(QQC2.ToolTip.toolTip.delay * 1.1); 0033 compare(QQC2.ToolTip.toolTip.visible, false); 0034 } 0035 0036 function test_labelElided() { 0037 mouseMove(ui.itemLabelElided, ui.itemLabelElided.width / 2, ui.itemLabelElided.height / 2); 0038 tryCompare(QQC2.ToolTip.toolTip, "visible", true, QQC2.ToolTip.toolTip.delay * 1.1); 0039 compare(QQC2.ToolTip.toolTip.text, ui.itemLabelElided.label); 0040 } 0041 0042 function test_subtitleElided() { 0043 mouseMove(ui.itemSubtitleElided, ui.itemSubtitleElided.width / 2, ui.itemSubtitleElided.height / 2); 0044 tryCompare(QQC2.ToolTip.toolTip, "visible", true, QQC2.ToolTip.toolTip.delay * 1.1); 0045 compare(QQC2.ToolTip.toolTip.text, ui.itemSubtitleElided.subtitle); 0046 } 0047 0048 function test_bothElided() { 0049 mouseMove(ui.itemBothElided, ui.itemBothElided.width / 2, ui.itemBothElided.height / 2); 0050 tryCompare(QQC2.ToolTip.toolTip, "visible", true, QQC2.ToolTip.toolTip.delay * 1.1); 0051 compare(QQC2.ToolTip.toolTip.text, `${ui.itemBothElided.label}<br/><br/>${ui.itemBothElided.subtitle}`); 0052 } 0053 0054 function test_htmlElided() { 0055 mouseMove(ui.itemHtmlElided, ui.itemHtmlElided.width / 2, ui.itemHtmlElided.height / 2); 0056 tryCompare(QQC2.ToolTip.toolTip, "visible", true, QQC2.ToolTip.toolTip.delay * 1.1); 0057 compare(QQC2.ToolTip.toolTip.text, `${ui.itemHtmlElided.label}<br/><br/>${ui.itemHtmlElided.subtitle}`); 0058 } 0059 }