aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols/qquickapplicationwindow
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quickcontrols/qquickapplicationwindow')
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt12
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/activeFocusControl.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/activefocusontab.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/attachedProperties.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/backgroundSize.qml16
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/basicapplicationwindow.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/clearfocusondestruction.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/defaultFocus.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/explicitBackgroundSizeBinding.qml21
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/fill.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/focusAfterPopupClosed.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/font.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/layout.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/layoutLayout.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/locale.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/data/opacity.qml2
-rw-r--r--tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp75
17 files changed, 130 insertions, 20 deletions
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt b/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt
index 397441d16a..c8134173b7 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt
@@ -6,7 +6,7 @@
if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
cmake_minimum_required(VERSION 3.16)
project(tst_qquickapplicationwindow LANGUAGES C CXX ASM)
- find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
endif()
#####################################################################
@@ -40,11 +40,11 @@ qt_internal_add_test(tst_qquickapplicationwindow
TESTDATA ${test_data}
)
-#### Keys ignored in scope 1:.:.:qquickapplicationwindow.pro:<TRUE>:
-# OTHER_FILES = "data/*.qml"
-
-## Scopes:
-#####################################################################
+# Make the QML files available to Creator's locator.
+target_sources(tst_qquickapplicationwindow
+ PRIVATE
+ ${test_data}
+)
qt_internal_extend_target(tst_qquickapplicationwindow CONDITION ANDROID OR IOS
DEFINES
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/activeFocusControl.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/activeFocusControl.qml
index f699a27fc1..c6073fedeb 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/activeFocusControl.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/activeFocusControl.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/activefocusontab.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/activefocusontab.qml
index 7798c4ff1d..dd53faf537 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/activefocusontab.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/activefocusontab.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/attachedProperties.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/attachedProperties.qml
index 4bb773a831..d84cdc3daa 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/attachedProperties.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/attachedProperties.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Window
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/backgroundSize.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/backgroundSize.qml
new file mode 100644
index 0000000000..db5470986f
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/backgroundSize.qml
@@ -0,0 +1,16 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 600
+ height: 400
+
+ background: Item {
+ objectName: "background"
+ implicitWidth: 123
+ implicitHeight: 456
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/basicapplicationwindow.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/basicapplicationwindow.qml
index ba4bf1597e..d59afa7e6b 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/basicapplicationwindow.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/basicapplicationwindow.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/clearfocusondestruction.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/clearfocusondestruction.qml
index 56dfa89e68..e86902c12c 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/clearfocusondestruction.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/clearfocusondestruction.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/defaultFocus.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/defaultFocus.qml
index 02ff15ff45..68b889bdc2 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/defaultFocus.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/defaultFocus.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/explicitBackgroundSizeBinding.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/explicitBackgroundSizeBinding.qml
new file mode 100644
index 0000000000..67fdf7808c
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/explicitBackgroundSizeBinding.qml
@@ -0,0 +1,21 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ id: window
+ width: 600
+ height: 400
+
+ property real scaleFactor: 1
+
+ background: Rectangle {
+ objectName: "background"
+ color: "green"
+ width: window.width * window.scaleFactor
+ height: window.height * window.scaleFactor
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/fill.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/fill.qml
index d57c4c4f71..db0c2a4e89 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/fill.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/fill.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/focusAfterPopupClosed.qml
index 5e13ac274a..a40277a45c 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/focusAfterPopupClosed.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/focusAfterPopupClosed.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/font.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/font.qml
index 4f33439811..8909666b76 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/font.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/font.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/layout.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/layout.qml
index 11f2371673..4bcb56e993 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/layout.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/layout.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/layoutLayout.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/layoutLayout.qml
index e27fe07b12..3f6b51706c 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/layoutLayout.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/layoutLayout.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/locale.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/locale.qml
index 7e0b40095e..e2ccd677d7 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/locale.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/locale.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/data/opacity.qml b/tests/auto/quickcontrols/qquickapplicationwindow/data/opacity.qml
index ea2de5ccd2..5a7edc532b 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/data/opacity.qml
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/data/opacity.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
index e055340dde..0b84bca678 100644
--- a/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
+++ b/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QtCore/qoperatingsystemversion.h>
@@ -12,6 +12,7 @@
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickoverlay_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
@@ -22,8 +23,10 @@
#include <QtQuickTemplates2/private/qquicktextfield_p.h>
#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <QtQuickControlsTestUtils/private/controlstestutils_p.h>
using namespace QQuickVisualTestUtils;
+using namespace QQuickControlsTestUtils;
class tst_QQuickApplicationWindow : public QQmlDataTest
{
@@ -50,11 +53,15 @@ private slots:
void layoutLayout();
void componentComplete();
void opacity();
+ void backgroundSize();
+ void explicitBackgroundSizeBinding();
};
tst_QQuickApplicationWindow::tst_QQuickApplicationWindow()
: QQmlDataTest(QT_QMLTEST_DATADIR)
{
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuWindows);
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
QQuickStyle::setStyle("Basic");
}
@@ -275,6 +282,10 @@ void tst_QQuickApplicationWindow::implicitFill()
void tst_QQuickApplicationWindow::attachedProperties()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("eglfs"), Qt::CaseInsensitive))
+ {
+ QSKIP("This test uses multiple windows and it crashes on EGLFS because of that");
+ }
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("attachedProperties.qml"));
@@ -930,6 +941,68 @@ void tst_QQuickApplicationWindow::opacity()
QVERIFY(window);
}
+void tst_QQuickApplicationWindow::backgroundSize()
+{
+ QQuickControlsApplicationHelper helper(this, QLatin1String("backgroundSize.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
+ QQuickApplicationWindow *window = helper.appWindow;
+ QCOMPARE(window->width(), 600);
+ QCOMPARE(window->height(), 400);
+
+ auto *background = window->background();
+ QCOMPARE(background->implicitWidth(), 123);
+ QCOMPARE(background->implicitHeight(), 456);
+ QCOMPARE(background->width(), window->width());
+ QCOMPARE(background->height(), window->height());
+
+ // Changing the implicit size of the background shouldn't have any effect
+ // on its size if it was never explicitly set.
+ background->setImplicitWidth(234);
+ QCOMPARE(background->implicitWidth(), 234);
+ QCOMPARE(window->width(), 600);
+ QCOMPARE(background->width(), window->width());
+
+ background->setImplicitHeight(567);
+ QCOMPARE(background->implicitHeight(), 567);
+ QCOMPARE(window->height(), 400);
+ QCOMPARE(background->height(), window->height());
+
+ // Explicitly setting the size of the background should ensure
+ // that it's respected from that point onwards.
+ background->setWidth(345);
+ QCOMPARE(background->implicitWidth(), 234);
+ QCOMPARE(window->width(), 600);
+ QCOMPARE(background->width(), 345);
+
+ window->setWidth(610);
+ QCOMPARE(background->width(), 345);
+
+ background->setHeight(678);
+ QCOMPARE(background->implicitHeight(), 567);
+ QCOMPARE(window->height(), 400);
+ QCOMPARE(background->height(), 678);
+
+ window->setHeight(410);
+ QCOMPARE(background->height(), 678);
+}
+
+void tst_QQuickApplicationWindow::explicitBackgroundSizeBinding()
+{
+ QQuickControlsApplicationHelper helper(this, QLatin1String("explicitBackgroundSizeBinding.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
+ QQuickApplicationWindow *window = helper.appWindow;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ auto *background = window->background();
+ QCOMPARE(background->width(), window->width());
+ QCOMPARE(background->height(), window->height());
+
+ window->setProperty("scaleFactor", 0.5);
+ QCOMPARE(background->width(), window->width() / 2);
+ QCOMPARE(background->height(), window->height() / 2);
+}
+
QTEST_MAIN(tst_QQuickApplicationWindow)
#include "tst_qquickapplicationwindow.moc"