summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2013-11-03 22:00:18 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-04 10:14:21 (GMT)
commit6bf8bbeb813f70b44105994d745133d9ed5f9ea1 (patch)
tree6c862877d857241de5017f7bd91565aaeb225601 /tests/auto
parentbe4e275fdb2f144b79c90b7fe612132ab3dbc0a9 (diff)
downloadQt-6bf8bbeb813f70b44105994d745133d9ed5f9ea1.zip
Qt-6bf8bbeb813f70b44105994d745133d9ed5f9ea1.tar.gz
Qt-6bf8bbeb813f70b44105994d745133d9ed5f9ea1.tar.bz2
Expose QTest::currentAppName() and remove hard-coded argv[0] in tests
Except where we're actually testing QCoreApplication::applicationName() and friends. Based on a3530859e9a7423db0b6839f15538f248aaf4a79 Change-Id: I36ef8cbb5d8bce45225a7f81409f46f1d584287b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcoreapplication/tst_qcoreapplication.cpp28
-rw-r--r--tests/auto/qsql/tst_qsql.cpp47
2 files changed, 41 insertions, 34 deletions
diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
index 9eb53ee..74605f7 100644
--- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
@@ -80,7 +80,7 @@ public:
void tst_QCoreApplication::sendEventsOnProcessEvents()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -102,7 +102,7 @@ void tst_QCoreApplication::getSetCheck()
// Test the property
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(app.property("applicationVersion").toString(), v);
}
@@ -114,7 +114,7 @@ void tst_QCoreApplication::getSetCheck()
void tst_QCoreApplication::qAppName()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QVERIFY(!::qAppName().isEmpty());
}
@@ -123,7 +123,7 @@ void tst_QCoreApplication::argc()
{
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.argc(), 1);
@@ -131,7 +131,7 @@ void tst_QCoreApplication::argc()
{
int argc = 4;
- char *argv[] = { "tst_qcoreapplication", "arg1", "arg2", "arg3" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()), "arg1", "arg2", "arg3" };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 4);
QCOMPARE(app.argc(), 4);
@@ -147,7 +147,7 @@ void tst_QCoreApplication::argc()
{
int argc = 2;
- char *argv[] = { "tst_qcoreapplication", "-qmljsdebugger=port:3768,block" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()), "-qmljsdebugger=port:3768,block" };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.argc(), 1);
@@ -179,7 +179,7 @@ public:
void tst_QCoreApplication::postEvent()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -264,7 +264,7 @@ void tst_QCoreApplication::postEvent()
void tst_QCoreApplication::removePostedEvents()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -431,7 +431,7 @@ public:
void tst_QCoreApplication::deliverInDefinedOrder()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
DeliverInDefinedOrderObject obj(&app);
@@ -474,7 +474,7 @@ public:
void tst_QCoreApplication::globalPostedEventsCount()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCoreApplication::sendPostedEvents();
@@ -520,7 +520,7 @@ public:
void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
ProcessEventsAlwaysSendsPostedEventsObject object;
@@ -538,7 +538,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
void tst_QCoreApplication::reexec()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once
@@ -553,7 +553,7 @@ void tst_QCoreApplication::reexec()
void tst_QCoreApplication::execAfterExit()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
app.exit(1);
@@ -564,7 +564,7 @@ void tst_QCoreApplication::execAfterExit()
void tst_QCoreApplication::eventLoopExecAfterExit()
{
int argc = 1;
- char *argv[] = { "tst_qcoreapplication" };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once and exit
diff --git a/tests/auto/qsql/tst_qsql.cpp b/tests/auto/qsql/tst_qsql.cpp
index 4565588..37a07eb 100644
--- a/tests/auto/qsql/tst_qsql.cpp
+++ b/tests/auto/qsql/tst_qsql.cpp
@@ -119,8 +119,10 @@ void tst_QSql::cleanup()
// of a field "id"(integer) and "name"(char/varchar).
void tst_QSql::basicDriverTest()
{
- int argc = 0;
- QApplication app( argc, 0, false );
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ QApplication app( argc, argv, false );
+
tst_Databases dbs;
dbs.open();
@@ -201,21 +203,22 @@ void tst_QSql::basicDriverTest()
void tst_QSql::open()
{
int i;
- int argc = 0;
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
int count = -1;
for ( i = 0; i < 10; ++i ) {
- QApplication app( argc, 0, false );
- tst_Databases dbs;
-
- dbs.open();
- if ( count == -1 )
- // first iteration: see how many dbs are open
- count = (int) dbs.dbNames.count();
- else
- // next iterations: make sure all are opened again
- QCOMPARE( count, (int)dbs.dbNames.count() );
- dbs.close();
+ QApplication app( argc, argv, false );
+ tst_Databases dbs;
+
+ dbs.open();
+ if ( count == -1 )
+ // first iteration: see how many dbs are open
+ count = (int) dbs.dbNames.count();
+ else
+ // next iterations: make sure all are opened again
+ QCOMPARE( count, (int)dbs.dbNames.count() );
+ dbs.close();
}
}
@@ -230,8 +233,9 @@ void tst_QSql::openInvalid()
void tst_QSql::concurrentAccess()
{
- int argc = 0;
- QApplication app( argc, 0, false );
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ QApplication app( argc, argv, false );
tst_Databases dbs;
dbs.open();
@@ -258,8 +262,10 @@ void tst_QSql::concurrentAccess()
void tst_QSql::openErrorRecovery()
{
- int argc = 0;
- QApplication app( argc, 0, false );
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ QApplication app( argc, argv, false );
+
tst_Databases dbs;
dbs.addDbs();
@@ -305,8 +311,9 @@ void tst_QSql::openErrorRecovery()
void tst_QSql::registerSqlDriver()
{
- int argc = 0;
- QApplication app( argc, 0, false );
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ QApplication app( argc, argv, false );
QSqlDatabase::registerSqlDriver( "QSQLTESTDRIVER", new QSqlDriverCreator<QSqlNullDriver> );
QVERIFY( QSqlDatabase::drivers().contains( "QSQLTESTDRIVER" ) );