draft for GUI plugin and networking
authorKonrad Rosenbaum <konrad@silmor.de>
Tue, 24 Jun 2014 19:49:56 +0000 (21:49 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Tue, 24 Jun 2014 19:49:56 +0000 (21:49 +0200)
20 files changed:
examples/gui-system-in-test/calculator.cpp [new file with mode: 0644]
examples/gui-system-in-test/calculator.h [new file with mode: 0644]
examples/gui-system-in-test/sit.pro [new file with mode: 0644]
examples/gui-system-in-test/siti.pro [new file with mode: 0644]
examples/gui-system-in-test/sitinstrumented.cpp [new file with mode: 0644]
examples/gui-system-in-test/sitmain.cpp [new file with mode: 0644]
guiplugin/gplugin.cpp [new file with mode: 0644]
guiplugin/gplugin.h [new file with mode: 0644]
guiplugin/guiplugin.pro [new file with mode: 0644]
guiplugin/observer.cpp [new file with mode: 0644]
guiplugin/observer.h [new file with mode: 0644]
guiplugin/skidstyle.json [new file with mode: 0644]
network/include/skid-connection.h [new file with mode: 0644]
network/include/skidnet-export.h [new file with mode: 0644]
network/include/skidnet.h [new file with mode: 0644]
network/network.pro [new file with mode: 0644]
network/src/skid-connection.cpp [new file with mode: 0644]
runnerlib/qt5gui/guilibqt5.pro [new file with mode: 0644]
runnerlib/qt5gui/include/skidguiinit.h [new file with mode: 0644]
skid.pro

diff --git a/examples/gui-system-in-test/calculator.cpp b/examples/gui-system-in-test/calculator.cpp
new file mode 100644 (file)
index 0000000..53c92b2
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// SKID Examples: System In Test
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include <QApplication>
+#include <QBoxLayout>
+#include <QDebug>
+#include <QLabel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+
+#include "calculator.h"
+
+Calculator::Calculator ( QWidget *parent, Qt::WindowFlags f ) : QDialog ( parent, f )
+{
+        setWindowTitle("Stupid Calculator");
+        
+        QVBoxLayout*vl;
+        setLayout(vl=new QVBoxLayout);
+        QMenuBar*mb;
+        vl->addWidget(mb=new QMenuBar,0);
+        QMenu*m=mb->addMenu("&Window");
+        m->addAction("&About",this,SLOT(about()));
+        m->addAction("About Q&t",qApp,SLOT(aboutQt()));
+        m->addSeparator();
+        m->addAction("&Quit",qApp,SLOT(quit()));
+        
+        m=mb->addMenu("&Calculate");
+        m->addAction("&Add",this,SLOT(addSomething()));
+        m->addAction("&Multiply",this,SLOT(multiplySomething()));
+        
+        vl->addWidget(new QLabel("Please use the menu!"),1);
+}
+
+void Calculator::addSomething()
+{
+
+}
+
+void Calculator::multiplySomething()
+{
+
+}
+
+void Calculator::about()
+{
+        QMessageBox::about(this,"About Stupid Calculator",
+                           "<html><h1>About Stupid Calculator</h1>"
+                           "This is a very stupid an unergonomic calculator."
+                           "Do not expect it to make much sense, it exists to demonstrate"
+                           "SKID GUI manipulation techniques.<p>"
+                          );
+}
diff --git a/examples/gui-system-in-test/calculator.h b/examples/gui-system-in-test/calculator.h
new file mode 100644 (file)
index 0000000..b7e0596
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// SKID Examples: System In Test
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_EXAMPLE_CALCULATOR_H
+#define SKID_EXAMPLE_CALCULATOR_H
+
+#include <QDialog>
+
+class Calculator:public QDialog
+{
+        Q_OBJECT
+        public:
+                explicit Calculator ( QWidget *parent = 0, Qt::WindowFlags f = 0 );
+        public slots:
+                void addSomething();
+                void multiplySomething();
+                
+                void about();
+};
+
+#endif
diff --git a/examples/gui-system-in-test/sit.pro b/examples/gui-system-in-test/sit.pro
new file mode 100644 (file)
index 0000000..81195a8
--- /dev/null
@@ -0,0 +1,11 @@
+#project file for system in test example: non-instrumented GUI
+TEMPLATE = app
+TARGET = guisit
+QT += widgets
+
+include(../../common.pri)
+DESTDIR = $$BINDIR
+
+#our actual sources:
+SOURCES += sitmain.cpp calculator.cpp
+HEADERS += calculator.h
\ No newline at end of file
diff --git a/examples/gui-system-in-test/siti.pro b/examples/gui-system-in-test/siti.pro
new file mode 100644 (file)
index 0000000..125931b
--- /dev/null
@@ -0,0 +1,12 @@
+#project file for system in test example: instrumented GUI
+TEMPLATE = app
+TARGET = guisiti
+QT += widgets
+
+include(../../common.pri)
+DESTDIR = $$BINDIR
+INCLUDEPATH += ../../runnerlib/qt5gui/include
+
+#our actual sources:
+SOURCES += sitinstrumented.cpp calculator.cpp
+HEADERS += calculator.h
\ No newline at end of file
diff --git a/examples/gui-system-in-test/sitinstrumented.cpp b/examples/gui-system-in-test/sitinstrumented.cpp
new file mode 100644 (file)
index 0000000..d1e2995
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// SKID Examples: System In Test
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include <QApplication>
+#include <QDebug>
+
+#include "calculator.h"
+#include <skidguiinit.h>
+
+
+int main(int ac,char**av)
+{
+        QApplication app(ac,av);
+        if(!Skid::Gui::initialize())
+                qDebug()<<"Unable to instrument this program with SKID GUI controller";
+        
+        Calculator c;
+        c.show();
+        
+        return app.exec();
+}
\ No newline at end of file
diff --git a/examples/gui-system-in-test/sitmain.cpp b/examples/gui-system-in-test/sitmain.cpp
new file mode 100644 (file)
index 0000000..df2a632
--- /dev/null
@@ -0,0 +1,24 @@
+//
+// SKID Examples: System In Test
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include <QApplication>
+
+#include "calculator.h"
+
+
+int main(int ac,char**av)
+{
+        QApplication app(ac,av);
+        
+        Calculator c;
+        c.show();
+        
+        return app.exec();
+}
\ No newline at end of file
diff --git a/guiplugin/gplugin.cpp b/guiplugin/gplugin.cpp
new file mode 100644 (file)
index 0000000..b0289e7
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// SKID Examples: GUI Style Plugin Interface
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include <QStylePlugin>
+#include <QStyleFactory>
+#include <QDebug>
+#include <QCoreApplication>
+
+#include "gplugin.h"
+#include "observer.h"
+
+#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
+#define STYLE "fusion"
+#elif defined(Q_OS_WIN)
+#define STYLE "windows"
+#elif defined(Q_OS_MAC)
+#define STYLE "macintosh"
+#else
+#define STYLE "fusion"
+#endif
+
+QStyle *SkidStylePlugin::create ( const QString &key )
+{
+        qDebug()<<"SKID init via Style Path";
+        Skid::Gui::Observer::initialize();
+        QString substyle=STYLE;
+        if(1){
+                const QByteArray st=qgetenv("SKIDSTYLE");
+                if(!st.isEmpty())
+                        substyle=QString::fromLocal8Bit(st);
+        }
+        if(qApp!=nullptr){
+                for(const QString&arg:qApp->arguments())
+                        if(arg.startsWith("-skidstyle="))
+                                substyle=arg.mid(11);
+        }
+        if(key=="skidstyle"){
+                qDebug()<<"SKID creating instance of style"<<substyle<<"out of"<<QStyleFactory::keys();
+                return QStyleFactory::create(substyle);
+        }else{
+                return nullptr;
+        }
+}
+
+QStringList SkidStylePlugin::keys() const
+{
+        return QStringList()<<"skidstyle";
+}
diff --git a/guiplugin/gplugin.h b/guiplugin/gplugin.h
new file mode 100644 (file)
index 0000000..1d6ebef
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// SKID Examples: GUI Style Plugin Interface
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_GUI_STYLE_PLUGIN_H
+#define SKID_GUI_STYLE_PLUGIN_H
+
+#include <QStylePlugin>
+
+///The pseudo style used to infuse a GUI based system-in-test with the SKID GUI observer.
+///It is usually selected by setting the QT_PLUGIN_PATH and QT_STYLE_OVERRIDE variables,
+///alternatively the -style parameter can be used or the program can be instrumented directly.
+///It returns the platform default style instead of creating a new one.
+///The environment variable SKIDSTYLE or the parameter -skidstyle=(style)
+///can be used to select a real style.
+class SkidStylePlugin:public QStylePlugin
+{
+        Q_OBJECT
+        Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "skidstyle.json")
+
+        public:
+                SkidStylePlugin() {}
+
+                QStringList keys() const;
+                QStyle *create(const QString &key);
+};
+
+#endif
diff --git a/guiplugin/guiplugin.pro b/guiplugin/guiplugin.pro
new file mode 100644 (file)
index 0000000..d2f9c84
--- /dev/null
@@ -0,0 +1,17 @@
+#project file for SKID pseudo style plugin
+
+#test runners are applications...
+TEMPLATE = lib
+CONFIG += plugin
+TARGET = skidstyle
+
+#it is usually designed to be non-graphical
+QT += gui widgets
+
+#config
+include (../common.pri)
+DESTDIR = $$LIBDIR/styles
+
+#our actual sources:
+SOURCES += gplugin.cpp observer.cpp
+HEADERS += gplugin.h observer.h
diff --git a/guiplugin/observer.cpp b/guiplugin/observer.cpp
new file mode 100644 (file)
index 0000000..c11fd35
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// SKID Examples: GUI Style Plugin Interface
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "observer.h"
+#include <QCoreApplication>
+#include <QTimer>
+#include <QDebug>
+
+using namespace Skid::Gui;
+
+static Observer *observer=nullptr;
+
+void Observer::initialize()
+{
+        if(observer)return;
+        observer=new Observer;
+        qDebug()<<"Initialized SKID GUI Observer";
+}
+
+static void observer_init(){Observer::initialize();}
+
+Q_COREAPP_STARTUP_FUNCTION(observer_init);
+
+Observer::Observer() : QObject()
+{
+        qApp->installEventFilter(this);
+}
+
+bool Observer::eventFilter ( QObject *, QEvent *event )
+{
+        if(event)
+        switch(event->type())
+        {
+                //events that influence window visibility
+                case QEvent::Close:
+                case QEvent::Hide:
+                case QEvent::Show:
+                case QEvent::ShowWindowRequest:
+                        QTimer::singleShot(0,this,SLOT(reschedule()));
+                        break;
+                default:/*nothing*/ break;
+        }
+        //pass events on to the actual program
+        return false;
+}
+
+void Observer::reschedule()
+{
+        qDebug()<<"SKID scheduler";
+}
diff --git a/guiplugin/observer.h b/guiplugin/observer.h
new file mode 100644 (file)
index 0000000..01ecbf2
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// SKID Examples: GUI Style Plugin Interface
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_GUI_OBSERVER_H
+#define SKID_GUI_OBSERVER_H
+
+#include <QObject>
+
+namespace Skid { namespace Gui {
+
+class Observer:public QObject
+{
+        Q_OBJECT
+        public:
+                static void initialize();
+        protected:
+                bool eventFilter(QObject *obj, QEvent *event);
+                Observer ();
+        private slots:
+                void reschedule();
+};
+
+
+//end of namespace
+}}
+
+#endif
diff --git a/guiplugin/skidstyle.json b/guiplugin/skidstyle.json
new file mode 100644 (file)
index 0000000..1183c85
--- /dev/null
@@ -0,0 +1 @@
+{ "Keys": [ "skidstyle" ] }
\ No newline at end of file
diff --git a/network/include/skid-connection.h b/network/include/skid-connection.h
new file mode 100644 (file)
index 0000000..cb49755
--- /dev/null
@@ -0,0 +1,32 @@
+//
+// network connection include file for SKID
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_NETWORK_CONNECTION_H
+#define SKID_NETWORK_CONNECTION_H
+
+#include <QObject>
+
+class QTcpSocket;
+class QLocalSocket;
+class QSslSocket;
+
+namespace Skid {
+class Connection:public QObject
+{
+        Q_OBJECT
+        public:
+                explicit Connection ( QTcpSocket*, QObject *parent = 0 );
+        private slots:
+                void readData();
+};
+
+}
+
+#endif
diff --git a/network/include/skidnet-export.h b/network/include/skidnet-export.h
new file mode 100644 (file)
index 0000000..04f0761
--- /dev/null
@@ -0,0 +1,26 @@
+//
+// main include file for SKID
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_NETLIB_QT_SKID_EXPORT_H
+#define SKID_NETLIB_QT_SKID_EXPORT_H
+
+#include <QtGlobal>
+
+#ifdef SKIDNET_LIBBUILDSTATIC
+# define SKID_NETLIB_EXPORT 
+#else
+# ifdef SKIDNET_LIBBUILD
+#  define SKID_NETLIB_EXPORT Q_DECL_EXPORT
+# else
+#  define SKID_NETLIB_EXPORT Q_DECL_IMPORT
+# endif
+#endif
+
+#endif
\ No newline at end of file
diff --git a/network/include/skidnet.h b/network/include/skidnet.h
new file mode 100644 (file)
index 0000000..5d4c7a5
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// main network include file for SKID
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+///\file skid.h
+///Include this file to gain access to all SKID runner facilities.
+
+#ifndef SKID_NETLIB_QT_SKID_H
+#define SKID_NETLIB_QT_SKID_H
+
+#include "skidnet-export.h"
+
+///This is the main namespace in which all SKID specific functions and classes exist.
+namespace Skid {
+};
+
+
+#include "skid-connection.h"
+
+using namespace Skid;
+
+#endif
diff --git a/network/network.pro b/network/network.pro
new file mode 100644 (file)
index 0000000..b57a467
--- /dev/null
@@ -0,0 +1,52 @@
+#project file for SKID network lib
+
+#change this if you want to change the way the library is linked
+# static - static library (linked into runner executable)
+# shared - DLL or shared object (potentially less disk space, but you need to deploy the DLL)
+# Note: don't use CONFIG directly it will be overwritten below
+RUNNERBUILD += static
+#RUNNERBUILD += shared
+
+#how to handle debug symbols of the runner lib itself
+# debug - with debug symbols
+# release - no debug symbols, release mode
+# debug_and_release - build both (recommended for Windows)
+# -> with Visual Studio the above have to match your runner
+CONFIG += debug
+#CONFIG += release
+#CONFIG += debug_and_release
+
+#END of configuration
+##########################
+
+include (../common.pri)
+
+#non-negotiable configuration :-)
+DEFINES += SKIDNET_LIBBUILD=1
+
+equals(RUNNERBUILD, static) { 
+        DEFINES            += SKIDNET_LIBBUILDSTATIC=1 
+        PRL_EXPORT_DEFINES += SKIDNET_LIBBUILDSTATIC=1 
+        CONFIG += static
+} else {
+        CONFIG += shared separate_debug_info
+}
+
+
+#target spec
+TEMPLATE = lib
+TARGET = skidnet
+DESTDIR = $$LIBDIR
+QT += network
+QT -= gui
+
+#source dirs
+INCLUDEPATH += $$PWD/include $$PWD/src
+DEPENDPATH += $$INCLUDEPATH
+
+#sources
+SOURCES += \
+        src/skid-connection.cpp
+
+HEADERS += \
+        include/skid-connection.h
\ No newline at end of file
diff --git a/network/src/skid-connection.cpp b/network/src/skid-connection.cpp
new file mode 100644 (file)
index 0000000..9deb637
--- /dev/null
@@ -0,0 +1,19 @@
+//
+// network connection for SKID
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "skidnet.h"
+
+Connection::Connection ( QTcpSocket*, QObject *parent )
+        :QObject(parent)
+{
+}
+
+void Connection::readData(){}
+
diff --git a/runnerlib/qt5gui/guilibqt5.pro b/runnerlib/qt5gui/guilibqt5.pro
new file mode 100644 (file)
index 0000000..e336c3e
--- /dev/null
@@ -0,0 +1,51 @@
+#project file for SKID runnerlib for Qt5 based test runners
+
+#TODO: move this to skid.config
+#change this if you want to change the way the library is linked
+# static - static library (linked into runner executable)
+# shared - DLL or shared object (potentially less disk space, but you need to deploy the DLL)
+# Note: don't use CONFIG directly it will be overwritten below
+RUNNERBUILD += static
+#RUNNERBUILD += shared
+
+#how to handle debug symbols of the runner lib itself
+# debug - with debug symbols
+# release - no debug symbols, release mode
+# debug_and_release - build both (recommended for Windows)
+# -> with Visual Studio the above have to match your runner
+CONFIG += debug
+#CONFIG += release
+#CONFIG += debug_and_release
+
+#END of configuration
+##########################
+
+include (../../common.pri)
+
+#non-negotiable configuration :-)
+DEFINES += RUNNERQT5_LIBBUILD=1
+
+equals(RUNNERBUILD, static) { 
+        DEFINES            += RUNNERQT5_LIBBUILDSTATIC=1 
+        PRL_EXPORT_DEFINES += RUNNERQT5_LIBBUILDSTATIC=1 
+        CONFIG += static
+} else {
+        CONFIG += shared separate_debug_info
+}
+
+
+#target spec
+TEMPLATE = lib
+TARGET = skidguiqt5
+DESTDIR = $$LIBDIR
+QT += network
+QT -= gui
+
+#source dirs
+INCLUDEPATH += $$PWD/include $$PWD/src
+DEPENDPATH += $$INCLUDEPATH
+
+#sources
+SOURCES += 
+
+HEADERS += 
\ No newline at end of file
diff --git a/runnerlib/qt5gui/include/skidguiinit.h b/runnerlib/qt5gui/include/skidguiinit.h
new file mode 100644 (file)
index 0000000..4b44d93
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// SKID Examples: System In Test - initialize the GUI wrapper
+// This file is included by applications that want to auto-initialize.
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2014
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef SKID_GUI_PLUGIN_INIT_H
+#define SKID_GUI_PLUGIN_INIT_H
+
+#include <QStyleFactory>
+#include <QStyle>
+
+namespace Skid { namespace Gui {
+
+static inline bool initialize()
+{
+        //call the factory, which will implicitly load the plugin,
+        //the side effect of this is that the SKID GUI controller is initialized,
+        //... we don't really need the style object though ...
+        QStyle *st=QStyleFactory::create("skidstyle");
+        if(st){
+                delete st;
+                return true;
+        }else
+                return false;
+}
+
+}}
+
+#endif
index dd74852..15164d4 100644 (file)
--- a/skid.pro
+++ b/skid.pro
@@ -3,9 +3,9 @@
 TEMPLATE = subdirs
 SUBDIRS = copygen version \
         agent controller gui \
-        runnerqt5 \
+        runnerqt5 guiqt5 guiplugin \
         qt-simple qt-distrib \
-        sit
+        sit guisit guisiti network
 
 
 runnerqt5.file = runnerlib/qt5/runnerqt5.pro
@@ -20,8 +20,19 @@ qt-distrib.depends = runnerqt5 copygen version
 sit.file = examples/system-in-test/sit.pro
 sit.depends = copygen version
 
+guisit.file = examples/gui-system-in-test/sit.pro
+guisit.depends = copygen version
+
+guisiti.file = examples/gui-system-in-test/siti.pro
+guisiti.depends = copygen version guiqt5
+
+guiqt5.file = runnerlib/qt5gui/guilibqt5.pro
+guiqt5.depends = copygen version
+
 gui.depends = copygen version
 
+guiplugin.file = guiplugin/guiplugin.pro
+
 copygen.file = copygen/copygen.pro
 
 version.depends = copygen