If you want to test the languages, you don't need to access any labels. All you need to do is to call tr() passing it a message id and context and check if the result is translated properly. Parsing the command line should be done before calling exec as exec() is a blocking call so it will not be possible to test anything within it. Remember QTestLib is about black-box testing so you can't test anything that doesn't provide some kind of result. Of course it is technically possible to do what you want however you'd be rewriting some of QTestLib functionality:
void TestClass::testobject() { QTest::qExec(this); }
int main(int argc, char **argv) {
MyApp app(argc, argv);
TestClass testobject;
QMetaObject::invokeMethod(&testobject,
"startTest", Qt
::QueuedConnection);
app.exec();
}
void TestClass::testobject() { QTest::qExec(this); }
int main(int argc, char **argv) {
MyApp app(argc, argv);
TestClass testobject;
QMetaObject::invokeMethod(&testobject, "startTest", Qt::QueuedConnection);
app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks