tst_QWidget: Add test that WA_NativeWindow results in window handle

Pick-to: 6.7
Change-Id: I63a653a552be2a6435e0c068e47c2442e53642cb
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
Tor Arne Vestbø 2024-01-19 12:00:45 +01:00
parent 92acc94fa9
commit 0c2a16c49c
1 changed files with 20 additions and 0 deletions

View File

@ -135,7 +135,9 @@ public:
public slots:
void initTestCase();
void cleanup();
private slots:
void nativeWindowAttribute();
void addActionOverloads();
void getSetCheck();
void fontPropagation();
@ -688,6 +690,24 @@ struct ImplicitlyConvertibleTo {
void testFunction0() {}
void testFunction1(bool) {}
void tst_QWidget::nativeWindowAttribute()
{
QWidget parent;
QWidget child(&parent);
QCOMPARE(parent.windowHandle(), nullptr);
QCOMPARE(child.windowHandle(), nullptr);
// Setting WA_NativeWindow should create window handle
parent.setAttribute(Qt::WA_NativeWindow);
QVERIFY(parent.windowHandle() != nullptr);
// But not its child's window handle
QCOMPARE(child.windowHandle(), nullptr);
// Until the child also gains WA_NativeWindow
child.setAttribute(Qt::WA_NativeWindow);
QVERIFY(child.windowHandle() != nullptr);
}
void tst_QWidget::addActionOverloads()
{
// almost exhaustive check of addAction() overloads: