From 0efc6e92d8008127c162e3c2721e6f4364aae8ab Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 9 Jan 2014 12:45:14 +0100 Subject: Use the default height (not 0) if only width is specified If width was specified, but not height (or vice versa) the actual window size was not as expected: * The window width was not the width specified. * The window height became 0. This was unexpected, since if both width and height was not specified it would fallback to becoming 160x160 (on Windows). However, with the advent of https://codereview.qt-project.org/71999 both width and height might receive sensible defaults based on the content of the ApplicationWindow, which would mean that it might be reasonable to expect that you only need to specify one size component of the window. This also fixes an assertion in file ..\..\..\3rdparty\angle\src\libGLESv2\renderer\SwapChain9.cpp, line 81 The assertion happened when a window was created with 0 height (but valid width), and then its height got increased, causing it to become visible. Change-Id: Ia9e730418e35d679907bdcc59b00c3c988216c32 Reviewed-by: Shawn Rutledge --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 76b3a4f6cc..7e6313295b 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -82,6 +82,7 @@ private slots: void windowModality_QTBUG27039(); void visibility(); void mask(); + void initialSize(); void initTestCase() { @@ -1186,6 +1187,32 @@ void tst_QWindow::mask() QCOMPARE(window.mask(), mask); } +void tst_QWindow::initialSize() +{ + QSize defaultSize(0,0); + { + Window w; + w.show(); + QTRY_VERIFY(w.width() > 0); + QTRY_VERIFY(w.height() > 0); + defaultSize = QSize(w.width(), w.height()); + } + { + Window w; + w.setWidth(200); + w.show(); + QTRY_COMPARE(w.width(), 200); + QTRY_VERIFY(w.height() > 0); + } + { + Window w; + w.resize(200, 42); + w.show(); + QTRY_COMPARE(w.width(), 200); + QTRY_COMPARE(w.height(), 42); + } +} + #include QTEST_MAIN(tst_QWindow) -- cgit v1.2.3