# HG changeset patch # User hgs # Date 1281091691 -10800 # Node ID 1b485afba0842fab74b0e96d64fcb66df301ba0b # Parent 19b186e432764c67f74d3d87086f70a29a674187 201031 diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/auto.pro --- a/qthighway/tests/auto/auto.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs - -SUBDIRS= \ - xqservice \ -# xqserviceipc diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/qsignalintercepter.cpp --- a/qthighway/tests/auto/xqservice/common/qsignalintercepter.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include "qsignalintercepter.h" -#include -#include -#include - -/*! - \class QSignalIntercepter - \inpublicgroup QtBaseModule - - \brief The QSignalIntercepter class provides an interface for intercepting signals as meta-calls - - IPC mechanisms need to intercept signals and convert them into protocol - messages, but it is generally impractical to create a slot for every - signal that needs to be dispatched. The QSignalIntercepter class allows - signals to be intercepted as meta-calls so that IPC dispatching can - be implemented in a generic fashion. - - The activated() method is called whenever the signal is emitted, - with the arguments in a typed list. - - \sa QSlotInvoker - - \ingroup objectmodel -*/ - -class QSignalIntercepterPrivate -{ -public: - QObject *sender; - QByteArray signal; - int signalIndex; - int destroyIndex; - int slotIndex; - int *types; - int numArgs; - - ~QSignalIntercepterPrivate() - { - if ( types ) - qFree( types ); - } -}; - -/*! - Create a new signal intercepter which traps \a signal on \a sender. - The object will be attached to \a parent, if present. -*/ -QSignalIntercepter::QSignalIntercepter - ( QObject *sender, const QByteArray& signal, QObject *parent ) - : QObject( parent ) -{ - // Initialize the private members. - d = new QSignalIntercepterPrivate(); - d->sender = sender; - d->signal = signal; - d->signalIndex = -1; - d->destroyIndex = -1; - d->slotIndex = -1; - d->types = 0; - - // Resolve the indices of the signals we are interested in. - if ( sender && signal.size() > 0 ) { - // '2' is QSIGNAL_CODE in Qt 4.4 and below, - // '6' is QSIGNAL_CODE in Qt 4.5 and higher. - if ( signal[0] != '2' && signal[0] != '6' ) { - qWarning( "QSignalIntercepter: `%s' is not a valid signal " - "specification", signal.constData() ); - return; - } - QByteArray name = QMetaObject::normalizedSignature - ( signal.constData() + 1 ); - d->signalIndex - = sender->metaObject()->indexOfSignal( name.constData() ); - if ( d->signalIndex < 0 ) { - qWarning( "QSignalIntercepter: no such signal: %s::%s", - sender->metaObject()->className(), signal.constData() ); - return; - } - d->destroyIndex - = sender->metaObject()->indexOfSignal( "destroyed()" ); - d->types = connectionTypes( name, d->numArgs ); - } - - // Derive a fake slot index to use in our manual qt_metacall implementation. - d->slotIndex = staticMetaObject.methodCount(); - - // Connect up the signals. - if ( d->signalIndex >= 0 ) { - QMetaObject::connect( sender, d->signalIndex, - this, d->slotIndex, - Qt::DirectConnection, 0 ); - } - if ( d->destroyIndex >= 0 ) { - QMetaObject::connect( sender, d->destroyIndex, - this, d->slotIndex + 1, - Qt::DirectConnection, 0 ); - } -} - -/*! - Destroy a signal intercepter. -*/ -QSignalIntercepter::~QSignalIntercepter() -{ - if ( d->signalIndex >= 0 ) { - QMetaObject::disconnect( d->sender, d->signalIndex, - this, d->slotIndex ); - } - if ( d->destroyIndex >= 0 ) { - QMetaObject::disconnect( d->sender, d->destroyIndex, - this, d->slotIndex + 1 ); - } - delete d; -} - -/*! - Returns the sender that this signal interceptor is attached to. -*/ -QObject *QSignalIntercepter::sender() const -{ - return d->sender; -} - -/*! - Returns the name of the signal that this signal interceptor is attached to. -*/ -QByteArray QSignalIntercepter::signal() const -{ - return d->signal; -} - -/*! - Returns true if this signal intercepter is valid; that is, there was - a signal present with the specified parameters when this object - was constructed. -*/ -bool QSignalIntercepter::isValid() const -{ - return ( d->signalIndex != -1 ); -} - -/*! - \internal -*/ -int QSignalIntercepter::qt_metacall(QMetaObject::Call c, int id, void **a) -{ - id = QObject::qt_metacall(c, id, a); - if (id < 0) - return id; - if (c == QMetaObject::InvokeMetaMethod) { - switch (id) { - case 0: { - // The signal we are interested in has been activated. - if ( d->types ) { - QList args; - for ( int i = 0; i < d->numArgs; ++i ) { - if ( d->types[i] != QVariantId ) { - QVariant arg( d->types[i], a[i + 1] ); - args.append( arg ); - } else { - args.append( *((const QVariant *)( a[i + 1] )) ); - } - } - activated( args ); - } - } - break; - - case 1: { - // The sender has been destroyed. Clear the signal indices - // so that we don't try to do a manual disconnect when our - // own destructor is called. - d->signalIndex = -1; - d->destroyIndex = -1; - } - break; - } - id -= 2; - } - return id; -} - -/*! - \fn void QSignalIntercepter::activated( const QList& args ) - - Called when the signal that is being intercepted is activated. - The arguments to the signal are passed in the list \a args. -*/ - -// Get the QVariant type number for a type name. -int QSignalIntercepter::typeFromName( const QByteArray& type ) -{ - int id; - if (type.endsWith('*')) - return QMetaType::VoidStar; - else if ( type.size() == 0 || type == "void" ) - return QMetaType::Void; - else if ( type == "QVariant" ) - return QSignalIntercepter::QVariantId; - id = QMetaType::type( type.constData() ); - if ( id != (int)QMetaType::Void ) - return id; - return QVariant::nameToType(type); -} - -/*! - Returns the connection types associated with a signal or slot \a member - specification. The array of types is returned from this function, - and the number of arguments is returned in \a nargs. Returns null - if \a member is invalid. The return value must be freed with qFree(). -*/ -int *QSignalIntercepter::connectionTypes( const QByteArray& member, int& nargs ) -{ - // Based on Qt's internal queuedConnectionTypes function. - nargs = 0; - int *types = 0; - const char *s = member.constData(); - while (*s != '\0' && *s != '(') { ++s; } - if ( *s == '\0' ) - return 0; - ++s; - const char *e = s; - while (*e != ')') { - ++e; - if (*e == ')' || *e == ',') - ++nargs; - } - - types = (int *) qMalloc((nargs+1)*sizeof(int)); - types[nargs] = 0; - for (int n = 0; n < nargs; ++n) { - e = s; - while (*s != ',' && *s != ')') - ++s; - QByteArray type(e, s-e); - ++s; - - types[n] = typeFromName(type); - if (!types[n]) { - qWarning("QSignalIntercepter::connectionTypes: Cannot marshal arguments of type '%s'", type.data()); - qFree(types); - return 0; - } - } - return types; -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/qsignalintercepter.h --- a/qthighway/tests/auto/xqservice/common/qsignalintercepter.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef QSIGNALINTERCEPTER_H -#define QSIGNALINTERCEPTER_H - -#include -#include -#include - -class QSignalIntercepterPrivate; - -class QSignalIntercepter : public QObject -{ - // Note: Do not put Q_OBJECT here. - friend class QSlotInvoker; - friend class QCopProxy; -public: - QSignalIntercepter( QObject *sender, const QByteArray& signal, - QObject *parent=0 ); - ~QSignalIntercepter(); - - QObject *sender() const; - QByteArray signal() const; - - bool isValid() const; - - static const int QVariantId = -243; - - static int *connectionTypes( const QByteArray& member, int& nargs ); - -protected: - int qt_metacall( QMetaObject::Call c, int id, void **a ); - virtual void activated( const QList& args ) = 0; - -private: - QSignalIntercepterPrivate *d; - - static int typeFromName( const QByteArray& name ); -}; - -#endif diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/qslotinvoker.cpp --- a/qthighway/tests/auto/xqservice/common/qslotinvoker.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,234 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include "qslotinvoker.h" -#include "qsignalintercepter.h" -#include -#include -#include - -/*! - \class QSlotInvoker - \inpublicgroup QtBaseModule - - \brief The QSlotInvoker class provides an interface for invoking slots with explicit arguments - - IPC mechanisms need to intercept protocol messages and convert them into - slot invocations, but it is generally impractical to create explicit code - for every slot that needs to be dispatched. The QSlotInvoker class allows - an IPC dispatching mechanism to invoke slots in a generic fashion using - the invoke() method. - - Methods that are marked with Q_INVOKABLE or Q_SCRIPTABLE can also - be invoked with this class. - - \sa QSignalIntercepter - - \ingroup objectmodel -*/ - -class QSlotInvokerPrivate -{ -public: - QObject *receiver; - QByteArray member; - int memberIndex; - bool destroyed; - int returnType; - int *types; - int numArgs; - - ~QSlotInvokerPrivate() - { - if ( types ) - qFree( types ); - } -}; - -/*! - Create a slot invoker that can invoke \a member on \a receiver. - The object will be attached to \a parent, if present. -*/ -QSlotInvoker::QSlotInvoker( QObject *receiver, const QByteArray &member, - QObject *parent ) - : QObject( parent ) -{ - d = new QSlotInvokerPrivate(); - d->receiver = receiver; - QByteArray name; - if ( member.size() > 0 && member[0] >= '0' && member[0] <= '9' ) { - // Strip off the member type code. - name = member.mid(1); - } else { - name = member; - } - name = QMetaObject::normalizedSignature( name.constData() ); - d->member = name; - d->destroyed = false; - d->returnType = 0; - d->types = 0; - d->numArgs = 0; - if ( receiver && name.size() > 0 ) { - d->memberIndex - = receiver->metaObject()->indexOfMethod( name.constData() ); - } else { - d->memberIndex = -1; - } - if ( d->memberIndex != -1 ) { - QMetaMethod method = receiver->metaObject()->method - ( d->memberIndex ); - { - connect( receiver, SIGNAL(destroyed()), - this, SLOT(receiverDestroyed()) ); - d->returnType = - QSignalIntercepter::typeFromName( method.typeName() ); - d->types = QSignalIntercepter::connectionTypes - ( name, d->numArgs ); - if ( !( d->types ) ) - d->destroyed = true; - } - } else { - d->destroyed = true; - } -} - -/*! - Destroy a slot invoker. -*/ -QSlotInvoker::~QSlotInvoker() -{ - delete d; -} - -/*! - Returns true if the member is present on the object. -*/ -bool QSlotInvoker::memberPresent() const -{ - return ! d->destroyed; -} - -/*! - Returns true if the member can be invoked with \a numArgs arguments. - That is, the receiver has not been destroyed, the member is present, - and it requires \a numArgs or less arguments. -*/ -bool QSlotInvoker::canInvoke( int numArgs ) const -{ - if ( d->destroyed ) - return false; - return ( numArgs >= d->numArgs ); -} - -/*! - Returns the object that will receive slot invocations. -*/ -QObject *QSlotInvoker::receiver() const -{ - return d->receiver; -} - -/*! - Returns the member that will receiver slot invocations. -*/ -QByteArray QSlotInvoker::member() const -{ - return d->member; -} - -/*! - Returns the parameter types associated with this member. -*/ -int *QSlotInvoker::parameterTypes() const -{ - return d->types; -} - -/*! - Returns the number of parameter types associated with this member. -*/ -int QSlotInvoker::parameterTypesCount() const -{ - return d->numArgs; -} - -/*! - Invokes the slot represented by this object with the argument - list \a args. The slot's return value is returned from - this method. If the slot's return type is "void", then a - QVariant instance of type QVariant::Invalid will be returned. - - If it is possible that the slot may throw an exception, - it is the responsibility of the caller to catch and - handle the exception. -*/ -QVariant QSlotInvoker::invoke( const QList& args ) -{ - int arg; - QVariant returnValue; - - // Create a default instance of the return type for the result buffer. - if ( d->returnType != (int)QVariant::Invalid ) { - returnValue = QVariant( d->returnType, (const void *)0 ); - } - - // Bail out if the receiver object has already disappeared. - if ( d->destroyed ) - return returnValue; - - // Check that the number of arguments is compatible with the slot. - int numArgs = args.size(); - if ( numArgs < d->numArgs ) { - qWarning( "QSlotInvoker::invoke: insufficient arguments for slot" ); - return returnValue; - } else if ( numArgs > d->numArgs ) { - // Drop extraneous arguments. - numArgs = d->numArgs; - } - - // Construct the raw argument list. - QVarLengthArray a( numArgs + 1 ); - if ( d->returnType == (int)QVariant::Invalid ) - a[0] = 0; - else - a[0] = returnValue.data(); - for ( arg = 0; arg < numArgs; ++arg ) { - if ( d->types[arg] == QSignalIntercepter::QVariantId ) { - a[arg + 1] = (void *)&( args[arg] ); - } else if ( args[arg].userType() != d->types[arg] ) { - qWarning( "QSlotInvoker::invoke: argument %d has incorrect type", - arg ); - return QVariant(); - } else { - a[arg + 1] = (void *)( args[arg].data() ); - } - } - - // Invoke the specified slot. - d->receiver->qt_metacall( QMetaObject::InvokeMetaMethod, - d->memberIndex, a.data() ); - return returnValue; -} - -void QSlotInvoker::receiverDestroyed() -{ - d->destroyed = true; -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/qslotinvoker.h --- a/qthighway/tests/auto/xqservice/common/qslotinvoker.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef QSLOTINVOKER_H -#define QSLOTINVOKER_H - -#include -#include -#include - -class QSlotInvokerPrivate; - -class QSlotInvoker : public QObject -{ - Q_OBJECT -public: - QSlotInvoker( QObject *receiver, const QByteArray& member, - QObject *parent=0 ); - ~QSlotInvoker(); - - bool memberPresent() const; - bool canInvoke( int numArgs ) const; - QObject *receiver() const; - QByteArray member() const; - int *parameterTypes() const; - int parameterTypesCount() const; - -public slots: - QVariant invoke( const QList& args ); - -private slots: - void receiverDestroyed(); - -private: - QSlotInvokerPrivate *d; -}; - -#endif diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/xqservicechannel_stub.cpp --- a/qthighway/tests/auto/xqservice/common/xqservicechannel_stub.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -/* THIS IS A XQServiceChannel STUB used only for UNIT TEST */ - -#include - -#include "xqservicechannel.h" -#include "xqservicethreaddata.h" -#include "xqsharablefile.h" - -static QThreadStorage xqchannel; - -XQServiceChannel::XQServiceChannel(const QString& channel, bool isServer, QObject *parent) - : QObject(parent) -{ - d = new XQServiceChannelPrivate(this, channel, isServer); - xqchannel.setLocalData(d); -} - - -XQServiceChannel::~XQServiceChannel() -{ -} - -bool XQServiceChannel::connectChannel() -{ - return true; -} - -QString XQServiceChannel::channel() const -{ - return d->channel; -} - -QVariant XQServiceChannel::receive(const QString& msg, const QByteArray &data, const XQSharableFile &sf) -{ - emit received(msg, data,sf); - return QVariant(); -} - -void XQServiceChannel::commandReceive(const XQServiceCommand cmd) -{ - emit commandReceived(cmd); -} - -bool XQServiceChannel::send(const QString& channel, const QString& msg, - const QByteArray &data, QVariant &retValue, bool sync, XQServiceRequestCompletedAsync* rc) -{ - return send(channel,msg,data,retValue,sync,rc,NULL); -} - -bool XQServiceChannel::send(const QString& channel, const QString& msg, - const QByteArray &data, QVariant &retValue, - bool sync, XQServiceRequestCompletedAsync* rc, - const void* userData) -{ - XQServiceChannelPrivate* channelPrivate = xqchannel.localData(); - XQSharableFile dummy; - retValue = channelPrivate->object->receive(msg,data,dummy); - return true; -} - -bool XQServiceChannel::cancelPendingSend(const QString& channel) -{ - return true ; -} - -QVariant XQServiceChannel::sendLocally(const QString& ch, const QString& msg, - const QByteArray &data, const XQSharableFile &sf) -{ - /* - // filter out internal events - if (ch.isEmpty()) - return; - - // feed local clients with received data - XQServiceThreadData *td = XQService::serviceThreadData(); - QList clients = td->clientMap[ch]; - for (int i = 0; i < clients.size(); ++i) { - XQServiceChannelPrivate *channel = clients.at(i).data(); - if (channel->object) - channel->object->receive(msg, data); - } - */ - return QVariant(); -} - -int XQServiceChannel::latestError() - { - return -4998; - } - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/common/xqserviceipcclient_stub.cpp --- a/qthighway/tests/auto/xqservice/common/xqserviceipcclient_stub.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,184 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -/* THIS IS A XQServiceIpcClient STUB used only for UNIT TEST */ - -#include "xqserviceipcclient.h" -#include "xqservicechannel.h" -#include "xqservicethreaddata.h" - - -struct XQServicePacketHeader -{ - int totalLength; - int command; - int chLength; - int msgLength; - int dataLength; -}; - -XQServiceIpcClient::XQServiceIpcClient(const QString& ipcConName, bool isServer, bool isSync, - XQServiceRequestCompletedAsync* rc, - const void *userData) - : QObject(), serviceIpc(NULL), serviceIpcServer(NULL), callBackRequestComplete(rc), - mUserData(userData) -{ - mIpcConName = ipcConName; - server = isServer; - synchronous = isSync ; - currentRequest = NULL ; -} - -XQServiceIpcClient::~XQServiceIpcClient() -{ -disconnected(); -} - -bool XQServiceIpcClient::listen() -{ - return true; -} - -bool XQServiceIpcClient::connectToServer() -{ - return true; -} - -bool XQServiceIpcClient::handleRequest( ServiceIPCRequest *aRequest ) -{ - bool result(true); - int index = setCurrentRequest(aRequest); - - QVariant ret; - - if (!requestAsync) { - completeRequest(index,ret); - } - - return result; -} - -/*! - * From MServiceIPCObserver - * \see MServiceIPCObserver::handleCancelRequest( ServiceIPCRequest *aRequest ) - */ -void XQServiceIpcClient::handleCancelRequest( ServiceIPCRequest* /*aRequest*/ ) -{ -//TODO: -} - -/*! - * From MServiceIPCObserver - * \see MServiceIPCObserver::handleCancelRequest( ServiceIPCRequest *aRequest ) - */ -void XQServiceIpcClient::handleDeleteRequest( ServiceIPCRequest* /*aRequest*/ ) -{ -//TODO: -} - -bool XQServiceIpcClient::sendChannelCommand(int cmd, const QString& ch) -{ - return true; -} - -bool XQServiceIpcClient::send - (const QString& ch, const QString& msg, const QByteArray& data, QByteArray &retData, int cmd) -{ - return true; -} - -bool XQServiceIpcClient::cancelPendingSend(const QString& channel) -{ - return true; -} - -void XQServiceIpcClient::disconnected() -{ -} - -void XQServiceIpcClient::clientError(int error) -{ -} - -int XQServiceIpcClient::setCurrentRequest(ServiceIPCRequest* request) -{ - if (currentRequest && request) - return 0; - currentRequest = request; - requestAsync = false; - //TODO: - return 1; -} - -int XQServiceIpcClient::setCurrentRequestAsync() -{ - requestAsync = true; - //TODO: - return 1; -} - -bool XQServiceIpcClient::completeRequest(int index, const QVariant& retValue) -{ - //TODO: - Q_UNUSED(index); - if (!currentRequest) - return false; - - bool ret = true; - setCurrentRequest(NULL) ; - return ret; -} - - -// -// This function need to be called during a slot call before returning from -// the slot. -// The lastId might change after returning from the slot call as -// other possible requests may arrive -// -XQRequestInfo XQServiceIpcClient::requestInfo() const -{ - // Dummy - return XQRequestInfo(); -} - -// -// This internal function need to be called before a slot call to set the request info -// The provider can then call requestInfo() to get the data. -// The lastId might change after returning from the slot call as -// other possible requests may arrive -// -bool XQServiceIpcClient::setRequestInfo(XQRequestInfo &info) -{ - // Dummy - return true; -} - - - -void XQServiceIpcClient::readyRead() -{ -} - -void XQServiceIpcClient::readDone() -{ -} - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/runall.cmd --- a/qthighway/tests/auto/xqservice/runall.cmd Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -@rem -@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -@rem All rights reserved. -@rem -@rem This program is free software: you can redistribute it and/or modify -@rem it under the terms of the GNU Lesser General Public License as published by -@rem the Free Software Foundation, version 2.1 of the License. -@rem -@rem This program is distributed in the hope that it will be useful, -@rem but WITHOUT ANY WARRANTY; without even the implied warranty of -@rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -@rem GNU Lesser General Public License for more details. -@rem -@rem You should have received a copy of the GNU Lesser General Public License -@rem along with this program. If not, -@rem see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -@rem -@rem Description: -@rem - -@echo on - -call runtest.cmd ut_xqservicechannel -call runtest.cmd ut_xqserviceadaptor -call runtest.cmd ut_xqserviceprovider -call runtest.cmd ut_xqservicerequest -call runtest.cmd tst_xqservicechannel diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/runtest.cmd --- a/qthighway/tests/auto/xqservice/runtest.cmd Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -@rem -@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -@rem All rights reserved. -@rem -@rem This program is free software: you can redistribute it and/or modify -@rem it under the terms of the GNU Lesser General Public License as published by -@rem the Free Software Foundation, version 2.1 of the License. -@rem -@rem This program is distributed in the hope that it will be useful, -@rem but WITHOUT ANY WARRANTY; without even the implied warranty of -@rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -@rem GNU Lesser General Public License for more details. -@rem -@rem You should have received a copy of the GNU Lesser General Public License -@rem along with this program. If not, -@rem see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -@rem -@rem Description: -@rem - -@echo on - -call del %1.log - -:FINAL -call \epoc32\release\winscw\udeb\%1.exe -o c:\%1.log -call copy \epoc32\winscw\c\%1.log . -call type %1.log \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/tst_xqservicechannel/src/tst_xqservicechannel.cpp --- a/qthighway/tests/auto/xqservice/tst_xqservicechannel/src/tst_xqservicechannel.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,332 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include -#include -#include "xqservicechannel.h" -#include "xqsharablefile.h" - -const QString ConstReturnValue("ReturnValue=OK"); - -class TestChannel: public XQServiceChannel -{ - Q_OBJECT - -public: - TestChannel(const QString& ch, QObject *parent = 0) - : XQServiceChannel(ch,true,parent),count(0) - { - } - - ~TestChannel() - { - } - - QVariant receive(const QString& msg, const QByteArray &data); - -signals: - void received(); - -public: - QString lastMsg; - QByteArray lastData; - int count; -}; - -QVariant TestChannel::receive(const QString& msg, const QByteArray &data) -{ - lastMsg = msg; - lastData = data; - ++count; - return QVariant(ConstReturnValue); -} - -class ServerThread : public QThread -{ - Q_OBJECT - -public: - ServerThread(const QString ch,QObject *parent = 0) : QThread(parent), tstChannel(NULL), channel(ch) - { - } - - ~ServerThread() - { - } - -public slots: - -signals: - void serverThreadStarted(); - -protected: - void run(); - -public: - QString channel; - TestChannel* tstChannel; -}; - -void ServerThread::run() -{ - tstChannel = new TestChannel(channel); - bool ret = tstChannel->connectChannel(); - emit serverThreadStarted(); - exec(); - delete tstChannel; -} - -class tst_XQServiceChannel : public QObject, public XQServiceRequestCompletedAsync -{ - Q_OBJECT -public: - tst_XQServiceChannel() {} - ~tst_XQServiceChannel() {} - -private slots: - void initTestCase(); - void init(); - - void send_data(); - void send(); - - void sendLocally_data(); - void sendLocally(); - - void cleanup(); - void cleanupTestCase(); - -public slots: - void signalSeen(); - -public: - void requestCompletedAsync(const QVariant &retValue); - void requestErrorAsync(int err); - -signals: - void received(); - void sendLocally(const QString& ch, const QString& msg, - const QByteArray &data); -protected: - -private: - ServerThread* startThreadChannel(const QString &ch); - void stopThreadChannel(ServerThread* st); - - ServerThread *serverThread; - - QEventLoop *eventLoop; - bool signalAlreadySeen; - TestChannel* tstChannelLocally; - - void expectSignal(QObject *object, const char *signal); - bool waitForSignal(int timeout = 1000); - QVariant lastRetValue ; -}; - -void tst_XQServiceChannel::initTestCase() -{ - serverThread = startThreadChannel(QLatin1String("TestChannel")) ; - tstChannelLocally = new TestChannel(QLatin1String("TestChannelLocally")); - QVERIFY(tstChannelLocally->connectChannel()); - connect(tstChannelLocally, SIGNAL(received()), - this, SIGNAL(received())); -} - -void tst_XQServiceChannel::cleanupTestCase() -{ - stopThreadChannel(serverThread) ; -} - -void tst_XQServiceChannel::init() -{ -} - -void tst_XQServiceChannel::cleanup() -{ -} - -void tst_XQServiceChannel::send_data() -{ - QString currentChannel; - - if (qstrcmp(QTest::currentTestFunction(), "sendLocally") == 0){ - currentChannel = "TestChannelLocally"; - } - else { - currentChannel = "TestChannel"; - } - - QTest::addColumn("chan"); - QTest::addColumn("msg"); - QTest::addColumn("data"); - - QTest::newRow("simple") - << currentChannel - << "message()" - << QByteArray(); - - QTest::newRow("withargs") - << currentChannel - << "message(QString,int,QByteArray)" - << QByteArray(32, 'A'); - - QTest::newRow("longmessage") - << currentChannel - << (QLatin1String("message(QString,int,QByteArray)") + QString(1024, QChar('X'))) - << QByteArray(32, 'A'); - - QTest::newRow("longdata-1024") - << currentChannel - << "message(QString,int,QByteArray)" - << QByteArray(1024, 'A'); - - QTest::newRow("longdata-2048") - << currentChannel - << "message(QString,int,QByteArray)" - << QByteArray(2048, 'A'); - - QTest::newRow("longdata-4096") - << currentChannel - << "message(QString,int,QByteArray)" - << QByteArray(4096, 'A'); - - QTest::newRow("longdata-64K") - << currentChannel - << "message(QString,int,QByteArray)" - << QByteArray(65535, 'A'); -} - -void tst_XQServiceChannel::send() -{ - QFETCH(QString, chan); - QFETCH(QString, msg); - QFETCH(QByteArray, data); - - serverThread->tstChannel->count = 0; - - // We expect to see the received() signal if the message is delivered. - expectSignal(this, SIGNAL(received())); - - QVariant ret; // not used for asyn - - // Send the message. - QVERIFY(XQServiceChannel::send(chan, msg, data, ret, false,this)); - - // Wait until the message is delivered or a timeout occurs. - QVERIFY(waitForSignal()); - - // Check that the correct values were delivered. - QCOMPARE(lastRetValue.toString(), ConstReturnValue); - QCOMPARE(serverThread->tstChannel->lastMsg, msg); - QCOMPARE(serverThread->tstChannel->lastData, data); - QCOMPARE(serverThread->tstChannel->count, 1); -} - -void tst_XQServiceChannel::sendLocally_data() -{ - send_data(); -} - -void tst_XQServiceChannel::sendLocally() -{ - QFETCH(QString, chan); - QFETCH(QString, msg); - QFETCH(QByteArray, data); - - tstChannelLocally->count = 0; - - // Send the message. - XQSharableFile dummy; - QVariant ret = XQServiceChannel::sendLocally(chan, msg, data, dummy); - - // Check that the correct values were delivered. - QCOMPARE(ret.toString(), ConstReturnValue); - QCOMPARE(tstChannelLocally->lastMsg, msg); - QCOMPARE(tstChannelLocally->lastData, data); - QCOMPARE(tstChannelLocally->count, 1); - -} - -void tst_XQServiceChannel::expectSignal(QObject *object, const char *signal) -{ - signalAlreadySeen = false; - connect(object, signal, this, SLOT(signalSeen())); -} - -bool tst_XQServiceChannel::waitForSignal(int timeout) -{ - if (signalAlreadySeen) - return true; - QEventLoop loop; - eventLoop = &loop; - QTimer::singleShot(timeout, eventLoop, SLOT(quit())); - loop.exec(); - eventLoop = 0; - return signalAlreadySeen; -} - -void tst_XQServiceChannel::signalSeen() -{ - signalAlreadySeen = true; - if (eventLoop) - eventLoop->quit(); -} - -ServerThread* tst_XQServiceChannel::startThreadChannel(const QString &ch) -{ - ServerThread* st = new ServerThread(ch, this); - expectSignal(st, SIGNAL(serverThreadStarted())); - st->start(); - - QTest::qVerify(waitForSignal(), "startThreadChannel", "", __FILE__, __LINE__); - - disconnect(st, SIGNAL(serverThreadStarted()), this, SLOT(signalSeen())); - connect(st->tstChannel, SIGNAL(received()), - this, SIGNAL(received())); - - eventLoop = 0; - signalAlreadySeen = false; - return st; -} - -void tst_XQServiceChannel::stopThreadChannel(ServerThread* st) -{ - st->quit(); - st->wait(); - delete st; -} - -void tst_XQServiceChannel::requestCompletedAsync(const QVariant &retValue) -{ - lastRetValue = retValue; - emit received(); -} - -void tst_XQServiceChannel::requestErrorAsync(int err) -{ - //nothing to emit for error here -} - -QTEST_MAIN(tst_XQServiceChannel) - -#include "tst_xqservicechannel.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/tst_xqservicechannel/src/tst_xqservicechannel.pri --- a/qthighway/tests/auto/xqservice/tst_xqservicechannel/src/tst_xqservicechannel.pri Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -SOURCES += \ - src/tst_xqservicechannel.cpp diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/tst_xqservicechannel/tst_xqservicechannel.pro --- a/qthighway/tests/auto/xqservice/tst_xqservicechannel/tst_xqservicechannel.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -CONFIG += warn_on -QT -= gui -QT += testlib - -INCLUDEPATH += ../../../../inc -INCLUDEPATH += ../../../../xqservice/src - -include(src/tst_xqservicechannel.pri) - -symbian:LIBS += -lxqservice -lxqserviceutil - -symbian { - TARGET.EPOCSTACKSIZE = 0x5000 - TARGET.EPOCHEAPSIZE = "0x20000 0x1000000" - TARGET.CAPABILITY = ALL -TCB -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceadaptor/src/ut_xqserviceadaptor.cpp --- a/qthighway/tests/auto/xqservice/ut_xqserviceadaptor/src/ut_xqserviceadaptor.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,292 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include - -#include "xqserviceadaptor.h" -#include "xqservicechannel.h" -#include "qslotinvoker.h" -#include "qsignalintercepter.h" - -class ut_XQServiceAdaptor : public QObject -{ - Q_OBJECT -public: - ut_XQServiceAdaptor() {} - ~ut_XQServiceAdaptor() {} - -private slots: - void initTestCase(); - - void create(); - - void messageToSignal_data(); - void messageToSignal(); - - void signalToMessage_data(); - void signalToMessage(); - -public slots: - void signalSeen(); - void receive(const QString& msg, const QByteArray& data); - -signals: - void received(); - void sig_message1(); - void sig_message2(QString); - -private: - QEventLoop *eventLoop; - bool signalAlreadySeen; - QString lastMsg; - QByteArray lastData; - int count; - - void expectSignal(QObject *object, const char *signal); - void disconnectSignal(QObject *object, const char *signal); - bool waitForSignal(int timeout = 1000); - static QByteArray argsToData(const QString& msg, const QList& args); -}; - -void ut_XQServiceAdaptor::initTestCase() -{ - eventLoop = 0; - signalAlreadySeen = false; - count = 0; -} - -void ut_XQServiceAdaptor::create() -{ - // Create an adaptor and check that the channel name is returned correctly. - XQServiceAdaptor *adaptor = new XQServiceAdaptor(QLatin1String("com.nokia.test.Receiver")); - QCOMPARE(adaptor->channel(), QLatin1String("com.nokia.test.Receiver")); - - // Hook a message to a local signal, and then test that it is delivered. - // This tests that the adaptor is basically sane. - XQServiceAdaptor::connect(adaptor, MESSAGE(foobar()), this, SIGNAL(received())); - expectSignal(this, SIGNAL(received())); - QByteArray data; - QVariant retValue; - XQServiceChannel::send(QLatin1String("com.nokia.test.Receiver"), QLatin1String("foobar()"), data,retValue,false); //async - QVERIFY(waitForSignal()); - disconnectSignal(this, SIGNAL(received())); - - // Clean up. - delete adaptor; -} - -void ut_XQServiceAdaptor::messageToSignal_data() -{ - QTest::addColumn("chan"); - QTest::addColumn("msg"); - QTest::addColumn< QList >("params"); - - QTest::newRow("simple") - << "com.nokia.test.Receiver" << "message1()" - << QList(); - - QTest::newRow("singlearg") - << "com.nokia.test.Receiver" << "message2(QString)" - << (QList() << QString::fromLatin1("foo")); -} - -// Test the conversion of XQService messages into signals. -void ut_XQServiceAdaptor::messageToSignal() -{ - QFETCH(QString, chan); - QFETCH(QString, msg); - QFETCH(QList, params); - - // Construct the equivalent of MESSAGE(msg). - QByteArray messageName(1, QMESSAGE_CODE + '0'); - messageName += msg.toLatin1(); - - // Construct the equivalent of SIGNAL("sig_" msg). - QByteArray signalName(1, QSIGNAL_CODE + '0'); - signalName += "sig_"; - signalName += msg.toLatin1(); - - // Construct the adaptor and hook up the message. - XQServiceAdaptor *adaptor = new XQServiceAdaptor(chan); - XQServiceAdaptor::connect(adaptor, messageName, this, signalName); - - // Send a raw XQService message and wait for the signal. - expectSignal(this, signalName.constData()); - QVariant retValue; - XQServiceChannel::send(chan, msg, argsToData(msg, params),retValue,false); //async - QVERIFY(waitForSignal()); - disconnectSignal(this, signalName.constData()); - - // Clean up. - delete adaptor; -} - -void ut_XQServiceAdaptor::signalToMessage_data() -{ - messageToSignal_data(); -} - -// Test the conversion of signals into XQService messages. -void ut_XQServiceAdaptor::signalToMessage() -{ - QFETCH(QString, chan); - QFETCH(QString, msg); - QFETCH(QList, params); - - // Construct the equivalent of MESSAGE(msg). - QByteArray messageName(1, QMESSAGE_CODE + '0'); - messageName += msg.toLatin1(); - - // Construct the equivalent of SIGNAL("sig_" msg). - QByteArray signalName(1, QSIGNAL_CODE + '0'); - signalName += "sig_"; - signalName += msg.toLatin1(); - - // Construct the adaptor and hook up the message. - XQServiceAdaptor *adaptor = new XQServiceAdaptor(chan); - XQServiceAdaptor::connect(this, signalName, adaptor, messageName); - - // Consruct a XQService channel object to receive the message. - XQServiceChannel *channel = new XQServiceChannel(chan,true); - QVERIFY(channel->connectChannel()); - - connect(channel, SIGNAL(received(QString,QByteArray)), - this, SLOT(receive(QString,QByteArray))); - - // Emit the signal using QSlotInvoker and wait for the message. - count = 0; - QSlotInvoker *invoker = new QSlotInvoker(this, signalName.constData()); - expectSignal(this, SIGNAL(received())); - invoker->invoke(params); - QVERIFY(waitForSignal()); - QCOMPARE(count, 1); - QCOMPARE(lastMsg, msg); - QCOMPARE(lastData, argsToData(msg, params)); - disconnectSignal(this, SIGNAL(received())); - - // Clean up. - delete invoker; - - delete adaptor; - delete channel; -} - -void ut_XQServiceAdaptor::expectSignal(QObject *object, const char *signal) -{ - signalAlreadySeen = false; - connect(object, signal, this, SLOT(signalSeen())); -} - -void ut_XQServiceAdaptor::disconnectSignal(QObject *object, const char *signal) -{ - disconnect(object, signal, this, SLOT(signalSeen())); -} - -bool ut_XQServiceAdaptor::waitForSignal(int timeout) -{ - if (signalAlreadySeen) - return true; - QEventLoop loop; - eventLoop = &loop; - QTimer::singleShot(timeout, eventLoop, SLOT(quit())); - loop.exec(); - eventLoop = 0; - return signalAlreadySeen; -} - -void ut_XQServiceAdaptor::signalSeen() -{ - signalAlreadySeen = true; - if (eventLoop) - eventLoop->quit(); -} - -void ut_XQServiceAdaptor::receive(const QString& msg, const QByteArray& data) -{ - lastMsg = msg; - lastData = data; - ++count; - emit received(); -} - -class ExtendedVariant : public QVariant -{ -public: - ExtendedVariant() : QVariant() {} - explicit ExtendedVariant(const QVariant& value) - : QVariant(value) {} - - void load(QDataStream& stream, int typeOrMetaType) - { - clear(); - create(typeOrMetaType, 0); - d.is_null = false; - QMetaType::load(stream, d.type, const_cast(constData())); - } - - void save(QDataStream& stream) const - { - QMetaType::save(stream, d.type, constData()); - } -}; - -QByteArray ut_XQServiceAdaptor::argsToData(const QString& msg, const QList& args) -{ - QByteArray array; - { - QDataStream stream - (&array, QIODevice::WriteOnly | QIODevice::Append); - QList::ConstIterator iter; - if (!msg.contains(QLatin1String("QVariant"))) { - for (iter = args.begin(); iter != args.end(); ++iter) { - ExtendedVariant copy(*iter); - copy.save(stream); - } - } else { - QByteArray name = msg.toLatin1(); - name = QMetaObject::normalizedSignature(name.constData()); - int numParams = 0; - int *params = QSignalIntercepter::connectionTypes - (name, numParams); - int index = 0; - for (iter = args.begin(); iter != args.end(); ++iter, ++index) { - if (index < numParams && - params[index] == QSignalIntercepter::QVariantId) { - // We need to handle QVariant specially because we actually - // need the type header in this case. - stream << *iter; - } else { - ExtendedVariant copy(*iter); - copy.save(stream); - } - } - if (params) - qFree(params); - } - // Stream is flushed and closed at this point. - } - return array; -} - -QTEST_MAIN(ut_XQServiceAdaptor) - -#include "ut_xqserviceadaptor.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceadaptor/src/ut_xqserviceadaptor.pri --- a/qthighway/tests/auto/xqservice/ut_xqserviceadaptor/src/ut_xqserviceadaptor.pri Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -HEADERS += \ - ../../../../xqservice/src/xqserviceadaptor.h \ - ../../../../xqservice/src/xqservicethreaddata.h \ - ../../../../xqservice/src/xqserviceipcclient.h \ - ../../../../xqservice/src/xqservicechannel.h \ - ../common/qsignalintercepter.h \ - ../common/qslotinvoker.h - -SOURCES += \ - ../../../../xqservice/src/xqserviceadaptor.cpp \ - ../../../../xqservice/src/xqservicethreaddata.cpp \ - ../common/xqserviceipcclient_stub.cpp \ - ../common/xqservicechannel_stub.cpp \ - ../common/qsignalintercepter.cpp \ - ../common/qslotinvoker.cpp \ - src/ut_xqserviceadaptor.cpp - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceadaptor/ut_xqserviceadaptor.pro --- a/qthighway/tests/auto/xqservice/ut_xqserviceadaptor/ut_xqserviceadaptor.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -CONFIG += warn_on -QT -= gui -QT += testlib - -DEFINES += XQ_BUILD_XQSERVICE_LIB - -INCLUDEPATH += ../common -INCLUDEPATH += ../../../../xqservice/src -INCLUDEPATH += ../../../../inc - -include(src/ut_xqserviceadaptor.pri) - -symbian:LIBS += -lxqserviceutil - -symbian { - TARGET.EPOCSTACKSIZE = 0x5000 - TARGET.EPOCHEAPSIZE = "0x20000 0x1000000" - TARGET.CAPABILITY = ALL -TCB -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel.cpp --- a/qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,243 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include - -#include "xqservicechannel.h" - -#include "ut_xqservicechannel_threadstorage.h" - - -static QThreadStorage testServiceStorage; - -XQServiceChannelStorage* testStorage() -{ - if (!testServiceStorage.hasLocalData()) { - testServiceStorage.setLocalData(new XQServiceChannelStorage()); - } - - return testServiceStorage.localData() ; -} - -class testChannel : public XQServiceChannel -{ - Q_OBJECT -public: - explicit testChannel(const QString& channel, bool isServer, QObject *parent=0); - virtual ~testChannel(); - -public slots: - QVariant receive(const QString& msg, const QByteArray &data); - -signals: - void received(); - -public: - -public: - void clear(); - - QString lastMsg; - QByteArray lastData; - int count; - -}; - -testChannel::testChannel(const QString& channel, bool isServer, QObject *parent) -: XQServiceChannel(channel,isServer,parent) -{ -} - -testChannel::~testChannel() -{ -} - -QVariant testChannel::receive(const QString& msg, const QByteArray &data) -{ -lastMsg = msg; -lastData = data; -count++; -return QVariant(); -} - -void testChannel::clear() -{ -lastMsg.clear(); -lastData.clear(); -count=0; -} - -class ut_XQServiceChannel : public QObject -{ - Q_OBJECT - -public: - ut_XQServiceChannel() {} - ~ut_XQServiceChannel() {} - -private slots: - void initTestCase(); - void init(); - - void connectFail(); - - void sendFail(); - - void returnValue(); - - void testSendLocally(); - - void cleanup(); - void cleanupTestCase(); - -public slots: - -signals: - -public: - -private: -}; - -void ut_XQServiceChannel::initTestCase() -{ -} - -void ut_XQServiceChannel::cleanupTestCase() -{ -} - -void ut_XQServiceChannel::init() -{ - testStorage()->resetAll(); -} - -void ut_XQServiceChannel::cleanup() -{ -} - -void ut_XQServiceChannel::connectFail() -{ - XQServiceChannel* tstChannel; - - QString channel("com.nokia.test.Receiver"); - //fail in connect - testStorage()->failConnect = true; - - tstChannel = new XQServiceChannel(channel,true ); - QCOMPARE(channel,tstChannel->channel()); - QVERIFY(!tstChannel->connectChannel()); - delete tstChannel; - - //OK - testStorage()->failConnect = false; - tstChannel = new XQServiceChannel(channel,true ); - QCOMPARE(channel,tstChannel->channel()); - QVERIFY(tstChannel->connectChannel()); - delete tstChannel; -} - -void ut_XQServiceChannel::sendFail() -{ - QByteArray data; - QVariant retData; - QString channel("com.nokia.test.Receiver"); - - testStorage()->failConnect = true; - //fail in connection - QVERIFY(!XQServiceChannel::send(channel,QString("test(QString)"), data, retData,false)); //sync - - testStorage()->failConnect = false; - testStorage()->failSend = true; - //fail in send - QVERIFY(!XQServiceChannel::send(channel,QString("test(QString)"), data, retData,false)); //sync - - testStorage()->failSend = false; - //send ok - QVERIFY(XQServiceChannel::send(channel,QString("test(QString)"), data, retData,false)); //sync -} - -void ut_XQServiceChannel::returnValue() -{ - QString channel("com.nokia.test.Receiver"); -//TODO: test return value - testChannel* tstChannel = new testChannel(channel,true ); - QCOMPARE(channel,tstChannel->channel()); - QVERIFY(tstChannel->connectChannel()); - - delete tstChannel; -} - -void ut_XQServiceChannel::testSendLocally() -{ - QString channel("com.nokia.test.Receiver"); - - testChannel* tstChannel1 = new testChannel(channel+"_1",true ); - QCOMPARE(channel+"_1",tstChannel1->channel()); - QVERIFY(tstChannel1->connectChannel()); - - testChannel* tstChannel2 = new testChannel(channel+"_2",true ); - QCOMPARE(channel+"_2",tstChannel2->channel()); - QVERIFY(tstChannel2->connectChannel()); - - testChannel* tstChannel3 = new testChannel(channel+"_3",true ); - QCOMPARE(channel+"_3",tstChannel3->channel()); - QVERIFY(tstChannel3->connectChannel()); - - QByteArray data(200,'A'); - QVariant retData; - QString msg("test(QString)"); - tstChannel1->clear(); - tstChannel2->clear(); - tstChannel3->clear(); - QVERIFY(XQServiceChannel::send(channel+"_1",msg, data, retData,false)); //sync - QCOMPARE(tstChannel1->count,1); - QCOMPARE(tstChannel1->lastMsg,msg); - QCOMPARE(tstChannel1->lastData,data); - QCOMPARE(tstChannel2->count,0); - QCOMPARE(tstChannel3->count,0); - tstChannel1->clear(); - - QVERIFY(XQServiceChannel::send(channel+"_2",msg, data, retData,false)); //sync - QCOMPARE(tstChannel2->count,1); - QCOMPARE(tstChannel2->lastMsg,msg); - QCOMPARE(tstChannel2->lastData,data); - QCOMPARE(tstChannel1->count,0); - QCOMPARE(tstChannel3->count,0); - tstChannel2->clear(); - - QVERIFY(XQServiceChannel::send(channel+"_3",msg, data, retData,false)); //sync - QCOMPARE(tstChannel3->count,1); - QCOMPARE(tstChannel3->lastMsg,msg); - QCOMPARE(tstChannel3->lastData,data); - QCOMPARE(tstChannel1->count,0); - QCOMPARE(tstChannel2->count,0); - tstChannel3->clear(); - - delete tstChannel1; - delete tstChannel2; - delete tstChannel3; -} - -QTEST_MAIN(ut_XQServiceChannel) - -#include "ut_xqservicechannel.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel.pri --- a/qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel.pri Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -HEADERS += \ - ../../../../xqservice/src/xqservicechannel.h \ - ../../../../xqservice/src/xqservicethreaddata.h \ - ../../../../xqservice/src/xqserviceipcclient.h - -SOURCES += \ - ../../../../xqservice/src/xqservicechannel.cpp \ - ../../../../xqservice/src/xqservicethreaddata.cpp \ - src/xqserviceipcclient_stub.cpp \ - src/ut_xqservicechannel.cpp - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel_threadstorage.h --- a/qthighway/tests/auto/xqservice/ut_xqservicechannel/src/ut_xqservicechannel_threadstorage.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef UT_XQSERVICECHANNEL_THREADSTORAGE_H -#define UT_XQSERVICECHANNEL_THREADSTORAGE_H - -#include - -class XQServiceChannelStorage -{ -public: - XQServiceChannelStorage() - { - resetAll(); - } - - virtual ~XQServiceChannelStorage() {}; - - void resetAll() { - failConnect = false; - failSend = false; - }; - - bool failConnect; - bool failSend; - -}; - -XQServiceChannelStorage *testStorage() ; - -#endif diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicechannel/src/xqserviceipcclient_stub.cpp --- a/qthighway/tests/auto/xqservice/ut_xqservicechannel/src/xqserviceipcclient_stub.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -/* THIS IS A XQServiceIpcClient STUB used only for UNIT TEST */ - -#include "xqserviceipcclient.h" -#include "ut_xqservicechannel_threadstorage.h" - -#include "xqservicechannel.h" - -XQServiceIpcClient::XQServiceIpcClient( - const QString& ipcConName, bool isServer, bool isSync, XQServiceRequestCompletedAsync* rc, - const void *userData) - : QObject() -{ -} - -/* -void XQServiceIpcClient::init() -{ -} -*/ - -XQServiceIpcClient::~XQServiceIpcClient() -{ -} - -bool XQServiceIpcClient::listen() -{ - return !testStorage()->failConnect; -} - -bool XQServiceIpcClient::connectToServer() -{ - return !testStorage()->failConnect; -} - -bool XQServiceIpcClient::handleRequest( ServiceIPCRequest */*aRequest*/ ) -{ - return true; -} - -void XQServiceIpcClient::handleCancelRequest( ServiceIPCRequest* /*aRequest*/ ) -{ -} - -void XQServiceIpcClient::handleDeleteRequest( ServiceIPCRequest* /*aRequest*/ ) -{ -} - -bool XQServiceIpcClient::send - (const QString& ch, const QString& msg, const QByteArray& data, QByteArray& retData, int cmd) -{ - if (!testStorage()->failSend) { - XQServiceChannel::sendLocally(ch, msg, data); - } - - return !testStorage()->failSend; -} - -bool XQServiceIpcClient::cancelPendingSend(const QString& channel) -{ - return true; -} - -void XQServiceIpcClient::disconnected() -{ -} - -void XQServiceIpcClient::clientError(int error) -{ -} - -void XQServiceIpcClient::readyRead() -{ -} - -void XQServiceIpcClient::readDone() -{ -} - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicechannel/ut_xqservicechannel.pro --- a/qthighway/tests/auto/xqservice/ut_xqservicechannel/ut_xqservicechannel.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -CONFIG += warn_on -QT -= gui -QT += testlib - -DEFINES += XQ_BUILD_XQSERVICE_LIB - -INCLUDEPATH += ../common -INCLUDEPATH += ../../../../xqservice/src -INCLUDEPATH += ../../../../inc - -include(src/ut_xqservicechannel.pri) - -#symbian:LIBS += -lxqservice - -symbian { - TARGET.EPOCSTACKSIZE = 0x5000 - TARGET.EPOCHEAPSIZE = "0x20000 0x1000000" - TARGET.CAPABILITY = ALL -TCB -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceprovider/src/ut_xqserviceprovider.cpp --- a/qthighway/tests/auto/xqservice/ut_xqserviceprovider/src/ut_xqserviceprovider.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,205 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include - -#include "xqservicerequest.h" -#include "xqserviceprovider.h" - -class testServiceProvider; - -class ut_XQServiceProvider : public QObject -{ - Q_OBJECT -public: - ut_XQServiceProvider() {} - ~ut_XQServiceProvider() {} - -private slots: - void initTestCase(); - - void send_data(); - void send(); - -public slots: - -signals: - -private: - testServiceProvider* service; -}; - -class testServiceProvider : public XQServiceProvider -{ - Q_OBJECT -public: - testServiceProvider( QObject *parent = 0 ); - ~testServiceProvider(); - -public slots: - QString test1(const QString& par1); - QString test2(const QString& par1, int par2); - QString test3(const QString& par1, int par2, const QByteArray& par3); - -public: - void reset(); - - QString mMessage; - QString mPar1; - int mPar2; - QByteArray mPar3; - QString mRetValue; -}; - -testServiceProvider::testServiceProvider(QObject *parent) -: XQServiceProvider(QLatin1String("com.nokia.services.TestInterface"),parent) -{ -publishAll(); -} - -testServiceProvider::~testServiceProvider() -{ -} - -void testServiceProvider::reset() -{ -mMessage.clear(); -mPar1.clear(); -mPar2=0; -mPar3.clear(); -mRetValue.clear(); -} - -QString testServiceProvider::test1(const QString& par1) -{ -mMessage=QString("test1(QString)"); -mRetValue = par1+"-retTest1"; -mPar1 = par1; -return mRetValue; -} - -QString testServiceProvider::test2(const QString& par1, int par2) -{ -mMessage=QString("test2(QString,int)"); -mRetValue = par1+"-retTest2"; -mPar1 = par1; -mPar2 = par2; -return mRetValue; -} - -QString testServiceProvider::test3(const QString& par1, int par2, const QByteArray& par3) -{ -mMessage=QString("test3(QString,int,QByteArray)"); -mRetValue = par1+"-retTest3"; -mPar1 = par1; -mPar2 = par2; -mPar3 = par3; -return mRetValue; -} - -void ut_XQServiceProvider::initTestCase() -{ - service = new testServiceProvider(this); -} - -void ut_XQServiceProvider::send_data() -{ - QTest::addColumn("par1"); - QTest::addColumn("par2"); - QTest::addColumn("par3"); - - QTest::newRow("simple") - << QString("PARAM1") - << 1000 - << QByteArray(32, 'A'); - - QTest::newRow("longdata-1024") - << QString("PARAM1")+QString(1024, QChar('X')) - << 1000 - << QByteArray(1024, 'A'); - - QTest::newRow("longdata-2048") - << QString("PARAM1")+QString(2048, QChar('X')) - << 1000 - << QByteArray(2048, 'A'); - - QTest::newRow("longdata-4096") - << QString("PARAM1")+QString(4096, QChar('X')) - << 1000 - << QByteArray(4096, 'A'); - - QTest::newRow("longdata-64K") - << QString("PARAM1")+QString(65535, QChar('X')) - << 1000 - << QByteArray(65535, 'A'); -} - -void ut_XQServiceProvider::send() -{ - QFETCH(QString, par1); - QFETCH(int, par2); - QFETCH(QByteArray, par3); - - QVariant retValue; - bool res; - - QString msg1=QString("test1(QString)"); - XQServiceRequest snd1(QLatin1String("com.nokia.services.TestInterface"),msg1); - snd1 << par1; - res = snd1.send(retValue); - // Check that the correct values were delivered. - QCOMPARE(res, true); - QCOMPARE(service->mPar1, par1); - QCOMPARE(service->mMessage, msg1); - QCOMPARE(service->mRetValue, retValue.toString()); - - - QString msg2=QString("test2(QString,int)"); - XQServiceRequest snd2(QLatin1String("com.nokia.services.TestInterface"),msg2); - snd2 << par1; - snd2 << par2; - res = snd2.send(retValue); - // Check that the correct values were delivered. - QCOMPARE(res, true); - QCOMPARE(service->mPar1, par1); - QCOMPARE(service->mPar2, par2); - QCOMPARE(service->mMessage, msg2); - QCOMPARE(service->mRetValue, retValue.toString()); - - QString msg3=QString("test3(QString,int,QByteArray)"); - XQServiceRequest snd3(QLatin1String("com.nokia.services.TestInterface"),msg3); - snd3 << par1; - snd3 << par2; - snd3 << par3; - res = snd3.send(retValue); - // Check that the correct values were delivered. - QCOMPARE(res, true); - QCOMPARE(service->mPar1, par1); - QCOMPARE(service->mPar2, par2); - QCOMPARE(service->mPar3, par3); - QCOMPARE(service->mMessage, msg3); - QCOMPARE(service->mRetValue, retValue.toString()); -} - -QTEST_MAIN(ut_XQServiceProvider) - -#include "ut_xqserviceprovider.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceprovider/src/ut_xqserviceprovider.pri --- a/qthighway/tests/auto/xqservice/ut_xqserviceprovider/src/ut_xqserviceprovider.pri Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -HEADERS += \ - ../../../../xqservice/src/xqservicerequest.h \ - ../../../../xqservice/src/xqserviceprovider.h \ - ../../../../xqservice/src/xqserviceadaptor.h \ - ../../../../xqservice/src/xqservicethreaddata.h \ - ../../../../xqservice/src/xqserviceipcclient.h \ - ../../../../xqservice/src/xqservicechannel.h - -SOURCES += \ - ../../../../xqservice/src/xqservicerequest.cpp \ - ../../../../xqservice/src/xqserviceprovider.cpp \ - ../../../../xqservice/src/xqserviceadaptor.cpp \ - ../../../../xqservice/src/xqservicethreaddata.cpp \ - ../common/xqserviceipcclient_stub.cpp \ - ../common/xqservicechannel_stub.cpp \ - src/ut_xqserviceprovider.cpp - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqserviceprovider/ut_xqserviceprovider.pro --- a/qthighway/tests/auto/xqservice/ut_xqserviceprovider/ut_xqserviceprovider.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -CONFIG += warn_on -QT -= gui -QT += testlib - -DEFINES += XQ_BUILD_XQSERVICE_LIB - -INCLUDEPATH += ../common -INCLUDEPATH += ../../../../xqservice/src -INCLUDEPATH += ../../../../inc - -include(src/ut_xqserviceprovider.pri) - -symbian { - TARGET.EPOCSTACKSIZE = 0x5000 - TARGET.EPOCHEAPSIZE = "0x20000 0x1000000" - TARGET.CAPABILITY = ALL -TCB -} - -LIBS+=-lxqserviceutil \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicerequest/src/ut_xqservicerequest.cpp --- a/qthighway/tests/auto/xqservice/ut_xqservicerequest/src/ut_xqservicerequest.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,872 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include -#include - -#include "xqservicerequest.h" -#include "xqserviceprovider.h" - -class testServiceProvider; - -class ut_XQServiceRequest : public QObject -{ - Q_OBJECT -public: - ut_XQServiceRequest() {} - ~ut_XQServiceRequest() {} - -private slots: - void initTestCase(); - - void testClassIstantiation(); - void testSerializeArguments(); - - void testParam1(); - void testParam2(); - void testParam3(); - void testParam4(); - void testParam5(); - - void testRetParamBool(); - void testRetParamInt(); - void testRetParamUInt(); - void testRetParamQString(); - void testRetParamQStringList(); - void testRetParamQByteArray(); - void testRetParamQDate(); - void testRetParamQTime(); - void testRetParamQDateTime(); - void testRetParamQUrl(); - void testRetParamQSize(); - void testRetParamQSizeF(); - void testRetParamQPoint(); - void testRetParamQPointF(); - void testRetParamQRect(); - void testRetParamQRectF(); - void testRetParamTestContact(); - void testLatestError(); - -public slots: - -signals: - -private: - testServiceProvider* provider; -}; - -class TestContact -{ - friend bool operator==( const TestContact &c1, const TestContact &c2 ); -public: - - TestContact(); - ~TestContact(); - void setSurname(const QString&); - void setFirstname(const QString&); - void setNumber(const QString&); - void setDate(const QDate&); - void setUid(const QUuid&); - - QString surname(); - QString firstname(); - QString number(); - QDate date(); - QUuid uid(); - - template void serialize(Stream &stream) const; - template void deserialize(Stream &stream); - -private: - QString mSurname; - QString mFirstname; - QString mNumber; - QDate mBorn; - QUuid mUid; -}; - -inline bool operator== ( const TestContact & c1, const TestContact & c2 ) -{ - return (c1.mSurname == c2.mSurname) && - (c1.mFirstname == c2.mFirstname) && - (c1.mNumber == c2.mNumber) && - (c1.mBorn == c2.mBorn) && - (c1.mUid == c2.mUid); -} - - - -Q_DECLARE_USER_METATYPE(TestContact) - -#define METHOD_TEST1 "test1(bool,int,uint,QString,QStringList,QVariant)" -#define METHOD_TEST2 "test2(QByteArray,QDate,QTime,QDateTime,QUrl)" -#define METHOD_TEST3 "test3(QSize,QSizeF,QPoint,QPointF,QRect,QRectF)" -#define METHOD_TEST4 "test4(TestContact)" -#define METHOD_TEST5 "test5(QString,QString,QString,QString)" -#define SERVICE_TEST "com.nokia.services.TestInterface" - -class testServiceProvider : public XQServiceProvider -{ - Q_OBJECT -public: - testServiceProvider( QObject *parent = 0 ); - ~testServiceProvider(); - -public slots: - QString test1(bool parBool, - int parInt, - uint parUint, - const QString& parQstring, - const QStringList& parQStringList, - const QVariant& parVariant); - - QString test2(const QByteArray& parQByteArray, - const QDate& parQdate, - const QTime& parQTime, - const QDateTime& parQDateTime, - const QUrl& parQUrl); - - QString test3(const QSize& parQSize, - const QSizeF& parQSizeF, - const QPoint& parQPoint, - const QPointF& parQPointF, - const QRect& parQRect, - const QRectF& parQRectF); - - QString test4(const TestContact& parTestContact) ; - - QString test5( - const QString& par1, - const QString& par2, - const QString& par3, - const QString& par4); - - bool retParamBool(); - int retParamInt(); - uint retParamUInt(); - QString retParamQString(int size); - QStringList retParamQStringList(); - QByteArray retParamQByteArray(int size); - QDate retParamQDate(); - QTime retParamQTime(); - QDateTime retParamQDateTime(); - QUrl retParamQUrl(); - QSize retParamQSize(); - QSizeF retParamQSizeF(); - QPoint retParamQPoint(); - QPointF retParamQPointF(); - QRect retParamQRect(); - QRectF retParamQRectF(); - - TestContact retParamTestContact(); - -public: - void reset(); - - QString mMessage; - QString mRetValue; - - bool mParBool; - int mParInt; - uint mParUint; - QString mParQString; - QStringList mParQStringList; - QVariant mParVariant; - - QString mParQString1; - QString mParQString2; - QString mParQString3; - QString mParQString4; - - QByteArray mParQByteArray; - QDate mParQDate; - QTime mParQTime; - QDateTime mParQDateTime; - QUrl mParQUrl; - - QSize mParQSize; - QSizeF mParQSizeF; - QPoint mParQPoint; - QPointF mParQPointF; - QRect mParQRect; - QRectF mParQRectF; - - TestContact mParTestContact; - -}; - -testServiceProvider::testServiceProvider(QObject *parent) -: XQServiceProvider(QLatin1String(SERVICE_TEST),parent) -{ -publishAll(); -} - -testServiceProvider::~testServiceProvider() -{ -} - -void testServiceProvider::reset() -{ - mMessage.clear(); - - mParBool=false; - mParInt=0; - mParUint=0; - mParQString.clear(); - mParQStringList.clear(); - mParVariant.clear(); - - mRetValue.clear(); - - mParQByteArray.clear(); - mParQDate.setDate(0,0,0); - -} - -QString testServiceProvider::test1( - bool parBool, - int parInt, - uint parUint, - const QString& parQstring, - const QStringList& parQStringList, - const QVariant& parVariant) -{ - mMessage=QString(METHOD_TEST1); - mRetValue = "retTest1"; - mParBool=parBool; - mParInt=parInt; - mParUint=parUint; - mParQString=parQstring; - mParQStringList=parQStringList; - mParVariant=parVariant; - return mRetValue; -} - -QString testServiceProvider::test2( - const QByteArray& parQByteArray, - const QDate& parQdate, - const QTime& parQTime, - const QDateTime& parQDateTime, - const QUrl& parQUrl) -{ - mMessage=QString(METHOD_TEST2); - mRetValue = "retTest2"; - mParQByteArray=parQByteArray; - mParQDate=parQdate; - mParQTime=parQTime; - mParQDateTime=parQDateTime; - mParQUrl=parQUrl; - return mRetValue; -} - -QString testServiceProvider::test3( - const QSize& parQSize, - const QSizeF& parQSizeF, - const QPoint& parQPoint, - const QPointF& parQPointF, - const QRect& parQRect, - const QRectF& parQRectF) -{ - mMessage=QString(METHOD_TEST3); - mRetValue = "retTest3"; - mParQSize=parQSize; - mParQSizeF=parQSizeF; - mParQPoint=parQPoint; - mParQPointF=parQPointF; - mParQRect=parQRect; - mParQRectF=parQRectF; - return mRetValue; -} - -QString testServiceProvider::test4(const TestContact& parTestContact) -{ - mMessage=QString(METHOD_TEST4); - mRetValue = "retTest4"; - mParTestContact=parTestContact; - return mRetValue; -} - -QString testServiceProvider::test5( - const QString& par1, - const QString& par2, - const QString& par3, - const QString& par4) -{ - mMessage=QString(METHOD_TEST5); - mRetValue = "retTest5"; - mParQString1=par1; - mParQString2=par2; - mParQString3=par3; - mParQString4=par4; - return mRetValue; -} - -bool testServiceProvider::retParamBool() -{ -mParBool = true; -return mParBool; -} - -int testServiceProvider::retParamInt() -{ -mParInt = -98765; -return mParInt; -} - -uint testServiceProvider::retParamUInt() -{ -mParUint = 98765; -return mParUint; -} - -QString testServiceProvider::retParamQString(int size) -{ -mParQString.clear(); -mParQString = QString(size,'A'); -return mParQString; -} - -QStringList testServiceProvider::retParamQStringList() -{ -mParQStringList.clear(); -for (int i = 0 ; i < 10 ; i++) - mParQStringList << "string "+QString::number(i); -return mParQStringList; -} - -QByteArray testServiceProvider::retParamQByteArray(int size) -{ -mParQByteArray=QByteArray(size,'A'); -return mParQByteArray; -} - -QDate testServiceProvider::retParamQDate() -{ -mParQDate = QDate(2009,12,11); -return mParQDate; -} - -QTime testServiceProvider::retParamQTime() -{ -mParQTime = QTime(10,9,8); -return mParQTime; -} - -QDateTime testServiceProvider::retParamQDateTime() -{ -mParQDateTime = QDateTime(mParQDate,mParQTime); -return mParQDateTime; -} - -QUrl testServiceProvider::retParamQUrl() -{ -mParQUrl = QUrl("http://www.nokia.com"); -return mParQUrl; -} - -QSize testServiceProvider::retParamQSize() -{ -mParQSize = QSize(123,321); -return mParQSize; -} - -QSizeF testServiceProvider::retParamQSizeF() -{ -mParQSizeF = QSizeF(1234567890.54321,987654321.12345); -return mParQSizeF; -} - -QPoint testServiceProvider::retParamQPoint() -{ -mParQPoint = QPoint(1234,4321); -return mParQPoint; -} - -QPointF testServiceProvider::retParamQPointF() -{ -mParQPointF = QPointF(1234567890.54321,987654321.12345); -return mParQPointF; -} - -QRect testServiceProvider::retParamQRect() -{ -mParQRect = QRect(mParQPoint,mParQSize); -return mParQRect; -} - -QRectF testServiceProvider::retParamQRectF() -{ -mParQRectF = QRectF(mParQPointF,mParQSizeF); -return mParQRectF; -} - -TestContact testServiceProvider::retParamTestContact() -{ -mParTestContact.setSurname("piro-RetParam"); -mParTestContact.setFirstname("stephen-RetParam"); -mParTestContact.setNumber(QString("+35850987654321")); -mParTestContact.setDate(QDate(1963,12,17)); -mParTestContact.setUid(QUuid::createUuid()); -return mParTestContact; -} - -void ut_XQServiceRequest::initTestCase() -{ - provider = new testServiceProvider(this); -} - -void ut_XQServiceRequest::testClassIstantiation() -{ - QString service("com.nokia.service.test"); - QString msg("test(QString)"); - - { - XQServiceRequest snd; - QVERIFY(snd.isNull()); - snd.setService(service); - snd.setMessage(msg); - QVERIFY(!snd.isNull()); - QCOMPARE(snd.service(),service); - QCOMPARE(snd.message(),msg); - } - - { - XQServiceRequest snd(service,msg); - QVERIFY(!snd.isNull()); - QCOMPARE(snd.service(),service); - QCOMPARE(snd.message(),msg); - - XQServiceRequest snd1(snd); - QVERIFY(!snd1.isNull()); - QCOMPARE(snd1.service(),service); - QCOMPARE(snd1.message(),msg); - - QCOMPARE(snd,snd1); - } -} - -void ut_XQServiceRequest::testSerializeArguments() -{ - XQServiceRequest snd(QLatin1String(SERVICE_TEST),"test(QString,QDate,QTime)"); - - snd << QString("test") - << QDate(2009,1,1) - << QTime(8,1,2); - - QByteArray ret = XQServiceRequest::serializeArguments(snd); - - XQServiceRequest snd1(QLatin1String(SERVICE_TEST),"test(QString,QDate,QTime)"); - XQServiceRequest::deserializeArguments(snd1, ret); - - - QCOMPARE(snd,snd1); -} - -void ut_XQServiceRequest::testParam1() -{ - QString service(SERVICE_TEST); - QVariant ret; - bool par1 = true; - int par2 = -12345; - uint par3 = 54321; - QString par4("Test String"); - QStringList par5; - par5 << "string 1" << "string 2" << "string 3" ; - QVariant par6 = qVariantFromValue(QDate(1963,12,17)); - - QString msg(METHOD_TEST1); - XQServiceRequest snd(service,msg); - - snd << par1 << par2 << par3 << par4 << par5 << par6; - bool res = snd.send(ret); - // Check that the correct values were delivered. - QCOMPARE(res,true); - QCOMPARE(provider->mParBool,par1); - QCOMPARE(provider->mParInt, par2); - QCOMPARE(provider->mParUint, par3); - QCOMPARE(provider->mParQString, par4); - QCOMPARE(provider->mParQStringList, par5); - QCOMPARE(provider->mParVariant, par6); - QCOMPARE(provider->mMessage, msg); - QCOMPARE(provider->mRetValue, ret.toString()); -} - -void ut_XQServiceRequest::testParam2() -{ - QString service(SERVICE_TEST); - QVariant ret; - QByteArray par1(1024,'A'); - QDate par2(2009,12,17); - QTime par3(11,12,13); - QDateTime par4(par2,par3); - QUrl par5("http://www.nokia.com"); - - QString msg(METHOD_TEST2); - XQServiceRequest snd(service,msg); - - snd << par1 << par2 << par3 << par4 << par5; - bool res = snd.send(ret); - // Check that the correct values were delivered. - QCOMPARE(res,true); - QCOMPARE(provider->mParQByteArray,par1); - QCOMPARE(provider->mParQDate, par2); - QCOMPARE(provider->mParQTime, par3); - QCOMPARE(provider->mParQDateTime, par4); - QCOMPARE(provider->mParQUrl, par5); - QCOMPARE(provider->mMessage, msg); - QCOMPARE(provider->mRetValue, ret.toString()); -} - -void ut_XQServiceRequest::testParam3() -{ - QString service(SERVICE_TEST); - QVariant ret; - QSize par1(123,321); - QSizeF par2(1234567890.54321,987654321.12345); - QPoint par3(1234,4321); - QPointF par4(1234567890.54321,987654321.12345); - QRect par5(par3,par1); - QRectF par6(par4,par2); - - QString msg(METHOD_TEST3); - XQServiceRequest snd(service,msg); - - snd << par1 << par2 << par3 << par4 << par5 << par6; - bool res = snd.send(ret); - // Check that the correct values were delivered. - QCOMPARE(res,true); - QCOMPARE(provider->mParQSize,par1); - QCOMPARE(provider->mParQSizeF, par2); - QCOMPARE(provider->mParQPoint, par3); - QCOMPARE(provider->mParQPointF, par4); - QCOMPARE(provider->mParQRect, par5); - QCOMPARE(provider->mParQRectF, par6); - QCOMPARE(provider->mMessage, msg); - QCOMPARE(provider->mRetValue, ret.toString()); -} - -void ut_XQServiceRequest::testParam4() -{ - QString service(SERVICE_TEST); - QVariant ret; - TestContact par1; - par1.setSurname("piro"); - par1.setFirstname("stephen"); - par1.setNumber(QString("+35850987654321")); - par1.setDate(QDate(1963,12,17)); - par1.setUid(QUuid::createUuid()); - - QString msg(METHOD_TEST4); - XQServiceRequest snd(service,msg); - - snd << par1 ; - bool res = snd.send(ret); - // Check that the correct values were delivered. - QCOMPARE(res,true); - QCOMPARE(provider->mParTestContact,par1); - QCOMPARE(provider->mMessage, msg); - QCOMPARE(provider->mRetValue, ret.toString()); -} - -void ut_XQServiceRequest::testParam5() -{ - QString service(SERVICE_TEST); - QVariant ret; - QString par1 = "parameter 1"; - QString par2 = "parameter 2"; - QString par3 = "parameter 3"; - QString par4 = "parameter 4"; - - QString msg(METHOD_TEST5); - XQServiceRequest snd(service,msg); - - snd << par1 << par2 << par3 << par4; - bool res = snd.send(ret); - // Check that the correct values were delivered. - QCOMPARE(res,true); - QCOMPARE(provider->mParQString1,par1); - QCOMPARE(provider->mParQString2,par2); - QCOMPARE(provider->mParQString3,par3); - QCOMPARE(provider->mParQString4,par4); - QCOMPARE(provider->mMessage, msg); - QCOMPARE(provider->mRetValue, ret.toString()); -} - -void ut_XQServiceRequest::testRetParamBool() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamBool()"); - bool ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParBool, ret); -} - -void ut_XQServiceRequest::testRetParamInt() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamInt()"); - int ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParInt, ret); -} - -void ut_XQServiceRequest::testRetParamUInt() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamUInt()"); - uint ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParUint, ret); -} - -void ut_XQServiceRequest::testRetParamQString() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQString(int)"); - QList testSizes; - testSizes << 100 << 1024 << 2048 << 4096 ; - foreach(int size,testSizes) { - QString ret; - snd.setMessage("retParamQString(int)"); - snd << size ; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQString, ret); - } -} - -void ut_XQServiceRequest::testRetParamQStringList() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQStringList()"); - QStringList ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQStringList, ret); -} - -void ut_XQServiceRequest::testRetParamQByteArray() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQByteArray(int)"); - QList testSizes; - testSizes << 100 << 1024 << 2048 << 4096 ; - foreach(int size,testSizes) { - QByteArray ret; - snd.setMessage("retParamQByteArray(int)"); - snd << size ; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQByteArray, ret); - } - -} - -void ut_XQServiceRequest::testRetParamQDate() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQDate()"); - QDate ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQDate, ret); -} - -void ut_XQServiceRequest::testRetParamQTime() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQTime()"); - QTime ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQTime, ret); -} - -void ut_XQServiceRequest::testRetParamQDateTime() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQDateTime()"); - QDateTime ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQDateTime, ret); -} - -void ut_XQServiceRequest::testRetParamQUrl() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQUrl()"); - QUrl ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQUrl, ret); -} - -void ut_XQServiceRequest::testRetParamQSize() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQSize()"); - QSize ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQSize, ret); -} - -void ut_XQServiceRequest::testRetParamQSizeF() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQSizeF()"); - QSizeF ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQSizeF, ret); -} - -void ut_XQServiceRequest::testRetParamQPoint() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQPoint()"); - QPoint ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQPoint, ret); -} - -void ut_XQServiceRequest::testRetParamQPointF() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQPointF()"); - QPointF ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQPointF, ret); -} - -void ut_XQServiceRequest::testRetParamQRect() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQRect()"); - QRect ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQRect, ret); -} - -void ut_XQServiceRequest::testRetParamQRectF() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamQRectF()"); - QRectF ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParQRectF, ret); -} - -void ut_XQServiceRequest::testRetParamTestContact() -{ - XQServiceRequest snd(SERVICE_TEST,"retParamTestContact()"); - TestContact ret; - bool res = snd.send(ret); - QCOMPARE(res,true); - QCOMPARE(provider->mParTestContact,ret); -} - -void ut_XQServiceRequest::testLatestError() -{ - QString service(SERVICE_TEST); - QString msg(METHOD_TEST1); - XQServiceRequest snd(service,msg); - int error = snd.latestError(); - QCOMPARE(error,-4998); -} - - -TestContact::TestContact() -{ -} - -TestContact::~TestContact() -{ -} - -void TestContact::setSurname(const QString& surname) -{ -mSurname = surname; -} - -void TestContact::setFirstname(const QString& name) -{ -mFirstname = name; -} - -void TestContact::setNumber(const QString& number) -{ -mNumber = number; -} - -void TestContact::setDate(const QDate& date) -{ -mBorn = date; -} - -void TestContact::setUid(const QUuid& uid) -{ -mUid = uid; -} - - -QString TestContact::surname() -{ -return mSurname; -} - -QString TestContact::firstname() -{ -return mFirstname; -} - -QString TestContact::number() -{ -return mNumber; -} - -QDate TestContact::date() -{ -return mBorn; -} - -QUuid TestContact::uid() -{ -return mUid; -} - -Q_IMPLEMENT_USER_METATYPE(TestContact) - - -template void TestContact::serialize(Stream &s) const -{ - s << mSurname; - s << mFirstname; - s << mNumber; - s << mBorn; - s << mUid; -} - -template void TestContact::deserialize(Stream &s) -{ - s >> mSurname; - s >> mFirstname; - s >> mNumber; - s >> mBorn; - s >> mUid; -} - -QTEST_MAIN(ut_XQServiceRequest) - -#include "ut_xqservicerequest.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicerequest/src/ut_xqservicerequest.pri --- a/qthighway/tests/auto/xqservice/ut_xqservicerequest/src/ut_xqservicerequest.pri Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -HEADERS += \ - ../../../../xqservice/src/xqservicerequest.h \ - ../../../../xqservice/src/xqserviceadaptor.h \ - ../../../../xqservice/src/xqserviceprovider.h \ - ../../../../xqservice/src/xqservicethreaddata.h \ - ../../../../xqservice/src/xqserviceipcclient.h \ - ../../../../xqservice/src/xqservicechannel.h - -SOURCES += \ - ../../../../xqservice/src/xqservicerequest.cpp \ - ../../../../xqservice/src/xqserviceadaptor.cpp \ - ../../../../xqservice/src/xqserviceprovider.cpp \ - ../../../../xqservice/src/xqservicethreaddata.cpp \ - ../common/xqserviceipcclient_stub.cpp \ - ../common/xqservicechannel_stub.cpp \ - src/ut_xqservicerequest.cpp - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/ut_xqservicerequest/ut_xqservicerequest.pro --- a/qthighway/tests/auto/xqservice/ut_xqservicerequest/ut_xqservicerequest.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -CONFIG += warn_on -QT -= gui -QT += testlib - -DEFINES += XQ_BUILD_XQSERVICE_LIB - -INCLUDEPATH += ../common -INCLUDEPATH += ../../../../xqservice/src -INCLUDEPATH += ../../../../inc - -include(src/ut_xqservicerequest.pri) - -symbian { - TARGET.EPOCSTACKSIZE = 0x5000 - TARGET.EPOCHEAPSIZE = "0x20000 0x1000000" - TARGET.CAPABILITY = ALL -TCB -} - -LIBS+=-lxqserviceutil \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqservice/xqservice.pro --- a/qthighway/tests/auto/xqservice/xqservice.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs - -SUBDIRS= \ - tst_xqservicechannel \ - ut_xqserviceadaptor \ - ut_xqservicechannel \ - ut_xqserviceprovider \ - ut_xqservicerequest diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/client/serviceipctest.cpp --- a/qthighway/tests/auto/xqserviceipc/client/serviceipctest.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,665 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -/* -* Module Test cases for Service Framework IPC -*/ - -#include -#include -#include "commondefs.h" - -using namespace QtService; -// CONSTANTS -const int WAIT_TIME = 50000; // 5 seconds, must be a multiple of WAIT_INTERVAL -const int WAIT_INTERVAL = 100; // 100 ms - -class QIPCTestThread: public QThread -{ -private: - QSemaphore* iSem; - QString iName; - int iCount; - ServiceFwIPC* iIPC; -public: - QIPCTestThread( QSemaphore* aSem, QString aName ) - { - iSem = aSem; - iName = aName; - } - ~QIPCTestThread() - { - } - -protected: - void run() - { - TServiceIPCBackends backend; -#ifdef __SYMBIAN32__ - backend = ESymbianServer; -#else - backend = ELocalSocket; -#endif //__SYMBIAN32__ - - iIPC = new ServiceFwIPC( backend, NULL ); - iIPC->connect( TEST_SERVER_NAME ); - - for( int i=0; i<100; ++i ) - { - // Send 100 echo messages and verify the return - QString echo="echoechoecho_"; - echo+=iName; - bool sent = iIPC->sendSync( REQUEST_1, echo.toAscii() ); - if( sent == false ) - { - qDebug() << "Send error~!"; - } - - // Wait for a reply - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != echo ) - { - QFAIL("Thread verification error"); - } - // sleep a little and send again - } - delete iIPC; - - iSem->release(1); - } -}; - -class QIPClientTest : public QObject -{ -Q_OBJECT - // Member data - private: - ServiceFwIPC* iIPC; - bool connected; - bool iWaitForDownloadComplete; - int iTestLength; - - private slots: - // Automatically run at the start of entire test set - void initTestCase() - { - iIPC = NULL; - connected = false; - } - - // Automatically run at the start of each test case - //void init(); - - // Automatically run at the end of each test case - //void cleanup(); - - // Automatically run at the end of entire test set - //void cleanupTestCase(); - - // =============================================================== - // Test construction of the IPC client - // =============================================================== - void testConstruct() - { - TServiceIPCBackends backend; -#ifdef __SYMBIAN32__ - backend = ESymbianServer; -#else - backend = ELocalSocket; -#endif //__SYMBIAN32__ - iIPC = new ServiceFwIPC( backend, this); - - if( iIPC == NULL ) - { - QFAIL("Unable to create IPC object"); - } - } - - // =============================================================== - // Test connection to the client - // =============================================================== - void testStartServerAndConnect() - { - connected = iIPC->connect( TEST_SERVER_NAME ); - if( !connected ) - { - // Start the server and sleep 100ms to let it start - iIPC->startServer( TEST_SERVER_NAME,TEST_SERVER_EXE ); - QTest::qSleep(100); - connected = iIPC->connect( TEST_SERVER_NAME ); - - } - if( connected == false ) - { - QFAIL("Connection failure, cannot continue"); - } - } - - // =============================================================== - // Test simple IPC - // =============================================================== - void testSimpleIPC() - { - if( connected ) - { - // Send a simple "ECHO" message - qDebug() << "Test Case 1: ECHO client"; - QString echo="echoechoecho"; - bool sent = iIPC->sendSync( REQUEST_1, echo.toAscii() ); - if( sent == false ) - { - QFAIL("ECHO send failure"); - } - - // Wait for a reply - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != echo ) - { - QFAIL("ECHO receive failure"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, big buffer of messages 1k characters - // =============================================================== - void testSimpleIPC2() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 2: Sending a big message"; - QString bigString="This is going to be a very long string!!"; // 40 characters - QByteArray ary; - for( int i=0; i< 25; ++i ) - { - ary.append( bigString.toAscii() ); - } - bool sent = iIPC->sendSync( REQUEST_2, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "1000" ) - { - QFAIL("Big String receive failure (1k)"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, big buffer of messages 2k characters - // =============================================================== - void testSimpleIPC3() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 3: Sending a very big message"; - QString bigString="This is going to be a very long string!!"; // 40 characters - QByteArray ary; - for( int i=0; i< 50; ++i ) - { - ary.append( bigString.toAscii() ); - } - bool sent = iIPC->sendSync( REQUEST_2, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "2000" ) - { - QFAIL("Big String receive failure (2k)"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, big buffer of messages 4k characters - // =============================================================== - void testSimpleIPC4() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 4: Sending a very big message"; - QString bigString="This is going to be a very long string!!"; // 40 characters - QByteArray ary; - for( int i=0; i< 100; ++i ) - { - ary.append( bigString.toAscii() ); - } - bool sent = iIPC->sendSync( REQUEST_2, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "4000" ) - { - QFAIL("Big String receive failure (4k)"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, big buffer of messages 8k characters - // =============================================================== - void testSimpleIPC5() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 5: Sending a very big message"; - QString bigString="This is going to be a very long string!!"; // 40 characters - QByteArray ary; - for( int i=0; i< 200; ++i ) - { - ary.append( bigString.toAscii() ); - } - bool sent = iIPC->sendSync( REQUEST_2, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "8000" ) - { - QFAIL("Big String receive failure (8k)"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, ECHO service with server returning data async - // =============================================================== - void testSimpleIPC6() - { - // Test ECHO service with async IPC on server side, callback later - if( connected ) - { - // Send a simple "ECHO" message - qDebug() << "Test Case 6: ECHO client async server"; - QString echo="echoechoecho"; - bool sent = iIPC->sendSync( REQUEST_3, echo.toAscii() ); - if( sent == false ) - { - QFAIL("ECHO send failure"); - } - - // Wait for a reply - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != echo ) - { - QFAIL("ECHO receive failure"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test simple IPC, big buffer of messages 1k/2k/4k/8k characters returned async - // =============================================================== - void testSimpleIPC7() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 7: Sending a big message"; - QString bigString="This is going to be a very long string!!"; // 40 characters - QByteArray ary; - for( int i=0; i< 25; ++i ) - { - ary.append( bigString.toAscii() ); - } - bool sent = iIPC->sendSync( REQUEST_4, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "1000" ) - { - QFAIL("Big String receive failure (1k)"); - } - - // Reset for 2000 character case - ary.clear(); - for( int i=0; i< 50; ++i ) - { - ary.append( bigString.toAscii() ); - } - sent = iIPC->sendSync( REQUEST_4, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "2000" ) - { - QFAIL("Big String receive failure (2k)"); - } - - // Reset for 4000 character case - ary.clear(); - for( int i=0; i< 100; ++i ) - { - ary.append( bigString.toAscii() ); - } - sent = iIPC->sendSync( REQUEST_4, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "4000" ) - { - QFAIL("Big String receive failure (4k)"); - } - - // Reset for 4000 character case - ary.clear(); - for( int i=0; i< 200; ++i ) - { - ary.append( bigString.toAscii() ); - } - sent = iIPC->sendSync( REQUEST_4, ary ); - if( sent == false ) - { - QFAIL("Send large string failure"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - qDebug() << "ECHO Returned: " << rtn; - if( rtn != "8000" ) - { - QFAIL("Big String receive failure (8k)"); - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test receiving big buffers on client side sync - // =============================================================== - void testSimpleIPC8() - { - if( connected ) - { - // Send a large 1k message - qDebug() << "Test Case 8: Receiving a very big buffer"; - - QByteArray ary; - ary.setNum(1000); - bool sent = iIPC->sendSync( REQUEST_5, ary ); - if( sent == false ) - { - QFAIL("Sending request failed"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - QString rtn = QString(iIPC->readAll()); - if( rtn.length() != 1000 ) - { - QFAIL("Receiving a very long string failed"); - } - else - { - qDebug() << "Test Case 8: Receiving a very big buffer 1000 ok"; - } - // Ask for a 2k return buffer - // - ary.clear(); - ary.setNum(2000); - sent = iIPC->sendSync( REQUEST_5, ary ); - if( sent == false ) - { - QFAIL("Sending request failed"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - if( rtn.length() != 2000 ) - { - QFAIL("Receiving a very long string failed"); - } - else - { - qDebug() << "Test Case 8: Receiving a very big buffer 2000 ok"; - } - // Ask for a 2k return buffer - // - ary.clear(); - ary.setNum(4000); - sent = iIPC->sendSync( REQUEST_5, ary ); - if( sent == false ) - { - QFAIL("Sending request failed"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - if( rtn.length() != 4000 ) - { - QFAIL("Receiving a very long string failed"); - } - else - { - qDebug() << "Test Case 8: Receiving a very big buffer 4000 ok"; - } - - ary.clear(); - ary.setNum(8000); - sent = iIPC->sendSync( REQUEST_5, ary ); - if( sent == false ) - { - QFAIL("Sending request failed"); - } - - // Wait for a reply, the reply should be the length of data received - iIPC->waitForRead(); - rtn = QString(iIPC->readAll()); - if( rtn.length() != 8000 ) - { - QFAIL("Receiving a very long string failed"); - } - else - { - qDebug() << "Test Case 8: Receiving a very big buffer 8000 ok"; - } - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test receiving big buffers on client side async - // =============================================================== - void testSimpleIPC9() - { - if( connected ) - { - doReceiveAsyncBigBuffer( 1000 ); -#ifndef __SYMBIAN32__ - doReceiveAsyncBigBuffer( 2000 ); - doReceiveAsyncBigBuffer( 4000 ); - doReceiveAsyncBigBuffer( 8000 ); -#endif // __SYMBIAN32__ - } - else - { - QFAIL("Cannot run!"); - } - } - - // =============================================================== - // Test disconnect and destruction of the IPC client - // =============================================================== - void testSimpleIPC10() - { - // Test multi-threaded client read/write - QSemaphore sem(0); - - QIPCTestThread* thread1 = new QIPCTestThread(&sem,"thread1"); - QIPCTestThread* thread2 = new QIPCTestThread(&sem,"thread2"); - thread1->start(); - thread2->start(); - // Wait until both threads die - sem.acquire(2); - delete thread1; - delete thread2; - } - - // =============================================================== - // Test disconnect and destruction of the IPC client - // =============================================================== - void testDisconnect() - { - iIPC->sendSync( KILL_SERVER, "" ); - iIPC->waitForRead(); - iIPC->disconnect(); - QTest::qWait(2500); - delete iIPC; - iIPC = NULL; - } - -// Utility functions -private: - void WaitForTestComplete() - { - int num = WAIT_TIME / WAIT_INTERVAL; - num*=3; - iWaitForDownloadComplete = true; - while ( num-- > 0 && iWaitForDownloadComplete ) - { - QTest::qWait(WAIT_INTERVAL); - } - if( iWaitForDownloadComplete == true ) - { - qDebug() << "Timed out"; - } - QVERIFY2( iWaitForDownloadComplete == false, "Test case timed out" ); - iWaitForDownloadComplete = false; - } - - void doReceiveAsyncBigBuffer( int aSize ) - { - qDebug() << "Test Case 9: Receiving a very big buffer of size: " << aSize;\ - iTestLength = aSize; - QByteArray ary; - ary.setNum(aSize); - iIPC->sendAsync( REQUEST_5, ary ); - // Wait for signal - QObject::connect(iIPC, SIGNAL( readyRead() ), - this, SLOT( handleReadyRead() ) ); - WaitForTestComplete(); - // Cleanup signals - QObject::disconnect(iIPC, SIGNAL( readyRead() ), - this, SLOT( handleReadyRead() ) ); - } - -public slots: - void handleReadyRead() - { - QString rtn = iIPC->readAll(); - if( rtn.length() != iTestLength ) - { - QFAIL("Receiving a very long string failed"); - } - else - { - qDebug() << "Test Case 9: Receiving a very big buffer " << iTestLength << " ok"; - } - iWaitForDownloadComplete = false; - } -}; - -QTEST_MAIN(QIPClientTest); -#include "serviceipctest.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/client/serviceipctest.pro --- a/qthighway/tests/auto/xqserviceipc/client/serviceipctest.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -QT += testlib -TEMPLATE = app -TARGET = -DESTDIR = ../../../../bin -INCLUDEPATH += ../../../../inc ../ - -SOURCES += serviceipctest.cpp - -LIBS += -L../../../../bin -lxqserviceipcclient - -symbian { - TARGET.CAPABILITY = CAP_APPLICATION - TARGET.EPOCSTACKSIZE = 0x8000 - TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000 -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/commondefs.h --- a/qthighway/tests/auto/xqserviceipc/commondefs.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef __COMMONDEFS_H_ -#define __COMMONDEFS_H_ - -static const char TEST_SERVER_NAME[] = "testipcserver"; -static const char TEST_SERVER_EXE[] = "serviceipcservertest.exe"; -static const char REQUEST_1[] = "testcase1"; -static const char REQUEST_2[] = "testcase2"; -static const char REQUEST_3[] = "testcase3"; -static const char REQUEST_4[] = "testcase4"; -static const char REQUEST_5[] = "testcase5"; -static const char REQUEST_6[] = "testcase6"; -static const char REQUEST_7[] = "testcase7"; -static const char REQUEST_8[] = "testcase8"; -static const char REQUEST_9[] = "testcase9"; -static const char REQUEST_10[] = "testcase10"; -static const char KILL_SERVER[] = "Kill!"; - -#endif __COMMONDEFS_H_ - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/server/serviceipcservertest.cpp --- a/qthighway/tests/auto/xqserviceipc/server/serviceipcservertest.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -/* -* Module Test cases for Service Framework IPC -*/ - -#include -#include -#include -#include -#include -#include "commondefs.h" - -#ifdef __SYMBIAN32__ -#include -#endif // __SYMBIAN32__ - -using namespace QtService; - -// CONSTANTS -class QIPCServerTest : public QObject, public MServiceIPCObserver -{ - Q_OBJECT - public: - QIPCServerTest::QIPCServerTest() - { - TServiceIPCBackends backend; -#ifdef __SYMBIAN32__ - backend = ESymbianServer; -#else - backend = ELocalSocket; -#endif //__SYMBIAN32__ - iServer = new ServiceFwIPCServer( backend, this, this ); - iServer->listen( TEST_SERVER_NAME ); - } - - QIPCServerTest::~QIPCServerTest() - { - iServer->disconnect(); - } - - private: - // =============================================================== - // From MServiceIPCObserver - // =============================================================== - bool handleRequest( ServiceIPCRequest* aRequest ) - { - if( aRequest->getOperation() == REQUEST_1 ) - { - // Simply echo the data back to the client - aRequest->write( aRequest->getData() ); - aRequest->completeRequest(); - } - else if( aRequest->getOperation() == REQUEST_2 ) - { - int length = aRequest->getData().length(); - QString reply; - reply.setNum( length ); - aRequest->write( reply.toAscii() ); - aRequest->completeRequest(); - } - else if( aRequest->getOperation() == REQUEST_3 || - aRequest->getOperation() == REQUEST_4 ) - { - // Callback in 100ms - QTimer::singleShot( 100, this, SLOT( doAsyncCallback() ) ); - iAsyncRequest = aRequest; - } - else if( aRequest->getOperation() == REQUEST_5 ) - { - int length = aRequest->getData().toLong(); - - QByteArray data; - for( int i=0; iwrite( data ); - aRequest->completeRequest(); - } - else if( aRequest->getOperation() == KILL_SERVER ) - { - aRequest->write( "bye" ); - aRequest->completeRequest(); - QCoreApplication::quit(); - } - return true; - } - - // =============================================================== - // From MServiceIPCObserver - // =============================================================== - void handleCancelRequest( ServiceIPCRequest* /*aRequest*/ ) - { - } - - void handleDeleteRequest( ServiceIPCRequest* /*aRequest*/ ) - { - } - - public slots: - - // =============================================================== - // From MServiceIPCObserver - // =============================================================== - void doAsyncCallback() - { - if( iAsyncRequest ) - { - if( iAsyncRequest->getOperation() == REQUEST_3 ) - { - // Simply echo the data back to the client - iAsyncRequest->write( iAsyncRequest->getData() ); - iAsyncRequest->completeRequest(); - iAsyncRequest = NULL; - } - else if ( iAsyncRequest->getOperation() == REQUEST_4 ) - { - int length = iAsyncRequest->getData().length(); - QString reply; - reply.setNum( length ); - iAsyncRequest->write( reply.toAscii() ); - iAsyncRequest->completeRequest(); - iAsyncRequest = NULL; - } - } - } - private: - ServiceFwIPCServer* iServer; - ServiceIPCRequest* iAsyncRequest; // not owned -}; - -#ifdef __SYMBIAN32__ -LOCAL_C void StartServerL() - { - // Some test code - User::LeaveIfError(User::RenameThread(_L("testipcserver"))); - CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; - CleanupStack::PushL(scheduler); - CActiveScheduler::Install(scheduler); - QIPCServerTest* server = new QIPCServerTest(); - RProcess::Rendezvous(KErrNone); - - RProcess proc; - TInt err = proc.Create(_L("serviceipctest.exe"),_L("")); - proc.Resume(); - CActiveScheduler::Start(); - CActiveScheduler::Install(NULL); - CleanupStack::PopAndDestroy(scheduler); - } -#endif // __SYMBIAN32__ - -int main(int argc, char *argv[]) -{ - // Simple test application -#if 1 - QCoreApplication a(argc, argv); - QIPCServerTest* server = new QIPCServerTest(); - - int rtn = a.exec(); - delete server; -#else // __SYMBIAN32__ - // Symbian currently does not support >1 QT processes on windows, so we run a traditional server - CTrapCleanup* cleanup=CTrapCleanup::New(); - TInt rtn(KErrNoMemory); - if (cleanup) - { - TRAP(rtn,StartServerL()); - } - - delete cleanup; -#endif // __SYMBIAN32__ - - return rtn; -} - -#include "serviceipcservertest.moc" diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/server/serviceipcservertest.pro --- a/qthighway/tests/auto/xqserviceipc/server/serviceipcservertest.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -QT += testlib -TEMPLATE = app -TARGET = -DESTDIR = ../../../../bin -INCLUDEPATH += ../../../../inc ../ - -SOURCES += serviceipcservertest.cpp - -LIBS += -L../../../../bin -lxqserviceipcserver - -symbian { - TARGET.CAPABILITY = CAP_SERVER - TARGET.EPOCSTACKSIZE = 0x8000 - TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000 -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/auto/xqserviceipc/xqserviceipc.pro --- a/qthighway/tests/auto/xqserviceipc/xqserviceipc.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs -CONFIG += ordered -SUBDIRS = ./server/serviceipcservertest.pro \ - ./client/serviceipctest.pro diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp/testapp.cpp --- a/qthighway/tests/testapps/testapp/testapp.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "testapp.h" - -TestApp1::TestApp1( QWidget *parent, Qt::WFlags f ) : QWidget( parent,f ) - { - qDebug() << "[QTH] [TestApp1] TestApp1: START"; - QPalette p = qApp->palette(); - QColor color(80,20,20); - QColor bg(256,20,20); - p.setColor(QPalette::Highlight, color.lighter(200)); - p.setColor(QPalette::Text, Qt::white); - p.setColor(QPalette::Base, bg); - p.setColor(QPalette::WindowText, Qt::white); - p.setColor(QPalette::Window, bg); - p.setColor(QPalette::ButtonText, Qt::white); - p.setColor(QPalette::Button, color.lighter(150)); - p.setColor(QPalette::Link, QColor(240,40,40)); - - qApp->setPalette(p); - - QPushButton *quitButton = new QPushButton(tr("quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - - QPushButton *sendButton = new QPushButton(tr("asynsend 10 times")); - connect(sendButton, SIGNAL(clicked()), this, SLOT(asyncsend())); - - label = new QLabel("Test App1"); - - QVBoxLayout *vl = new QVBoxLayout; - vl->setMargin(0); - vl->setSpacing(0); - - vl->addWidget(label); - vl->addWidget(sendButton); - vl->addWidget(quitButton); - - setLayout(vl); - //showMaximized(); - showFullScreen(); - - i = 0; - request = NULL; - asyncsend(); - qDebug() << "[QTH] [TestApp1] TestApp1: END"; - } - -void TestApp1::requestCompletedWithError(int err) - { - qDebug() << "[QTH] [TestApp1] requestCompletedWithError START "; - qDebug() << "[QTH] [TestApp1] error = " << err << " !!!"; - qDebug() << "[QTH] [TestApp1] requestCompletedWithError END "; - } - -void TestApp1::requestCompleted(const QVariant& data) -{ - i++; - qDebug() << "[QTH] [TestApp1] requestCompleted START "; - qDebug() << "[QTH] [TestApp1] \t data: " << data.toString() << ", i: " << i; - - if ( i <= 20 ) - { - qDebug() << "[QTH] [TestApp1] \t i <= 20 trigger again()"; - QString string; - string.append("Test app1 -->"); - string.append(48+i); - string.append("times"); - label->setText(string); - asyncsend(); - } - else - { - /*qDebug() << "[QTH] [TestApp1] \t i > 20, setText()"; - label->setText("Test app1 Done!"); - if(request) - { - qDebug() << "[QTH] [TestApp1] \t \t request != null, delete request"; - delete request; - request=NULL; - }*/ - qDebug() << "[QTH] [TestApp1] \t request sent 20 times!!!"; - } - - qDebug() << "[QTH] [TestApp1] requestCompleted STOP"; -} - - - -void TestApp1::asyncsend() -{ - qDebug() << "[QTH] [TestApp1] asyncsend: START"; - - QString testString("Test Application 1"); - int testInt(112233); - - QString service("com.nokia.services.testservice.TestService"); - QString method("asyncWithParams(QString,int)"); - - if (!request) - { - qDebug() << "[QTH] [TestApp1] \t creating request"; - request = new XQServiceRequest(service, method, false); - qDebug() << "[QTH] [TestApp1] \t connecting signal request->requestCompleted to slot this.requestCompleted"; - bool res = connect(request, SIGNAL(requestCompleted(QVariant)), this, SLOT(requestCompleted(QVariant)) ); - qDebug() << "[QTH] [TestApp1] \t connect = " << res; - qDebug() << "[QTH] [TestApp1] \t connecting signal request->requestError to slot this.requestCompletedWithError"; - res = connect(request, SIGNAL(requestError(int)), this, SLOT(requestCompletedWithError(int)) ); - qDebug() << "[QTH] [TestApp1] \t connect = " << res; - *request << testString; - *request << testInt; - qDebug() << "[QTH] [TestApp1] \t request: " << testString << ", " << testInt; - } - - qDebug() << "[QTH] [TestApp1] \t before request->send()"; - bool res = request->send(); - qDebug() << "[QTH] [TestApp1] \t after request->send()"; - qDebug() << "[QTH] [TestApp1] asyncsend: STOP"; -} - -int main(int argc, char* argv[]) - { - qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); - qDebug() << "[QTH] [TestApp1] main START"; - QApplication a(argc, argv); - - TestApp1* tester = new TestApp1(); - - int rv = a.exec(); - qDebug() << "[QTH] [TestApp1] App1 exits"; - delete tester; - qDebug() << "[QTH] [TestApp1] main END"; - return rv; - } - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp/testapp.h --- a/qthighway/tests/testapps/testapp/testapp.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#ifndef T_TEST2_H -#define T_TEST2_H - -#include -#include -#include -#include -#include - - - -class TestApp1 : public QWidget -{ - -Q_OBJECT - -public: - - TestApp1(QWidget *parent = 0, Qt::WFlags f = 0); - - -protected slots: - - void requestCompleted(const QVariant &data); - void requestCompletedWithError(int err); - -private slots: - void asyncsend(); - -private: - int i; - XQServiceRequest* request; - QLabel *label; -}; - -#endif // T_TEST2_H diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp/testapp.pro --- a/qthighway/tests/testapps/testapp/testapp.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = app -SOURCES = testapp.cpp -HEADERS = testapp.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h -LIBS += -lxqservice -lflogger \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp2/testapp2.cpp --- a/qthighway/tests/testapps/testapp2/testapp2.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "testapp2.h" - -TestApp2::TestApp2(QWidget *parent, Qt::WFlags f) : - QWidget(parent, f) - { - QPalette p = qApp->palette(); - QColor color(80, 20, 20); - QColor bg(256, 20, 20); - p.setColor(QPalette::Highlight, color.lighter(200)); - p.setColor(QPalette::Text, Qt::white); - p.setColor(QPalette::Base, bg); - p.setColor(QPalette::WindowText, Qt::white); - p.setColor(QPalette::Window, bg); - p.setColor(QPalette::ButtonText, Qt::white); - p.setColor(QPalette::Button, color.lighter(150)); - p.setColor(QPalette::Link, QColor(240, 40, 40)); - - qApp->setPalette(p); - - QPushButton *quitButton = new QPushButton(tr("quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - - QPushButton *sendButton = new QPushButton(tr("asynsend 10 times")); - - connect(sendButton, SIGNAL(clicked()), this, SLOT(asyncsend())); - - label = new QLabel("Test App2"); - - QVBoxLayout *vl = new QVBoxLayout; - vl->setMargin(0); - vl->setSpacing(0); - - vl->addWidget(label); - vl->addWidget(sendButton); - vl->addWidget(quitButton); - - setLayout(vl); - //showMaximized(); - showFullScreen(); - - i = 0; - request = NULL; - asyncsend(); - } - -void TestApp2::requestCompleted(const QVariant& data) - { - i++; - qDebug() << "[QTH] [TestApp2] result: " << data.toString() << "Times" << i; - - if (i <= 10) - { - qDebug() << "[QTH] [TestApp2] trigger again()"; - QString string; - string.append("Test app2 -->"); - string.append(48 + i); - string.append("times"); - label->setText(string); - asyncsend(); - } - else - { - label->setText("Test app2 DONE!"); - /*if(request) - { - delete request; - request=NULL; - }*/ - qDebug() << "[QTH] [TestApp2] DONE 10-time sending !!!!!!!!!!!"; - } - } - -void TestApp2::asyncsend() - { - qDebug() << "[QTH] [TestApp2] asyncsend"; - - QString service( - "com.nokia.services.testservice.TestService"); - QString method("asyncNoParams()"); - - if (!request) - { - request = new XQServiceRequest(service, method, false); - connect(request, SIGNAL(requestCompleted(QVariant)), this, - SLOT(requestCompleted(QVariant))); - } - - bool res = request->send(); - } - -int main(int argc, char* argv[]) - { - qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); - qDebug() << "[QTH] [TestApp2] App2 started"; - QApplication a(argc, argv); - - TestApp2* tester = new TestApp2(); - - int rv = a.exec(); - qDebug() << "[QTH] [TestApp2] App2 exits"; - delete tester; - return rv; - } - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp2/testapp2.h --- a/qthighway/tests/testapps/testapp2/testapp2.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#ifndef T_TEST2_H -#define T_TEST2_H - -#include -#include -#include -#include -#include - -class TestApp2 : public QWidget -{ - -Q_OBJECT -public : - TestApp2(QWidget *parent = 0, Qt::WFlags f=0 ); - -signals: - void again(); - -protected slots: - - void requestCompleted(const QVariant &data); - -private slots: - - void asyncsend(); - -private: - int i; - XQServiceRequest* request; - QLabel *label; -}; - -#endif // T_TEST2_H diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp2/testapp2.pro --- a/qthighway/tests/testapps/testapp2/testapp2.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = app -SOURCES = testapp2.cpp -HEADERS = testapp2.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h -LIBS += -lxqservice -lflogger \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp3/testapp3.cpp --- a/qthighway/tests/testapps/testapp3/testapp3.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "testapp3.h" - -TestApp3::TestApp3( QWidget *parent, Qt::WFlags f ) : QWidget( parent,f ) - { - qDebug() << "[QTH] [TestApp3] MyServiceTester: START"; - QPalette p = qApp->palette(); - QColor color(80,20,20); - QColor bg(256,20,20); - p.setColor(QPalette::Highlight, color.lighter(200)); - p.setColor(QPalette::Text, Qt::white); - p.setColor(QPalette::Base, bg); - p.setColor(QPalette::WindowText, Qt::white); - p.setColor(QPalette::Window, bg); - p.setColor(QPalette::ButtonText, Qt::white); - p.setColor(QPalette::Button, color.lighter(150)); - p.setColor(QPalette::Link, QColor(240,40,40)); - - qApp->setPalette(p); - - QPushButton *quitButton = new QPushButton(tr("quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - - QPushButton *sendButton = new QPushButton(tr("asynsend 10 times")); - connect(sendButton, SIGNAL(clicked()), this, SLOT(asyncsend())); - - label = new QLabel("Test App3"); - - QVBoxLayout *vl = new QVBoxLayout; - vl->setMargin(0); - vl->setSpacing(0); - - vl->addWidget(label); - vl->addWidget(sendButton); - vl->addWidget(quitButton); - - setLayout(vl); - //showMaximized(); - showFullScreen(); - - i = 0; - request = NULL; - asyncsend(); - qDebug() << "[QTH] [TestApp3] MyServiceTester: END"; - } - - -void TestApp3::requestCompleted(const QVariant& data) -{ - i++; - qDebug() << "[QTH] [TestApp3] requestCompleted START "; - qDebug() << "[QTH] [TestApp3] \t data: " << data.toString() << ", i: " << i; - - if ( i <= 20 ) - { - qDebug() << "[QTH] [TestApp3] \t i <= 20 trigger again()"; - QString string; - string.append("Test app3 -->"); - string.append(48+i); - string.append("times"); - label->setText(string); - asyncsend(); - } - else - { - /*qDebug() << "[QTH] [MyServiceTester] \t i > 20, setText()"; - label->setText("Test app1 Done!"); - if(request) - { - qDebug() << "[QTH] [MyServiceTester] \t \t request != null, delete request"; - delete request; - request=NULL; - }*/ - qDebug() << "[QTH] [TestApp3] \t request sent 20 times!!!"; - } - - qDebug() << "[QTH] [TestApp3] requestCompleted STOP"; -} - - - -void TestApp3::asyncsend() -{ - qDebug() << "[QTH] [TestApp3] asyncsend: START"; - - QString testString("Test Application 3"); - int testInt(112233); - - QString service("com.nokia.services.testservice.TestService"); - QString method("asyncWithParams(QString,int)"); - - if (!request) - { - qDebug() << "[QTH] [TestApp3] \t creating request"; - request = new XQServiceRequest(service, method, false); - qDebug() << "[QTH] [TestApp3] \t connectint signal request->requestCompleted to slot this.requestCompleted"; - bool res = connect(request, SIGNAL(requestCompleted(QVariant)), this, SLOT(requestCompleted(QVariant)) ); - qDebug() << "[QTH] [TestApp3] \t connect = " << res; - *request << testString; - *request << testInt; - qDebug() << "[QTH] [TestApp3] \t request: " << testString << ", " << testInt; - } - - qDebug() << "[QTH] [TestApp3] \t before request->send()"; - bool res = request->send(); - qDebug() << "[QTH] [TestApp3] \t after request->send()"; - qDebug() << "[QTH] [TestApp3] asyncsend: STOP"; -} - -int main(int argc, char* argv[]) - { - qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); - qDebug() << "[QTH] [TestApp3] main START"; - QApplication a(argc, argv); - - TestApp3* tester = new TestApp3(); - qDebug() << "[QTH] [TestApp3] exits"; - int rv = a.exec(); - delete tester; - qDebug() << "[QTH] [TestApp3] main END"; - return rv; - } - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp3/testapp3.h --- a/qthighway/tests/testapps/testapp3/testapp3.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# -*/ - -#ifndef T_TEST2_H -#define T_TEST2_H - -#include -#include -#include -#include -#include - - - -class TestApp3 : public QWidget -{ - -Q_OBJECT - -public: - - TestApp3(QWidget *parent = 0, Qt::WFlags f = 0); - - -protected slots: - - void requestCompleted(const QVariant &data); -private slots: - void asyncsend(); -private: - int i; - XQServiceRequest* request; - QLabel *label; -}; - -#endif // T_TEST2_H diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp3/testapp3.pro --- a/qthighway/tests/testapps/testapp3/testapp3.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = app -SOURCES = testapp3.cpp -HEADERS = testapp3.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h -LIBS += -lxqservice -lflogger \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/app/testapp4.cpp --- a/qthighway/tests/testapps/testapp4/app/testapp4.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "testapp4.h" -#include "testdll.h" - - -TestApp4Widget::TestApp4Widget( QWidget *parent, Qt::WFlags f ) : QWidget( parent,f ) - { - td = new TestDll(); - qDebug() << "[QTH] [TestApp4] TestApp4Widget: START"; - QPalette p = qApp->palette(); - QColor color(80,20,20); - QColor bg(256,20,20); - p.setColor(QPalette::Highlight, color.lighter(200)); - p.setColor(QPalette::Text, Qt::white); - p.setColor(QPalette::Base, bg); - p.setColor(QPalette::WindowText, Qt::white); - p.setColor(QPalette::Window, bg); - p.setColor(QPalette::ButtonText, Qt::white); - p.setColor(QPalette::Button, color.lighter(150)); - p.setColor(QPalette::Link, QColor(240,40,40)); - - qApp->setPalette(p); - - QPushButton *quitButton = new QPushButton(tr("quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - - QPushButton *sendButton = new QPushButton(tr("asynsend 10 times")); - connect(sendButton, SIGNAL(clicked()), td, SLOT(asyncsend())); - - label = new QLabel("Test App4"); - - QVBoxLayout *vl = new QVBoxLayout; - vl->setMargin(0); - vl->setSpacing(0); - - vl->addWidget(label); - vl->addWidget(sendButton); - vl->addWidget(quitButton); - - setLayout(vl); - - showFullScreen(); - - i = 0; - request = NULL; - td->asyncsend(); - qDebug() << "[QTH] [TestApp4] TestApp4Widget: END"; - } - -int main(int argc, char* argv[]) - { - qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); - qDebug() << "[QTH] [TestApp4] main START"; - QApplication a(argc, argv); - TestDll* td = new TestDll(&a); - td->asyncsend(); - - //TestApp4Widget* t4 = new TestApp4Widget(); - - int rv = a.exec(); - //delete td; - qDebug() << "[QTH] [TestApp4] exits"; - qDebug() << "[QTH] [TestApp4] main END"; - return rv; - } - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/app/testapp4.h --- a/qthighway/tests/testapps/testapp4/app/testapp4.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef T_TEST2_H -#define T_TEST2_H - -#include -#include -#include -#include -#include -#include "testdll.h" - -class TestApp4Widget : public QWidget -{ - -Q_OBJECT - -public: - - TestApp4Widget(QWidget *parent = 0, Qt::WFlags f = 0); - -private: - int i; - XQServiceRequest* request; - QLabel *label; - TestDll* td; -}; - -#endif // T_TEST2_H diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/app/testapp4.pro --- a/qthighway/tests/testapps/testapp4/app/testapp4.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = app -SOURCES = testapp4.cpp -HEADERS = testapp4.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h - -INCLUDEPATH = ../dll - -LIBS += -lflogger -ltestdll - -symbian { - TARGET.EPOCALLOWDLLDATA = 1 - TARGET.EPOCHEAPSIZE = 0x020000 0x2000000 - TARGET.CAPABILITY = ALL -TCB -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/bwins/testdllu.def --- a/qthighway/tests/testapps/testapp4/bwins/testdllu.def Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -EXPORTS - ?staticMetaObject@TestDll@@2UQMetaObject@@B @ 1 NONAME ; struct QMetaObject const TestDll::staticMetaObject - ?metaObject@TestDll@@UBEPBUQMetaObject@@XZ @ 2 NONAME ; struct QMetaObject const * TestDll::metaObject(void) const - ??1TestDll@@UAE@XZ @ 3 NONAME ; TestDll::~TestDll(void) - ?requestCompleted@TestDll@@IAEXABVQVariant@@@Z @ 4 NONAME ; void TestDll::requestCompleted(class QVariant const &) - ??0TestDll@@QAE@PAVQObject@@@Z @ 5 NONAME ; TestDll::TestDll(class QObject *) - ?asyncsend@TestDll@@QAEXXZ @ 6 NONAME ; void TestDll::asyncsend(void) - ?trUtf8@TestDll@@SA?AVQString@@PBD0H@Z @ 7 NONAME ; class QString TestDll::trUtf8(char const *, char const *, int) - ?tr@TestDll@@SA?AVQString@@PBD0@Z @ 8 NONAME ; class QString TestDll::tr(char const *, char const *) - ??_ETestDll@@UAE@I@Z @ 9 NONAME ; TestDll::~TestDll(unsigned int) - ?getStaticMetaObject@TestDll@@SAABUQMetaObject@@XZ @ 10 NONAME ; struct QMetaObject const & TestDll::getStaticMetaObject(void) - ?qt_metacall@TestDll@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 11 NONAME ; int TestDll::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacast@TestDll@@UAEPAXPBD@Z @ 12 NONAME ; void * TestDll::qt_metacast(char const *) - ?tr@TestDll@@SA?AVQString@@PBD0H@Z @ 13 NONAME ; class QString TestDll::tr(char const *, char const *, int) - ?trUtf8@TestDll@@SA?AVQString@@PBD0@Z @ 14 NONAME ; class QString TestDll::trUtf8(char const *, char const *) - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/dll/testdll.cpp --- a/qthighway/tests/testapps/testapp4/dll/testdll.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "TestDll.h" - -TestDll::TestDll(QObject *parent) : QObject(parent) - { - qDebug() << "[QTH] [TestDll] MyServiceTester: START"; - i = 0; - request = NULL; - //asyncsend(); - qDebug() << "[QTH] [TestDll] MyServiceTester: END"; - } - - -void TestDll::requestCompleted(const QVariant& data) -{ - i++; - qDebug() << "[QTH] [TestDll] requestCompleted START "; - qDebug() << "[QTH] [TestDll] \t data: " << data.toString() << ", i: " << i; - - if ( i <= 20 ) - { - qDebug() << "[QTH] [TestDll] \t i <= 20 trigger again()"; - QString string; - qDebug() << "Test app3 --> " << 48 << i << " times"; - asyncsend(); - } - else - { - /*qDebug() << "[QTH] [MyServiceTester] \t i > 20, setText()"; - label->setText("Test app1 Done!"); - if(request) - { - qDebug() << "[QTH] [MyServiceTester] \t \t request != null, delete request"; - delete request; - request=NULL; - }*/ - qDebug() << "[QTH] [TestDll] \t request sent 20 times!!!"; - } - - qDebug() << "[QTH] [TestDll] requestCompleted STOP"; -} - - - -void TestDll::asyncsend() -{ - qDebug() << "[QTH] [TestDll] asyncsend: START"; - - QString testString("Test Application 3"); - int testInt(112233); - - QString service("com.nokia.services.testservice.TestService"); - QString method("asyncWithParams(QString,int)"); - - if (!request) - { - qDebug() << "[QTH] [TestDll] \t creating request"; - request = new XQServiceRequest(service, method, false); - qDebug() << "[QTH] [TestDll] \t connectint signal request->requestCompleted to slot this.requestCompleted"; - bool res = connect(request, SIGNAL(requestCompleted(QVariant)), this, SLOT(requestCompleted(QVariant)) ); - qDebug() << "[QTH] [TestDll] \t connect = " << res; - *request << testString; - *request << testInt; - qDebug() << "[QTH] [TestDll] \t request: " << testString << ", " << testInt; - } - - qDebug() << "[QTH] [TestDll] \t before request->send()"; - bool res = request->send(); - qDebug() << "[QTH] [TestDll] \t after request->send()"; - qDebug() << "[QTH] [TestDll] asyncsend: STOP"; -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/dll/testdll.h --- a/qthighway/tests/testapps/testapp4/dll/testdll.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef T_TESTDLL_H -#define T_TESTDLL_H - -#include -#include -#include -#include -#include - -class Q_DECL_EXPORT TestDll : public QObject -{ - -Q_OBJECT - -private: - int i; - -public: - TestDll(QObject *parent = 0); - -protected slots: - void requestCompleted(const QVariant &data); - -public slots: - void asyncsend(); - -public: - XQServiceRequest* request; - -}; - -#endif // T_TESTDLL diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/dll/testdll.pro --- a/qthighway/tests/testapps/testapp4/dll/testdll.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = lib -SOURCES = testdll.cpp -HEADERS = testdll.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h -LIBS += -lxqservice -lflogger - -symbian { - TARGET.EPOCALLOWDLLDATA = 1 - TARGET.EPOCHEAPSIZE = 0x020000 0x2000000 - TARGET.CAPABILITY = ALL -TCB -} \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapp4/main.pro --- a/qthighway/tests/testapps/testapp4/main.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs - -CONFIG += ordered - -SUBDIRS = dll \ - app \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testapps.pro --- a/qthighway/tests/testapps/testapps.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs - -CONFIG += ordered - -SUBDIRS = testservice \ - testapp \ - testapp2 \ - testapp3 \ - testapp4 \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/main.cpp --- a/qthighway/tests/testapps/testservice/main.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include "testservice.h" -#include - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "main.h" - -TestServiceView::TestServiceView( QWidget *parent, Qt::WFlags f ) : QWidget( parent,f ) -{ - qDebug() << "[QTH] [TestService] TestServiceView::TestServiceView START"; - QPalette p = qApp->palette(); - //p.setColor(QPalette::Highlight, color.lighter(200)); - //p.setColor(QPalette::Text, Qt::white); - //p.setColor(QPalette::Base, bg); - //p.setColor(QPalette::WindowText, Qt::red); - //p.setColor(QPalette::Window, Qt::yellow); - //p.setColor(QPalette::ButtonText, Qt::blue); - //p.setColor(QPalette::Button, Qt::green); - //p.setColor(QPalette::Link, QColor(240,40,40)); - - qApp->setPalette(p); - - QPushButton *quitButton = new QPushButton(tr("quit")); - connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); - - label = new QLabel("TEST SERVICE"); - - QVBoxLayout *vl = new QVBoxLayout; - vl->setMargin(0); - vl->setSpacing(0); - - vl->addWidget(label); - //vl->addWidget(sendButton); - vl->addWidget(quitButton); - - setLayout(vl); - //showMaximized(); - showFullScreen(); - service = new TestService(); - qDebug() << "[QTH] [TestService] TestServiceView::TestServiceView END"; -} - -TestServiceView::~TestServiceView() -{ - delete service; -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); - TestServiceView view; - return a.exec(); -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/main.h --- a/qthighway/tests/testapps/testservice/main.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef MAIN_H_ -#define MAIN_H_ - -#include -#include -#include -#include -#include -#include "testservice.h" - - -class TestServiceView : public QWidget -{ - -Q_OBJECT - -public: - - TestServiceView(QWidget *parent = 0, Qt::WFlags f = 0); - ~TestServiceView(); - -private: - QLabel *label; - TestService* service; -}; - - -#endif /* MAIN_H_ */ diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/mytimer.cpp --- a/qthighway/tests/testapps/testservice/mytimer.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include "MyTimer.h" - -MyTimer::MyTimer() - { - qDebug() << "[QTH] [MyTimer] MyTimer() START"; - timer = new QTimer(); - bool res = connect(timer, SIGNAL(timeout()), this, SLOT(emitMyTimeout())); - qDebug() << "[QTH] [MyTimer] \t connect = " << res; - qDebug() << "[QTH] [MyTimer] MyTimer() END"; - } - -void MyTimer::emitMyTimeout() - { - qDebug() << "[QTH] [MyTimer] emitMyTimeout, timerKey = " << timerKey; - emit timeout(timerKey); - } - -void MyTimer::start(int msec) - { - qDebug() << "[QTH] [MyTimer] start(" << msec << ")"; - timer->start(msec); - } - -void MyTimer::setTimerKey(int ti) - { - timerKey = ti; - } - -void MyTimer::setRequestId(int ri) - { - requestId = ri; - } - -int MyTimer::getRequestId() - { - return requestId; - } - -MyTimer::~MyTimer() - { - qDebug() << "[QTH] [MyTimer] ~MyTimer() START"; - delete timer; - qDebug() << "[QTH] [MyTimer] ~MyTimer() END"; - } diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/mytimer.h --- a/qthighway/tests/testapps/testservice/mytimer.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef MYTIMER_H_ -#define MYTIMER_H_ - -#include - -class MyTimer : public QObject - { - -Q_OBJECT - -private: - int timerKey; - int requestId; - QTimer* timer; - -public: - MyTimer(); - virtual ~MyTimer(); - void setTimerKey(int timerKey); - void setRequestId(int requestId); - int getRequestId(); - void start(int msec); - -public slots: - void emitMyTimeout(); - -signals: - void timeout(int index); - }; - -#endif /* MYTIMER_H_ */ diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/service_conf.xml --- a/qthighway/tests/testapps/testservice/service_conf.xml Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - QtHighway Bug Server - - QtHighway Bug Server - - \ No newline at end of file diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/testservice.cpp --- a/qthighway/tests/testapps/testservice/testservice.cpp Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#include -#include -#include -#include -#include "testservice.h" -#include "mytimer.h" - -TestService::TestService(QObject* parent ) - : XQServiceProvider("com.nokia.services.testservice.TestService", parent) -{ - publishAll(); - timer1 = new QTimer(this); - timer2 = new QTimer(this); - mRequestIndex1 = -1; - mRequestIndex2 = -1; - timerKey = 0; -} - -TestService::~TestService() -{ - delete timer1; - delete timer2; -} - -int TestService::syncNoParams() -{ - qDebug() << "[QTH] [TestService] syncNoParams"; - - for( int i = 0; i<20000; i++ ) - { - int ii = i; - } - - qDebug() << "[QTH] [TestService] syncNoParams end"; - return 1; -} - -int TestService::syncWithParams(QString param1, int param2) -{ - qDebug() << "[QTH] [TestService] syncWithParam "; - qDebug() << "[QTH] [TestService] param1: " << param1; - qDebug() << "[QTH] [TestService] param2: " << param2; - - for( int i = 0; i<20000; i++ ) - { - int ii = i; - } - - qDebug() << "[QTH] [TestService] syncWithParam end"; - return 1; -} - -int TestService::asyncNoParams() -{ - qDebug() << "[QTH] [TestService] asyncNoParams START"; - QString returnString("my_request"); - - mRequestIndex1 = setCurrentRequestAsync(); - - bool res = connect(timer1, SIGNAL(timeout()), this, SLOT(DoneAsyncNoParams())); - qDebug() << "[QTH] [TestService] \t connect timer1->timeout() to this->DoneAsyncNoParams() = " << res ; - timer1->start(10000); - qDebug() << "[QTH] [TestService] asyncNoParams END"; - return 1; -} - -void TestService::DoneAsyncNoParams() - { - qDebug() << "[QTH] [TestService] DoneasyncNoParams START"; - - if (mRequestIndex1 == -1) { - qDebug() << "[QTH] [TestService] \t mRequestIndex1 == -1 !!!!"; - return; - } - - qDebug() << "[QTH] [TestService] \t disconnect"; - disconnect(timer1, SIGNAL(timeout()), this, SLOT(DoneAsyncNoParams())); - qDebug() << "[QTH] [TestService] \t completeRequest(1, QVariant(1)) start"; - completeRequest(mRequestIndex1, QVariant(1)); - qDebug() << "[QTH] [TestService] \t completeRequest(" << mRequestIndex1 << ", QVariant(1)) end"; - qDebug() << "[QTH] [TestService] DoneasyncNoParams END"; - } - - -int TestService::asyncWithParams(QString param1, int param2) -{ - timerKey++; - qDebug() << "[QTH] [TestService] asyncWithParams START"; - qDebug() << "[QTH] [TestService] \t param1: " << param1; - qDebug() << "[QTH] [TestService] \t param2: " << param2; - - qDebug() << "[QTH] [TestService] \t setCurrentRequestAsync"; - mRequestIndex2 = setCurrentRequestAsync(); - qDebug() << "[QTH] [TestService] \t currentRequestIndex = " << mRequestIndex2; - - - MyTimer* mt = new MyTimer(); - - mt->setTimerKey(timerKey); - mt->setRequestId(mRequestIndex2); - qDebug() << "[QTH] [TestService] \t insert a new timer having key = " << timerKey; - timers.insert(timerKey, mt); - qDebug() << "[QTH] [TestService] \t size of timers map = " << timers.size(); - - qDebug() << "[QTH] [TestService] \t connect(timer2, SIGNAL(timeout()), this, SLOT(DoneAsyncWithParams()))"; - bool res = connect(mt, SIGNAL(timeout(int)), this, SLOT(DoneAsyncWithParams(int))); - qDebug() << "[QTH] [TestService] \t connect result = " << res; - - mt->start(10000); - - QString returnString; - returnString.append(param1); - returnString.append(" "); - returnString.append(param2); - qDebug() << "[QTH] [TestService] \t returnString = " << returnString; - qDebug() << "[QTH] [TestService] asyncWithParams END"; - return 1; -} - - -void TestService::DoneAsyncWithParams(int timerId) -{ - qDebug() << "[QTH] [TestService] DoneAsyncWithParams START"; - qDebug() << "[QTH] [TestService] \t timerId = " << timerId; - - if (!timers.contains(timerId)) { - qDebug() << "[QTH] [TestService] \t timers map does not contain timer having key = " << timerId << " !!!! "; - qDebug() << "[QTH] [TestService] \t return !!!"; - qDebug() << "[QTH] [TestService] DoneAsyncWithParams END (1)"; - return; - } else { - MyTimer* mt = timers[timerId]; - disconnect(mt, SIGNAL(timeout(int)), this, SLOT(DoneAsyncWithParams(int))); - int requestId = mt->getRequestId(); - qDebug() << "[QTH] [TestService] \t requestId = " << requestId; - timers.remove(timerId); - delete mt; - mt = NULL; - - if (requestId == -1) { - qDebug() << "[QTH] [TestService] \t requestId == -1 !!!!"; - return; - } - qDebug() << "[QTH] [TestService] \t completeRequest -> requestId = " << requestId << ", retValue = QVariant(\"helloworld!\")"; - completeRequest(requestId, QVariant("helloworld!")); - qDebug() << "[QTH] [TestService] DoneAsyncWithParams END (2)"; - } -} - -// not used -void TestService::longRunningRequest() -{ - qDebug() << "[QTH] [TestService] longRunningRequest START"; - qDebug() << "[QTH] [TestService] \t QTimer::singleShot(30000, this, SLOT(completeLongRunningRequest()))"; - QTimer::singleShot(30000, this, SLOT(completeLongRunningRequest())); - qDebug() << "[QTH] [TestService] longRunningRequest END"; -} - -void TestService::completeLongRunningRequest() -{ - qDebug() << "[QTH] [TestService] completeLongRunningRequest END"; - completeRequest(mRequestIndex3 = setCurrentRequestAsync(), QVariant(true)); - qDebug() << "[QTH] [TestService] completeLongRunningRequest END"; -} diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/testservice.h --- a/qthighway/tests/testapps/testservice/testservice.h Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ - -#ifndef ACTIVITYSERVERSERVICE_H -#define ACTIVITYSERVERSERVICE_H - -#include -#include -#include -#include -#include -#include "mytimer.h" - -class TestService : public XQServiceProvider -{ - Q_OBJECT - -public: - TestService(QObject *parent = 0 ); - ~TestService(); - - void longRunningRequest(); - -public slots: - - // request handling methods - int syncNoParams(); - int syncWithParams(QString param1, int param2); - int asyncNoParams(); - int asyncWithParams(QString param1, int param2); - -private slots: - - void completeLongRunningRequest(); - void DoneAsyncNoParams(); - void DoneAsyncWithParams(int timerId); - -private: - QTimer* timer1; - QTimer* timer2; - QHash timers; - - int mRequestIndex1; - int mRequestIndex2; - int mRequestIndex3; - int timerKey; -}; - -#endif // ACTIVITYSERVERSERVICE_H diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/testapps/testservice/testservice.pro --- a/qthighway/tests/testapps/testservice/testservice.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = app -TARGET = testservice -symbian:TARGET.UID3 = 0xE1D10723 - -CONFIG += service - -SOURCES = main.cpp \ - mytimer.cpp \ - testservice.cpp - -HEADERS = main.h \ - testservice.h \ - mytimer.h \ - /ext/mw/qtextensions/qthighway/inc/xqservicelog.h - - -LIBS += -lxqservice \ - -lxqserviceutil \ - -lflogger -LIBS += -lcone \ - -lws32 -SERVICE.FILE = service_conf.xml - diff -r 19b186e43276 -r 1b485afba084 qthighway/tests/tests.pro --- a/qthighway/tests/tests.pro Tue Jul 13 20:51:27 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, version 2.1 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, -# see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -# -# Description: -# - -TEMPLATE = subdirs - -SUBDIRS= \ - auto