QFileDialog test with Qt test

I am trying to write a unit test for a GUI application using QTestLib. The problem is that one of the slots creates a dialog using exec () and I have not found a way to interact with that dialog.

The slots that create the dialog are associated with QAction. So the first problem is that there are test blocks when I run QAction in the test as this results in exec () being called.

Here is my snip code

            QActoin* currentActoin;
            if(currentAction->text() == action)
            {
               currentAction->trigger();
               ..........
            }

      

Here, when I called the action, it opens a file dialog that requires manual intervention to return to the program. How can I go back to testing my code without manual intervention? ie How can I get the handler (pointer) in the file dialog? How do I set a value for a file dialog?

+3


source to share





All Articles