From d2459611fd3650d8c80a3ccafd9ec3d58457a888 Mon Sep 17 00:00:00 2001 From: Petri Kiiskinen Date: Tue, 29 Sep 2009 11:06:40 +0200 Subject: Add the -testability option to Qt applications. If this option is given, Qt will load a plugin called "qttestability" and run an initialisation function from it. This allows one to just install the plugin in a non-debug device in order to enable testing. Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 3 ++- src/gui/kernel/qapplication.cpp | 24 ++++++++++++++++++++++++ src/gui/kernel/qapplication_p.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 61b9ee7..8a55bad 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2067,7 +2067,8 @@ QStringList QCoreApplication::arguments() ; else if (l1arg == "-style" || l1arg == "-session" || - l1arg == "-graphicssystem") + l1arg == "-graphicssystem" || + l1arg == "-testability") ++a; else stripped += arg; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 2ad89a2..df5097b 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -97,6 +97,10 @@ #include "qapplication.h" +#ifndef QT_NO_LIBRARY +#include "qlibrary.h" +#endif + #ifdef Q_WS_WINCE #include "qdatetime.h" #include "qguifunctions_wince.h" @@ -457,6 +461,7 @@ bool QApplicationPrivate::animate_tooltip = false; bool QApplicationPrivate::fade_tooltip = false; bool QApplicationPrivate::animate_toolbox = false; bool QApplicationPrivate::widgetCount = false; +bool QApplicationPrivate::load_testability = false; #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) bool QApplicationPrivate::inSizeMove = false; #endif @@ -563,6 +568,8 @@ void QApplicationPrivate::process_cmdline() QApplication::setLayoutDirection(Qt::RightToLeft); } else if (qstrcmp(arg, "-widgetcount") == 0) { widgetCount = true; + } else if (qstrcmp(arg, "-testability") == 0) { + load_testability = true; } else if (arg == "-graphicssystem" && i < argc-1) { graphics_system_name = QString::fromLocal8Bit(argv[++i]); } else { @@ -765,6 +772,23 @@ void QApplicationPrivate::construct( extern void qt_gui_eval_init(uint); qt_gui_eval_init(application_type); #endif + +#ifndef QT_NO_LIBRARY + if(load_testability) { + QLibrary testLib(QLatin1String("qttestability")); + if (testLib.load()) { + typedef void (*TasInitialize)(void); + TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); + if (initFunction) { + initFunction(); + } else { + qCritical("Library qttestability resolve failed!"); + } + } else { + qCritical("Library qttestability load failed!"); + } + } +#endif } #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index aec21fd..6036196 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -452,6 +452,7 @@ public: static bool fade_tooltip; static bool animate_toolbox; static bool widgetCount; // Coupled with -widgetcount switch + static bool load_testability; // Coupled with -testability switch #ifdef Q_WS_MAC static bool native_modal_dialog_active; #endif -- cgit v0.12