Adjust window rectangle for menu baseline test case

Capturing complete window for menu test cases makes it fail as there can
be different window shapes (such as rectangular or rounded corners). To
avoid this, its better to capture only minimal visual portion that can
be compared against.

Change-Id: I30e85589fce8c17115f511a7a345d46949e6c9e8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Santhosh Kumar 2023-03-17 12:15:10 +01:00
parent ee3611ce91
commit f50b853bed

View File

@ -1156,8 +1156,11 @@ void tst_Widgets::tst_QMenu()
testWindow()->show();
QVERIFY(QTest::qWaitForWindowExposed(testWindow()));
QRect testWindowRect(testWindow()->geometry());
// There can be rounded corners in the window and this leads to test
// case to be fuzzy. Adjust window rectangle that need to be captured
int adjustPixel = menu1.geometry().left();
testWindowRect.adjust(adjustPixel, adjustPixel, -adjustPixel, -adjustPixel);
QBASELINE_CHECK_DEFERRED(takeScreenSnapshot(testWindowRect), "showitems");
// Normal menu item with text