Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74160

Can't add import path in qmlEngineAvailable() when using QUICK_TEST_MAIN_WITH_SETUP

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11
    • Commits:
      52ac0ea8cbdc9a2b8e895ceee09994fba229ee12 (qt/qtdeclarative/5.12)

      Description

      Hello,

      I try to setup quicktests for a qml application.  I need to use QUICK_TEST_MAIN_WITH_SETUP to setup some things (including an import path) in the qmlEngine before launching the tests.

      I have the following minimal code:

      #include <QtQuickTest>
      #include <QQmlEngine>
      #include <QQmlContext>
      #include <CircleCommon/CircleCommon.h>
      class Setup : public QObject
      {
          Q_OBJECTpublic:
          Setup() {
              qDebug() << "setup" ;
          }public slots:
          void applicationAvailable() {
              qDebug() << "appli available" ;
          }
          void qmlEngineAvailable(QQmlEngine *engine)
          {
              CircleCommon circleCommon;
              engine->addImportPath("/home/elisabeth/dev/sofa/build/CircleCommonData/qml/");
              qDebug() << QCoreApplication::applicationDirPath();
          }
      };
      QUICK_TEST_MAIN_WITH_SETUP(example, Setup)
      #include "main.moc"
      
      

      With this code my tests fail because the import path is not correctly set.  If I launch the test with -import /home/elisabeth/dev/sofa/build/CircleCommonData/qml/ they pass.  The qDebug calls seem to indicate that the setup slots are called after the tests instead of before the tests.

      Is this a bug or did I do something wrong ?

      Regards.

        Attachments

        For Gerrit Dashboard: QTBUG-74160
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            mitch_curtis Mitch Curtis
            Reporter:
            elisabeth Elisabeth Rousset
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes