#include "taskjointeditor.h" #include "applicationstyle.h" #include #include #include #include #include static void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);} static void settle(){QElapsedTimer timer;timer.start();while(timer.elapsed()<120){QApplication::processEvents();QThread::msleep(2);}} int main(int argc,char** argv){QApplication app(argc,argv);ApplicationStyle::install(app);try{ for(int fontSize:{13,18})for(int width:{220,280,340}){ TaskJointEditor editor;QFont font=editor.font();font.setPixelSize(fontSize);editor.setFont(font); editor.setFixedWidth(width); editor.setDevice({{"jointNames",QStringList{"R_SHOULDER_P","R_SHOULDER_R","RIGHT_SHOULDER_PITCH_JOINT_EXTENDED_NAME","R_ELBOW_R","R_WRIST_P","R_WRIST_Y","R_WRIST_R"}}, {"jointLimits",QVariantMap{{"R_SHOULDER_R",QVariantMap{{"lower",-2.},{"upper",2.}}}}}}); editor.show();settle();editor.adjustSize();settle(); auto* table=editor.findChild("taskJointTable");check(table&&table->rowCount()==7,"all joints visible"); for(int i=0;irowCount();++i){ auto* row=table->cellWidget(i,0);auto* edit=row->findChild();check(edit,"angle input exists"); const QRect cell=table->visualRect(table->model()->index(i,0)); const QRect input(edit->mapTo(table->viewport(),QPoint()),edit->size()); if(!cell.contains(input)){std::cerr<<"width="<height()>=edit->minimumSizeHint().height(),"input fits theme minimum height"); for(auto* label:row->findChildren())check(label->height()>=label->heightForWidth(label->width()),"joint name and limits fit their wrapped text"); check(table->viewport()->rect().contains(cell),"all joint rows fit without nested scrolling"); } if(width==280&&fontSize==13)editor.grab().save("build/tests/joint-layout.png"); } std::cout<<"PASS: seven named joints, long names, limits, 220/280/340 widths and 13/18px fonts; inputs fully contained; no nested scrollbar\n";return 0; }catch(const std::exception& e){std::cerr<<"FAIL: "<