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. QML Testcases

QML Testcases

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 267 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.
  • K Offline
    K Offline
    kradhika981
    wrote on last edited by
    #1

    Hi,
    I am trying to write QML testcases. I have a tab bar component and on its OnCompleted() I am creating tab buttons inside the Tab Bar dynamically.
    I want to write a test case to check if the correct number of tab buttons are created. In testcase I have written when : tabBarButtonsCreated and I am emitting that signal after the createTabBarButtons(), but the count is returning 0. But console.log there is showing the right number.

    import "../JS/TabButtonCreator.js" as TabButtonCreator 
    signal tabButtonsCreated
    TabBar {
     id: tabbarGroup
       Component.onCompleted: {
                TabButtonCreator.createTabButtons() 
               console. log("tab btn count:", tabbarGroup.count) // showing correct count
                tabButtonsCreated()
            }
    }
    

    In JS file :

    function createTabButtons() {
    tabButtonComponent = Qt.createComponent("qrc:/tabBtn.qml")
    
    }
    
    function finishCreation() {
    tabBtn = tabButtonComponent.createObject(tabbarGroup);
    }
    

    In TestCase file :

      TabBarComponent {
        id: tabBarComp
      }
        TestCase {
            name: "Check number of tab comonents"
            when: tabBarComp.tabButtonsCreated
            function test_tabComponentSize_check() {
                compare(tabBarComp.count, 4) // fails
            }
        }
    
    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