Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. createTemporaryQmlObject import path

createTemporaryQmlObject import path

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqtquicktesting
1 Posts 1 Posters 1.1k Views 1 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.
  • R Offline
    R Offline
    rc2017
    wrote on last edited by
    #1

    So I've got a SUBDIRS project that has two directories called App and Tests. I've got a Bubba.qml under App, which is something I want to write tests for (in the Tests sub project).

    In the Tests project, if I create a tst_Tests.qml file and do:

    import QtQuick 2.0
    import QtTest 1.0
    import "../App"
    
    TestCase {
    ...
       Bubba {
       }
    }
    

    It resolves just fine.

    However, if I do what I want to do, which is add a function:

        function test_bubba() {
            var item = createTemporaryQmlObject("import QtQuick 2.0; import \"../App\"; Bubba {}", testCase);
            compare(item.color, "blue")
            mouseClick(item, 0, 0, Qt.LeftButton);
            compare(item.color, "gray")
    }
    

    It fails in createTemporaryQmlObject with:

    test::MathTests::test_bubba
    Uncaught exception: Qt.createQmlObject(): failed to create object:
    file:///C:/Qt/Qt5.9.0/5.9/mingw53_32/qml/QtTest/undefined:1:21: "../App": no such directory

    Any suggestions on how to get createTemporaryQmlObject to see this relative path, or a different way of having tests separated from the main code?

    1 Reply Last reply
    0

    • Login

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