| 266 | } |
| 267 | |
| 268 | void TestUI::ScreenCalibrationWidget_contextMenu() |
| 269 | { |
| 270 | MyScreenCalibrationWidget w; |
| 271 | |
| 272 | w.setGeometry(0, 0, 300, 20); |
| 273 | w.show(); |
| 274 | QCoreApplication::processEvents(); |
| 275 | |
| 276 | // Click inside the rulerRect |
| 277 | QVERIFY(w.contextMenu().isVisible() == false); |
| 278 | { |
| 279 | const QPoint local = w.rulerRect().center(); |
| 280 | const QPoint global = w.mapToGlobal(local); |
| 281 | QContextMenuEvent cme(QContextMenuEvent::Mouse, local, global); |
| 282 | QCoreApplication::instance()->notify(&w, &cme); |
| 283 | } |
| 284 | QVERIFY(w.contextMenu().isVisible()); |
| 285 | w.contextMenu().close(); |
| 286 | |
| 287 | // Click outside the rulerRect |
| 288 | QVERIFY(w.contextMenu().isVisible() == false); |
| 289 | { |
| 290 | const QPoint local = w.rulerRect().topLeft() - QPoint(1, 1); |
| 291 | const QPoint global = w.mapToGlobal(local); |
| 292 | QContextMenuEvent cme(QContextMenuEvent::Mouse, local, global); |
| 293 | QCoreApplication::instance()->notify(&w, &cme); |
| 294 | } |
| 295 | QVERIFY(w.contextMenu().isVisible() == false); |
| 296 | |
| 297 | // Keypress ("outside the rulerRect") |
| 298 | QVERIFY(w.contextMenu().isVisible() == false); |
| 299 | { |
| 300 | const QPoint local = w.rulerRect().center() - QPoint(1, 1); |
| 301 | const QPoint global = w.mapToGlobal(local); |
| 302 | QContextMenuEvent cme(QContextMenuEvent::Keyboard, local, global); |
| 303 | QCoreApplication::instance()->notify(&w, &cme); |
| 304 | } |
| 305 | QVERIFY(w.contextMenu().isVisible()); |
| 306 | w.contextMenu().close(); |
| 307 | } |
| 308 | |
| 309 | void TestUI::ClickableLable_ctor() |
| 310 | { |