Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Testing GUI structure
Forum Updated to NodeBB v4.3 + New Features

Testing GUI structure

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 438 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SebastianMS Offline
    SebastianMS Offline
    SebastianM
    wrote on last edited by
    #1

    Hi,
    In my new project I would like to focus more on TDD for GUI. I know that I can test GUI behaviour, like signal to one button/combobox and observe return signal or other visual changes.
    But how about testing structure. I mean - TDD encourage to write failing test first then create minimum code to cover this test.
    Currently I tried this:

    QLabel* label = test_object->findChild<QLabel*>("class_label");
    QLineEdit* edit = test_object->findChild<QLineEdit*>("class_name");
    QVERIFY(label != nullptr);
    QVERIFY(edit != nullptr);
    QHBoxLayout* parent_layout =
        test_object->findChild<QHBoxLayout*>("class_name_layout");
    QVERIFY(parent_layout != nullptr);
    QCOMPARE(label->parent(), edit->parent());
    QCOMPARE(label->parent(), test_object.get());
    QCOMPARE(label->maximumHeight(), 25);
    QCOMPARE(edit->maximumHeight(), 25);
    QVERIFY(!edit->hasFrame());
    QCOMPARE(edit->maximumHeight(), 25);
    QVERIFY2(label->x() < edit->x(),
             qPrintable(QString("Horizontal position of label (%1) should be "
                                "smaller then edit (%2)")
                            .arg(label->x())
                            .arg(edit->x())));
    

    This raises two questions:

    • good object naming convention, as in bigger and nested widgets name need to be unique
    • all test for position relation (like label A need to be left of LineEdt B) need to make widget visible (show or setVisibility). This makes test in Docker or other isolated environments little more difficult (like enforce use xvfb or other X emulators).
    • or maybe there's other established way of work with GUI and testing. If so - then please share link to this guide.
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you trying to test the look and feel of your widget ?

      That's the kind of test that are usually conducted with your potential users/customers.

      Also you have to take into account that unless you hard code every sizes used in your widget, you'll get different results depending on the platform you run your test on.

      When testing a GUI application, you usually don't test the design, you test that the widget reacts as you wish, e.g. that clicking on a button triggers the change of the colour from a QLabel from one to another.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved