Warning, /frameworks/kirigami/autotests/tst_navigationtabbar.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
0008 import QtQuick.Controls as QQC2
0009 import QtQuick.Templates as T
0010 import QtTest
0011 import org.kde.kirigami as Kirigami
0012
0013 TestCase {
0014 id: root
0015
0016 name: "NavigationTabBarTest"
0017 visible: true
0018 when: windowShown
0019
0020 width: 500
0021 height: 500
0022
0023 Component {
0024 id: emptyComponent
0025 Kirigami.NavigationTabBar {}
0026 }
0027
0028 Component {
0029 id: tActionComponent
0030 T.Action {}
0031 }
0032
0033 Component {
0034 id: kActionComponent
0035 Kirigami.Action {}
0036 }
0037
0038 function test_create() {
0039 failOnWarning(/error|null/i);
0040 {
0041 const tabbar = createTemporaryObject(emptyComponent, this);
0042 verify(tabbar);
0043 }
0044 {
0045 const tAction = createTemporaryObject(tActionComponent, this);
0046 const kAction = createTemporaryObject(kActionComponent, this);
0047 const tabbar = createTemporaryObject(emptyComponent, this);
0048 verify(tabbar);
0049 tabbar.actions = [tAction, kAction];
0050 compare(tabbar.visibleActions, [tAction, kAction]);
0051
0052 const kInvisibleAction = createTemporaryObject(kActionComponent, this, {
0053 visible: false,
0054 });
0055 verify(kInvisibleAction);
0056 tabbar.actions.push(kInvisibleAction);
0057 compare(tabbar.visibleActions, [tAction, kAction]);
0058
0059 tabbar.actions.push(null);
0060 compare(tabbar.visibleActions, [tAction, kAction]);
0061
0062 const tAction2 = createTemporaryObject(tActionComponent, this);
0063 tabbar.actions.push(tAction2);
0064 compare(tabbar.visibleActions, [tAction, kAction, tAction2]);
0065 }
0066 }
0067
0068 Component {
0069 id: pageWithHeader
0070 QQC2.Page {
0071 header: Kirigami.NavigationTabBar {}
0072 }
0073 }
0074
0075 Component {
0076 id: pageWithFooter
0077 QQC2.Page {
0078 footer: Kirigami.NavigationTabBar {}
0079 }
0080 }
0081
0082 function test_qqc2_page_position() {
0083 {
0084 const page = createTemporaryObject(pageWithHeader, this);
0085 verify(page);
0086 const bar = page.header;
0087 verify(bar instanceof Kirigami.NavigationTabBar);
0088 compare(bar.position, QQC2.ToolBar.Header);
0089 }
0090 {
0091 const page = createTemporaryObject(pageWithFooter, this);
0092 verify(page);
0093 const bar = page.footer;
0094 verify(bar instanceof Kirigami.NavigationTabBar);
0095 compare(bar.position, QQC2.ToolBar.Footer);
0096 }
0097 }
0098
0099 Component {
0100 id: windowWithHeader
0101 QQC2.ApplicationWindow {
0102 header: Kirigami.NavigationTabBar {}
0103 }
0104 }
0105
0106 Component {
0107 id: windowWithFooter
0108 QQC2.ApplicationWindow {
0109 footer: Kirigami.NavigationTabBar {}
0110 }
0111 }
0112
0113 function test_qqc2_window_position() {
0114 {
0115 const window = createTemporaryObject(windowWithHeader, this);
0116 verify(window);
0117 const bar = window.header;
0118 verify(bar instanceof Kirigami.NavigationTabBar);
0119 compare(bar.position, QQC2.ToolBar.Header);
0120 }
0121 {
0122 const window = createTemporaryObject(windowWithFooter, this);
0123 verify(window);
0124 const bar = window.footer;
0125 verify(bar instanceof Kirigami.NavigationTabBar);
0126 compare(bar.position, QQC2.ToolBar.Footer);
0127 }
0128 }
0129 }