| 1142 | } |
| 1143 | |
| 1144 | void testMenuItemSizeIsAccessible() { |
| 1145 | // Instantiate the same QProxyStyle used by the app (MenuBarStyle is |
| 1146 | // defined in main.cpp — we replicate the logic here to test it) |
| 1147 | class TestMenuStyle : public QProxyStyle { |
| 1148 | public: |
| 1149 | using QProxyStyle::QProxyStyle; |
| 1150 | QSize sizeFromContents(ContentsType type, const QStyleOption* opt, |
| 1151 | const QSize& sz, const QWidget* w) const override { |
| 1152 | QSize s = QProxyStyle::sizeFromContents(type, opt, sz, w); |
| 1153 | if (type == CT_MenuBarItem) |
| 1154 | s.setHeight(s.height() + qRound(s.height() * 0.5)); |
| 1155 | if (type == CT_MenuItem) |
| 1156 | s = QSize(s.width() + 24, s.height() + 4); |
| 1157 | return s; |
| 1158 | } |
| 1159 | }; |
| 1160 | |
| 1161 | TestMenuStyle style; |
| 1162 | QMenu menu; |
| 1163 | auto* action = menu.addAction("Delete Node"); |
| 1164 | |
| 1165 | QStyleOptionMenuItem opt; |
| 1166 | opt.initFrom(&menu); |
| 1167 | opt.text = action->text(); |
| 1168 | |
| 1169 | QSize base = style.QProxyStyle::sizeFromContents( |
| 1170 | QStyle::CT_MenuItem, &opt, QSize(80, 20), &menu); |
| 1171 | QSize styled = style.sizeFromContents( |
| 1172 | QStyle::CT_MenuItem, &opt, QSize(80, 20), &menu); |
| 1173 | |
| 1174 | // Width must grow by at least 24px |
| 1175 | QVERIFY2(styled.width() >= base.width() + 24, |
| 1176 | qPrintable(QString("Menu item width %1 too narrow (base %2, need +24)") |
| 1177 | .arg(styled.width()).arg(base.width()))); |
| 1178 | |
| 1179 | // Height must grow by at least 4px |
| 1180 | QVERIFY2(styled.height() >= base.height() + 4, |
| 1181 | qPrintable(QString("Menu item height %1 too short (base %2, need +4)") |
| 1182 | .arg(styled.height()).arg(base.height()))); |
| 1183 | } |
| 1184 | |
| 1185 | void testMenuHoverRendersAmberText() { |
| 1186 | // Replicate MenuBarStyle with drawControl hover override |
nothing calls this directly
no test coverage detected