// RTL layout test. Lane GUI. // // The GUI DoD asks for "a stub Arabic .ts proves the RTL layout survives". A .ts file on // its own proves nothing — this is the check with teeth: build the real main window, flip // the layout direction, and assert (a) the direction propagates to the children and // (b) a layout we own actually mirrors, by comparing a widget's position LTR vs RTL. #include #include #include #include #include "mainwindow/MainWindow.hpp" #include "rpc/RpcClient.hpp" using velox::gui::MainWindow; namespace { int settledLeftOf(QWidget *w) { QCoreApplication::processEvents(); QTest::qWait(30); QCoreApplication::processEvents(); return w->mapTo(w->window(), QPoint(0, 0)).x(); } } // namespace class TstRtl : public QObject { Q_OBJECT private slots: void directionPropagatesAndLayoutMirrors(); }; void TstRtl::directionPropagatesAndLayoutMirrors() { velox::gui::rpc::RpcClient client(QStringLiteral("/nonexistent/velox-rtl-test.sock")); MainWindow window(&client); // never started — the window must build without a daemon window.resize(900, 500); window.setLayoutDirection(Qt::LeftToRight); window.show(); auto *bannerLabel = window.findChild(QStringLiteral("offlineBannerLabel")); QVERIFY2(bannerLabel != nullptr, "offline banner label not found"); QVERIFY2(bannerLabel->isVisible(), "offline banner should be visible while disconnected"); const int leftLtr = settledLeftOf(bannerLabel); window.setLayoutDirection(Qt::RightToLeft); // Propagation: the window and its central widget must both flip. QCOMPARE(window.layoutDirection(), Qt::RightToLeft); QVERIFY2(window.centralWidget() != nullptr, "no central widget"); QCOMPARE(window.centralWidget()->layoutDirection(), Qt::RightToLeft); const int leftRtl = settledLeftOf(bannerLabel); // The banner is [label][stretch] in a QHBoxLayout we build ourselves. LTR pins the // label near x=0; RTL must push it to the right by (roughly) the free space. If the // layout ignored direction this delta would be ~0. QVERIFY2(leftRtl - leftLtr > 100, qPrintable(QStringLiteral("offline banner did not mirror under RTL: " "label x LTR=%1 RTL=%2") .arg(leftLtr) .arg(leftRtl))); } QTEST_MAIN(TstRtl) #include "tst_rtl.moc"