From e3a59c40e2cfab93ccfdf447afad79a269bc3afc Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Sat, 25 Apr 2009 13:50:35 +0000 Subject: [PATCH] Kill the public Sodep class prefix. Now use a Jolie namespace. svn path=/branches/work/~ervin/qtjolie/; revision=959030 --- private/qtjolie-branch/qtjolie/CMakeLists.txt | 14 +-- .../qtjolie/{sodepclient.cpp => client.cpp} | 40 ++++---- .../qtjolie/{sodepclient.h => client.h} | 31 ++++--- .../qtjolie/{sodepclient_p.h => client_p.h} | 34 ++++--- ...sodepclientthread.cpp => clientthread.cpp} | 28 +++--- ...sodepclientthread_p.h => clientthread_p.h} | 27 +++--- .../qtjolie/{sodepfault.cpp => fault.cpp} | 35 ++++--- .../qtjolie/{sodepfault.h => fault.h} | 29 +++--- .../qtjolie/{sodepmessage.cpp => message.cpp} | 49 +++++----- .../qtjolie/{sodepmessage.h => message.h} | 37 ++++---- .../{sodeppendingcall.cpp => pendingcall.cpp} | 28 +++--- .../{sodeppendingcall.h => pendingcall.h} | 33 ++++--- .../{sodeppendingcall_p.h => pendingcall_p.h} | 33 ++++--- .../qtjolie-branch/qtjolie/sodephelpers_p.h | 46 +++++---- .../qtjolie/{sodepvalue.cpp => value.cpp} | 58 +++++++----- .../qtjolie/{sodepvalue.h => value.h} | 33 ++++--- private/qtjolie-branch/tests/CMakeLists.txt | 10 +- .../{sodepfaulttest.cpp => testfault.cpp} | 30 +++--- .../{sodeptesthelpers.h => testhelpers.h} | 22 ++--- .../{sodepmessagetest.cpp => testmessage.cpp} | 32 ++++--- ...etaservicetest.cpp => testmetaservice.cpp} | 93 ++++++++++--------- .../{sodepprintertest.cpp => testprinter.cpp} | 12 ++- .../{sodepvaluetest.cpp => testvalue.cpp} | 46 ++++----- 23 files changed, 442 insertions(+), 358 deletions(-) rename private/qtjolie-branch/qtjolie/{sodepclient.cpp => client.cpp} (57%) rename private/qtjolie-branch/qtjolie/{sodepclient.h => client.h} (71%) rename private/qtjolie-branch/qtjolie/{sodepclient_p.h => client_p.h} (66%) rename private/qtjolie-branch/qtjolie/{sodepclientthread.cpp => clientthread.cpp} (76%) rename private/qtjolie-branch/qtjolie/{sodepclientthread_p.h => clientthread_p.h} (73%) rename private/qtjolie-branch/qtjolie/{sodepfault.cpp => fault.cpp} (71%) rename private/qtjolie-branch/qtjolie/{sodepfault.h => fault.h} (70%) rename private/qtjolie-branch/qtjolie/{sodepmessage.cpp => message.cpp} (65%) rename private/qtjolie-branch/qtjolie/{sodepmessage.h => message.h} (67%) rename private/qtjolie-branch/qtjolie/{sodeppendingcall.cpp => pendingcall.cpp} (64%) rename private/qtjolie-branch/qtjolie/{sodeppendingcall.h => pendingcall.h} (65%) rename private/qtjolie-branch/qtjolie/{sodeppendingcall_p.h => pendingcall_p.h} (67%) rename private/qtjolie-branch/qtjolie/{sodepvalue.cpp => value.cpp} (65%) rename private/qtjolie-branch/qtjolie/{sodepvalue.h => value.h} (70%) rename private/qtjolie-branch/tests/{sodepfaulttest.cpp => testfault.cpp} (81%) rename private/qtjolie-branch/tests/{sodeptesthelpers.h => testhelpers.h} (79%) rename private/qtjolie-branch/tests/{sodepmessagetest.cpp => testmessage.cpp} (85%) rename private/qtjolie-branch/tests/{sodepmetaservicetest.cpp => testmetaservice.cpp} (62%) rename private/qtjolie-branch/tests/{sodepprintertest.cpp => testprinter.cpp} (92%) rename private/qtjolie-branch/tests/{sodepvaluetest.cpp => testvalue.cpp} (83%) diff --git a/private/qtjolie-branch/qtjolie/CMakeLists.txt b/private/qtjolie-branch/qtjolie/CMakeLists.txt index 18eefeabb..16d0f877e 100644 --- a/private/qtjolie-branch/qtjolie/CMakeLists.txt +++ b/private/qtjolie-branch/qtjolie/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDE_DIR}) -set(qtjolie_LIB_SRCS sodepclient.cpp sodepclientthread.cpp sodepvalue.cpp sodepfault.cpp sodepmessage.cpp sodeppendingcall.cpp) +set(qtjolie_LIB_SRCS client.cpp clientthread.cpp value.cpp fault.cpp message.cpp pendingcall.cpp) kde4_add_library(QtJolie SHARED ${qtjolie_LIB_SRCS}) @@ -16,9 +16,9 @@ install(TARGETS QtJolie set_target_properties(QtJolie PROPERTIES VERSION 1.0.0 SOVERSION 1) install(FILES - sodepclient.h - sodepvalue.h - sodepfault.h - sodepmessage.h - sodeppendingcall.h - DESTINATION ${INCLUDE_INSTALL_DIR}) + client.h + value.h + fault.h + message.h + pendingcall.h + DESTINATION ${INCLUDE_INSTALL_DIR}/qtjolie) diff --git a/private/qtjolie-branch/qtjolie/sodepclient.cpp b/private/qtjolie-branch/qtjolie/client.cpp similarity index 57% rename from private/qtjolie-branch/qtjolie/sodepclient.cpp rename to private/qtjolie-branch/qtjolie/client.cpp index e2eb89c21..c2b7b41ce 100644 --- a/private/qtjolie-branch/qtjolie/sodepclient.cpp +++ b/private/qtjolie-branch/qtjolie/client.cpp @@ -18,59 +18,61 @@ * Boston, MA 02110-1301, USA. */ -#include "sodepclient.h" -#include "sodepclient_p.h" +#include "client.h" +#include "client_p.h" -#include "sodepclientthread_p.h" -#include "sodepmessage.h" -#include "sodeppendingcall.h" +#include "clientthread_p.h" +#include "message.h" +#include "pendingcall.h" +using namespace Jolie; -SodepClient::SodepClient(const QString &hostName, quint16 port) - : d(new SodepClientPrivate(this)) +Client::Client(const QString &hostName, quint16 port) + : d(new ClientPrivate(this)) { - d->readerThread = new SodepClientThread(hostName, port, d); + d->readerThread = new ClientThread(hostName, port, d); d->readerThread->start(); } -SodepClient::~SodepClient() +Client::~Client() { delete d->readerThread; delete d; } -SodepClient::Error SodepClient::error() const +Client::Error Client::error() const { return d->error; } -QString SodepClient::errorString() const +QString Client::errorString() const { return d->errorString; } -SodepPendingCall SodepClient::asyncCall(const SodepMessage &message) +PendingCall Client::asyncCall(const Message &message) { Q_ASSERT(!d->pendingCalls.contains(message.id())); - d->pendingCalls[message.id()] = new SodepPendingCallPrivate(message); + d->pendingCalls[message.id()] = new PendingCallPrivate(message); d->readerThread->sendMessage(message); - return SodepPendingCall(d->pendingCalls[message.id()]); + return PendingCall(d->pendingCalls[message.id()]); } -SodepMessage SodepClient::call(const SodepMessage &message) +Message Client::call(const Message &message) { - SodepPendingCall pending = asyncCall(message); + PendingCall pending = asyncCall(message); pending.waitForFinished(); return pending.reply(); } -void SodepClient::callNoReply(const SodepMessage &message) +void Client::callNoReply(const Message &message) { d->readerThread->sendMessage(message); } -void SodepClientPrivate::messageReceived(const SodepMessage &message) +void ClientPrivate::messageReceived(const Message &message) { - QExplicitlySharedDataPointer pending = pendingCalls.take(message.id()); + QExplicitlySharedDataPointer pending = pendingCalls.take(message.id()); pending->setReply(message); } + diff --git a/private/qtjolie-branch/qtjolie/sodepclient.h b/private/qtjolie-branch/qtjolie/client.h similarity index 71% rename from private/qtjolie-branch/qtjolie/sodepclient.h rename to private/qtjolie-branch/qtjolie/client.h index bd7ebe737..9e48a21f7 100644 --- a/private/qtjolie-branch/qtjolie/sodepclient.h +++ b/private/qtjolie-branch/qtjolie/client.h @@ -18,19 +18,21 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPCLIENT_H -#define SODEPCLIENT_H +#ifndef QTJOLIE_CLIENT_H +#define QTJOLIE_CLIENT_H #include class QIODevice; class QObject; -class SodepClientPrivate; -class SodepMessage; -class SodepPendingCall; +namespace Jolie +{ +class ClientPrivate; +class Message; +class PendingCall; -class Q_DECL_EXPORT SodepClient +class Q_DECL_EXPORT Client { public: enum Error @@ -40,19 +42,22 @@ public: UnkownError }; - explicit SodepClient(const QString &hostName, quint16 port); - ~SodepClient(); + explicit Client(const QString &hostName, quint16 port); + ~Client(); Error error() const; QString errorString() const; - SodepPendingCall asyncCall(const SodepMessage &message); - SodepMessage call(const SodepMessage &message); - void callNoReply(const SodepMessage &message); + PendingCall asyncCall(const Message &message); + Message call(const Message &message); + void callNoReply(const Message &message); private: - friend class SodepClientPrivate; - SodepClientPrivate * const d; + friend class ClientPrivate; + ClientPrivate * const d; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodepclient_p.h b/private/qtjolie-branch/qtjolie/client_p.h similarity index 66% rename from private/qtjolie-branch/qtjolie/sodepclient_p.h rename to private/qtjolie-branch/qtjolie/client_p.h index 93a4841a6..dc9c8f161 100644 --- a/private/qtjolie-branch/qtjolie/sodepclient_p.h +++ b/private/qtjolie-branch/qtjolie/client_p.h @@ -18,36 +18,42 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPCLIENT_P_H -#define SODEPCLIENT_P_H +#ifndef QTJOLIE_CLIENT_P_H +#define QTJOLIE_CLIENT_P_H -#include "sodepclient.h" -#include "sodeppendingcall_p.h" +#include "client.h" +#include "pendingcall_p.h" #include #include -class SodepClientThread; +namespace Jolie +{ -class SodepClientPrivate : public QObject +class ClientThread; + +class ClientPrivate : public QObject { Q_OBJECT public: - SodepClientPrivate(SodepClient *client) + ClientPrivate(Client *client) : q(client), - error(SodepClient::NoError) {} + error(Client::NoError) {} public slots: - void messageReceived(const SodepMessage &message); + void messageReceived(const Jolie::Message &message); private: - friend class SodepClient; - SodepClient * const q; - SodepClientThread *readerThread; + friend class Client; + Client * const q; + ClientThread *readerThread; - SodepClient::Error error; + Client::Error error; QString errorString; - QMap > pendingCalls; + QMap > pendingCalls; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodepclientthread.cpp b/private/qtjolie-branch/qtjolie/clientthread.cpp similarity index 76% rename from private/qtjolie-branch/qtjolie/sodepclientthread.cpp rename to private/qtjolie-branch/qtjolie/clientthread.cpp index 4d1068d31..daf54b2ad 100644 --- a/private/qtjolie-branch/qtjolie/sodepclientthread.cpp +++ b/private/qtjolie-branch/qtjolie/clientthread.cpp @@ -18,28 +18,30 @@ * Boston, MA 02110-1301, USA. */ -#include "sodepclientthread_p.h" +#include "clientthread_p.h" #include #include -#include "sodepclient_p.h" -#include "sodepmessage.h" +#include "client_p.h" +#include "message.h" #include "sodephelpers_p.h" -SodepClientThread::SodepClientThread(const QString &hostName, quint16 port, SodepClientPrivate *client) +using namespace Jolie; + +ClientThread::ClientThread(const QString &hostName, quint16 port, ClientPrivate *client) : QThread(), m_hostName(hostName), m_port(port), m_socket(0), m_client(client) { moveToThread(this); } -SodepClientThread::~SodepClientThread() +ClientThread::~ClientThread() { quit(); wait(); } -void SodepClientThread::sendMessage(const SodepMessage &message) +void ClientThread::sendMessage(const Message &message) { QMutexLocker locker(&m_mutex); @@ -47,7 +49,7 @@ void SodepClientThread::sendMessage(const SodepMessage &message) QTimer::singleShot(0, this, SLOT(writeMessageQueue())); } -void SodepClientThread::writeMessageQueue() +void ClientThread::writeMessageQueue() { QMutexLocker locker(&m_mutex); @@ -56,13 +58,13 @@ void SodepClientThread::writeMessageQueue() } } -void SodepClientThread::readMessage() +void ClientThread::readMessage() { if (m_socket->bytesAvailable()==0) { return; } - SodepMessage message = sodepReadMessage(*m_socket); + Message message = sodepReadMessage(*m_socket); emit messageReceived(message); if (m_socket->bytesAvailable()>0) { @@ -70,14 +72,14 @@ void SodepClientThread::readMessage() } } -void SodepClientThread::run() +void ClientThread::run() { m_socket = new QTcpSocket; connect(m_socket, SIGNAL(readyRead()), this, SLOT(readMessage()), Qt::QueuedConnection); - connect(this, SIGNAL(messageReceived(SodepMessage)), - m_client, SLOT(messageReceived(SodepMessage))); + connect(this, SIGNAL(messageReceived(Jolie::Message)), + m_client, SLOT(messageReceived(Jolie::Message))); m_socket->connectToHost(m_hostName, m_port); m_socket->waitForConnected(30000); @@ -89,4 +91,4 @@ void SodepClientThread::run() delete m_socket; } -#include "sodepclientthread_p.moc" +#include "clientthread_p.moc" diff --git a/private/qtjolie-branch/qtjolie/sodepclientthread_p.h b/private/qtjolie-branch/qtjolie/clientthread_p.h similarity index 73% rename from private/qtjolie-branch/qtjolie/sodepclientthread_p.h rename to private/qtjolie-branch/qtjolie/clientthread_p.h index 1c0511174..86d2ae67d 100644 --- a/private/qtjolie-branch/qtjolie/sodepclientthread_p.h +++ b/private/qtjolie-branch/qtjolie/clientthread_p.h @@ -18,8 +18,8 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPCLIENTTHREAD_P_H -#define SODEPCLIENTTHREAD_P_H +#ifndef QTJOLIE_CLIENTTHREAD_P_H +#define QTJOLIE_CLIENTTHREAD_P_H #include #include @@ -27,23 +27,25 @@ class QAbstractSocket; -class SodepMessage; -class SodepClientPrivate; +namespace Jolie +{ +class Message; +class ClientPrivate; -class SodepClientThread : public QThread +class ClientThread : public QThread { Q_OBJECT public: - explicit SodepClientThread(const QString &hostName, quint16 port, SodepClientPrivate *client); - ~SodepClientThread(); + explicit ClientThread(const QString &hostName, quint16 port, ClientPrivate *client); + ~ClientThread(); void run(); - void sendMessage(const SodepMessage &message); + void sendMessage(const Message &message); signals: - void messageReceived(const SodepMessage &message); + void messageReceived(const Jolie::Message &message); private slots: void readMessage(); @@ -54,11 +56,14 @@ private: quint16 m_port; QAbstractSocket *m_socket; - SodepClientPrivate *m_client; + ClientPrivate *m_client; - QQueue m_messageQueue; + QQueue m_messageQueue; QMutex m_mutex; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodepfault.cpp b/private/qtjolie-branch/qtjolie/fault.cpp similarity index 71% rename from private/qtjolie-branch/qtjolie/sodepfault.cpp rename to private/qtjolie-branch/qtjolie/fault.cpp index 967c9b01c..d88a85bc0 100644 --- a/private/qtjolie-branch/qtjolie/sodepfault.cpp +++ b/private/qtjolie-branch/qtjolie/fault.cpp @@ -18,61 +18,68 @@ * Boston, MA 02110-1301, USA. */ -#include "sodepfault.h" +#include "fault.h" #include #include "sodephelpers_p.h" -class SodepFaultPrivate +namespace Jolie +{ + +class FaultPrivate { public: QString name; - SodepValue data; + Value data; }; -SodepFault::SodepFault() - : d(new SodepFaultPrivate) +} // namespace Jolie + +using namespace Jolie; + +Fault::Fault() + : d(new FaultPrivate) { } -SodepFault::SodepFault(const QString &name, const SodepValue &data) - : d(new SodepFaultPrivate) +Fault::Fault(const QString &name, const Value &data) + : d(new FaultPrivate) { d->name = name; d->data = data; } -SodepFault::SodepFault(const SodepFault &other) - : d(new SodepFaultPrivate) +Fault::Fault(const Fault &other) + : d(new FaultPrivate) { *d = *other.d; } -SodepFault::~SodepFault() +Fault::~Fault() { delete d; } -SodepFault &SodepFault::operator=(const SodepFault &other) +Fault &Fault::operator=(const Fault &other) { *d = *other.d; return *this; } -QString SodepFault::name() const +QString Fault::name() const { return d->name; } -SodepValue SodepFault::data() const +Value Fault::data() const { return d->data; } -bool SodepFault::isValid() const +bool Fault::isValid() const { return !d->name.isEmpty(); } diff --git a/private/qtjolie-branch/qtjolie/sodepfault.h b/private/qtjolie-branch/qtjolie/fault.h similarity index 70% rename from private/qtjolie-branch/qtjolie/sodepfault.h rename to private/qtjolie-branch/qtjolie/fault.h index 7eaaf7952..7259c7b89 100644 --- a/private/qtjolie-branch/qtjolie/sodepfault.h +++ b/private/qtjolie-branch/qtjolie/fault.h @@ -18,32 +18,37 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPFAULT_H -#define SODEPFAULT_H +#ifndef QTJOLIE_FAULT_H +#define QTJOLIE_FAULT_H -#include +#include -class SodepFaultPrivate; +namespace Jolie +{ +class FaultPrivate; -class Q_DECL_EXPORT SodepFault +class Q_DECL_EXPORT Fault { public: - SodepFault(); - explicit SodepFault(const QString &name, const SodepValue &data = SodepValue()); + Fault(); + explicit Fault(const QString &name, const Value &data = Value()); - SodepFault(const SodepFault &other); + Fault(const Fault &other); - ~SodepFault(); + ~Fault(); - SodepFault &operator=(const SodepFault &other); + Fault &operator=(const Fault &other); QString name() const; - SodepValue data() const; + Value data() const; bool isValid() const; private: - SodepFaultPrivate * const d; + FaultPrivate * const d; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodepmessage.cpp b/private/qtjolie-branch/qtjolie/message.cpp similarity index 65% rename from private/qtjolie-branch/qtjolie/sodepmessage.cpp rename to private/qtjolie-branch/qtjolie/message.cpp index 20e044fb5..ec782aef8 100644 --- a/private/qtjolie-branch/qtjolie/sodepmessage.cpp +++ b/private/qtjolie-branch/qtjolie/message.cpp @@ -18,31 +18,38 @@ * Boston, MA 02110-1301, USA. */ -#include "sodepmessage.h" +#include "message.h" #include #include "sodephelpers_p.h" -class SodepMessagePrivate +namespace Jolie +{ + +class MessagePrivate { public: - SodepMessagePrivate() : id(0) {} + MessagePrivate() : id(0) {} qint64 id; QString resourcePath; QString operationName; - SodepFault fault; - SodepValue data; + Fault fault; + Value data; }; -SodepMessage::SodepMessage() - : d(new SodepMessagePrivate) +} // namespace Jolie + +using namespace Jolie; + +Message::Message() + : d(new MessagePrivate) { } -SodepMessage::SodepMessage(const QString &resourcePath, const QString &operationName, qint64 id) - : d(new SodepMessagePrivate) +Message::Message(const QString &resourcePath, const QString &operationName, qint64 id) + : d(new MessagePrivate) { static qint64 lastId = 0; @@ -55,60 +62,60 @@ SodepMessage::SodepMessage(const QString &resourcePath, const QString &operation d->operationName = operationName; } -SodepMessage::SodepMessage(const SodepMessage &other) - : d(new SodepMessagePrivate) +Message::Message(const Message &other) + : d(new MessagePrivate) { *d = *other.d; } -SodepMessage::~SodepMessage() +Message::~Message() { delete d; } -SodepMessage &SodepMessage::operator=(const SodepMessage &other) +Message &Message::operator=(const Message &other) { *d = *other.d; return *this; } -qint64 SodepMessage::id() const +qint64 Message::id() const { return d->id; } -QString SodepMessage::resourcePath() const +QString Message::resourcePath() const { return d->resourcePath; } -QString SodepMessage::operationName() const +QString Message::operationName() const { return d->operationName; } -SodepFault SodepMessage::fault() const +Fault Message::fault() const { return d->fault; } -void SodepMessage::setFault(const SodepFault &fault) +void Message::setFault(const Fault &fault) { d->fault = fault; } -SodepValue SodepMessage::data() const +Value Message::data() const { return d->data; } -void SodepMessage::setData(const SodepValue &data) +void Message::setData(const Value &data) { d->data = data; } -bool SodepMessage::isValid() +bool Message::isValid() { return !d->resourcePath.isEmpty() && !d->operationName.isEmpty(); } diff --git a/private/qtjolie-branch/qtjolie/sodepmessage.h b/private/qtjolie-branch/qtjolie/message.h similarity index 67% rename from private/qtjolie-branch/qtjolie/sodepmessage.h rename to private/qtjolie-branch/qtjolie/message.h index 830f91804..92507328a 100644 --- a/private/qtjolie-branch/qtjolie/sodepmessage.h +++ b/private/qtjolie-branch/qtjolie/message.h @@ -18,41 +18,46 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPMESSAGE_H -#define SODEPMESSAGE_H +#ifndef QTJOLIE_MESSAGE_H +#define QTJOLIE_MESSAGE_H -#include -#include +#include +#include -class SodepMessagePrivate; +namespace Jolie +{ +class MessagePrivate; -class Q_DECL_EXPORT SodepMessage +class Q_DECL_EXPORT Message { public: - SodepMessage(); - explicit SodepMessage(const QString &resourcePath, + Message(); + explicit Message(const QString &resourcePath, const QString &operationName, qint64 id = 0); - SodepMessage(const SodepMessage &other); - ~SodepMessage(); + Message(const Message &other); + ~Message(); - SodepMessage &operator=(const SodepMessage &other); + Message &operator=(const Message &other); qint64 id() const; QString resourcePath() const; QString operationName() const; - SodepFault fault() const; - void setFault(const SodepFault &fault); + Fault fault() const; + void setFault(const Fault &fault); - SodepValue data() const; - void setData(const SodepValue &data); + Value data() const; + void setData(const Value &data); bool isValid(); private: - SodepMessagePrivate * const d; + MessagePrivate * const d; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodeppendingcall.cpp b/private/qtjolie-branch/qtjolie/pendingcall.cpp similarity index 64% rename from private/qtjolie-branch/qtjolie/sodeppendingcall.cpp rename to private/qtjolie-branch/qtjolie/pendingcall.cpp index b55d69e71..516d53279 100644 --- a/private/qtjolie-branch/qtjolie/sodeppendingcall.cpp +++ b/private/qtjolie-branch/qtjolie/pendingcall.cpp @@ -18,62 +18,64 @@ * Boston, MA 02110-1301, USA. */ -#include "sodeppendingcall.h" -#include "sodeppendingcall_p.h" +#include "pendingcall.h" +#include "pendingcall_p.h" +using namespace Jolie; -SodepPendingCall::SodepPendingCall(const SodepPendingCall &other) +PendingCall::PendingCall(const PendingCall &other) : d(other.d) { } -SodepPendingCall::SodepPendingCall(QExplicitlySharedDataPointer dd) +PendingCall::PendingCall(QExplicitlySharedDataPointer dd) : d(dd) { } -SodepPendingCall::~SodepPendingCall() +PendingCall::~PendingCall() { } -SodepPendingCall &SodepPendingCall::operator=(const SodepPendingCall &other) +PendingCall &PendingCall::operator=(const PendingCall &other) { d = other.d; return *this; } -bool SodepPendingCall::isFinished() const +bool PendingCall::isFinished() const { return d->isFinished; } -SodepMessage SodepPendingCall::reply() const +Message PendingCall::reply() const { return d->reply; } -void SodepPendingCall::waitForFinished() +void PendingCall::waitForFinished() { - SodepPendingCallWaiter waiter; + PendingCallWaiter waiter; waiter.waitForFinished(d.data()); } -void SodepPendingCallPrivate::setReply(const SodepMessage &message) +void PendingCallPrivate::setReply(const Message &message) { Q_ASSERT(message.id()==id); isFinished = true; reply = message; - foreach (SodepPendingCallWaiter *waiter, waiters) { + foreach (PendingCallWaiter *waiter, waiters) { waiter->eventLoop.quit(); } waiters.clear(); } -void SodepPendingCallWaiter::waitForFinished(SodepPendingCallPrivate *pendingCall) +void PendingCallWaiter::waitForFinished(PendingCallPrivate *pendingCall) { pendingCall->waiters << this; eventLoop.exec(); } + diff --git a/private/qtjolie-branch/qtjolie/sodeppendingcall.h b/private/qtjolie-branch/qtjolie/pendingcall.h similarity index 65% rename from private/qtjolie-branch/qtjolie/sodeppendingcall.h rename to private/qtjolie-branch/qtjolie/pendingcall.h index 7f493465a..864eaa3b3 100644 --- a/private/qtjolie-branch/qtjolie/sodeppendingcall.h +++ b/private/qtjolie-branch/qtjolie/pendingcall.h @@ -18,35 +18,40 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPPENDINGCALL_H -#define SODEPPENDINGCALL_H +#ifndef QTJOLIE_PENDINGCALL_H +#define QTJOLIE_PENDINGCALL_H #include -class SodepClient; -class SodepPendingCallPrivate; -class SodepMessage; +namespace Jolie +{ +class Client; +class PendingCallPrivate; +class Message; -class Q_DECL_EXPORT SodepPendingCall +class Q_DECL_EXPORT PendingCall { public: - SodepPendingCall(const SodepPendingCall &other); - ~SodepPendingCall(); + PendingCall(const PendingCall &other); + ~PendingCall(); - SodepPendingCall &operator=(const SodepPendingCall &other); + PendingCall &operator=(const PendingCall &other); bool isFinished() const; - SodepMessage reply() const; + Message reply() const; void waitForFinished(); private: - friend class SodepClient; + friend class Client; - SodepPendingCall(); // Not defined - SodepPendingCall(QExplicitlySharedDataPointer dd); + PendingCall(); // Not defined + PendingCall(QExplicitlySharedDataPointer dd); - QExplicitlySharedDataPointer d; + QExplicitlySharedDataPointer d; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/qtjolie/sodeppendingcall_p.h b/private/qtjolie-branch/qtjolie/pendingcall_p.h similarity index 67% rename from private/qtjolie-branch/qtjolie/sodeppendingcall_p.h rename to private/qtjolie-branch/qtjolie/pendingcall_p.h index daa7b1535..15e90ab23 100644 --- a/private/qtjolie-branch/qtjolie/sodeppendingcall_p.h +++ b/private/qtjolie-branch/qtjolie/pendingcall_p.h @@ -18,44 +18,49 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPPENDINGCALL_P_H -#define SODEPPENDINGCALL_P_H +#ifndef QTJOLIE_PENDINGCALL_P_H +#define QTJOLIE_PENDINGCALL_P_H #include #include #include -#include "sodepmessage.h" +#include "message.h" -class SodepPendingCallPrivate; +namespace Jolie +{ -class SodepPendingCallWaiter +class PendingCallPrivate; + +class PendingCallWaiter { public: - void waitForFinished(SodepPendingCallPrivate *pendingCall); + void waitForFinished(PendingCallPrivate *pendingCall); private: - friend class SodepPendingCallPrivate; + friend class PendingCallPrivate; QEventLoop eventLoop; }; -class SodepPendingCallPrivate : public QSharedData +class PendingCallPrivate : public QSharedData { public: - SodepPendingCallPrivate(const SodepMessage &message) + PendingCallPrivate(const Message &message) : id(message.id()), isFinished(false) {} - void setReply(const SodepMessage &message); + void setReply(const Message &message); private: - friend class SodepPendingCall; - friend class SodepPendingCallWaiter; + friend class PendingCall; + friend class PendingCallWaiter; qint64 id; bool isFinished; - SodepMessage reply; - QList waiters; + Message reply; + QList waiters; }; +} // namespace Jolie #endif + diff --git a/private/qtjolie-branch/qtjolie/sodephelpers_p.h b/private/qtjolie-branch/qtjolie/sodephelpers_p.h index 930d037f9..8602eba73 100644 --- a/private/qtjolie-branch/qtjolie/sodephelpers_p.h +++ b/private/qtjolie-branch/qtjolie/sodephelpers_p.h @@ -18,16 +18,19 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPHELPERS_P_H -#define SODEPHELPERS_P_H +#ifndef QTJOLIE_SODEPHELPERS_P_H +#define QTJOLIE_SODEPHELPERS_P_H #include #include #include -#include "sodepvalue.h" -#include "sodepfault.h" -#include "sodepmessage.h" +#include "value.h" +#include "fault.h" +#include "message.h" + +namespace Jolie +{ inline void sodepWrite(QIODevice &io, double value) { @@ -72,7 +75,7 @@ inline void sodepWrite(QIODevice &io, const QString &value) io.write(data); } -inline void sodepWrite(QIODevice &io, const SodepValue &value) +inline void sodepWrite(QIODevice &io, const Value &value) { if (value.isDouble()) { io.putChar(3); @@ -92,7 +95,7 @@ inline void sodepWrite(QIODevice &io, const SodepValue &value) foreach (const QString &name, value.childrenNames()) { sodepWrite(io, name); - QList values = value.children(name); + QList values = value.children(name); qint32 valueCount = values.size(); sodepWrite(io, valueCount); for (int j=0; j #include #include "sodephelpers_p.h" -class SodepValuePrivate +namespace Jolie +{ + +class ValuePrivate { public: QVariant content; - QMap > children; + QMap > children; }; -SodepValue::SodepValue() - : d(new SodepValuePrivate) +} // namespace Jolie + +using namespace Jolie; + +Value::Value() + : d(new ValuePrivate) { } -SodepValue::SodepValue(const QString &content) - : d(new SodepValuePrivate) +Value::Value(const QString &content) + : d(new ValuePrivate) { d->content = content; } -SodepValue::SodepValue(qint32 content) - : d(new SodepValuePrivate) +Value::Value(qint32 content) + : d(new ValuePrivate) { d->content = content; } -SodepValue::SodepValue(double content) - : d(new SodepValuePrivate) +Value::Value(double content) + : d(new ValuePrivate) { d->content = content; } -SodepValue::SodepValue(const SodepValue &other) - : d(new SodepValuePrivate) +Value::Value(const Value &other) + : d(new ValuePrivate) { *d = *other.d; } -SodepValue::~SodepValue() +Value::~Value() { delete d; } -SodepValue &SodepValue::operator=(const SodepValue &other) +Value &Value::operator=(const Value &other) { *d = *other.d; return *this; } -QStringList SodepValue::childrenNames() const +QStringList Value::childrenNames() const { return d->children.keys(); } -QList & SodepValue::children(const QString &name) +QList & Value::children(const QString &name) { return d->children[name]; } -const QList & SodepValue::children(const QString &name) const +const QList & Value::children(const QString &name) const { return d->children[name]; } -QString SodepValue::toString() const +QString Value::toString() const { if (isString()) { return d->content.toString(); @@ -97,7 +104,7 @@ QString SodepValue::toString() const } } -qint32 SodepValue::toInt() const +qint32 Value::toInt() const { if (isInt()) { return d->content.toInt(); @@ -106,7 +113,7 @@ qint32 SodepValue::toInt() const } } -double SodepValue::toDouble() const +double Value::toDouble() const { if (isDouble()) { return d->content.toDouble(); @@ -115,22 +122,23 @@ double SodepValue::toDouble() const } } -bool SodepValue::isString() const +bool Value::isString() const { return d->content.type()==QVariant::String; } -bool SodepValue::isInt() const +bool Value::isInt() const { return d->content.type()==QVariant::Int; } -bool SodepValue::isDouble() const +bool Value::isDouble() const { return d->content.type()==QVariant::Double; } -bool SodepValue::isValid() const +bool Value::isValid() const { return isString() || isInt() || isDouble(); } + diff --git a/private/qtjolie-branch/qtjolie/sodepvalue.h b/private/qtjolie-branch/qtjolie/value.h similarity index 70% rename from private/qtjolie-branch/qtjolie/sodepvalue.h rename to private/qtjolie-branch/qtjolie/value.h index 21471acc9..564a1ec36 100644 --- a/private/qtjolie-branch/qtjolie/sodepvalue.h +++ b/private/qtjolie-branch/qtjolie/value.h @@ -18,32 +18,34 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SODEPVALUE_H -#define SODEPVALUE_H +#ifndef QTJOLIE_VALUE_H +#define QTJOLIE_VALUE_H #include #include -class SodepValuePrivate; +namespace Jolie +{ +class ValuePrivate; -class Q_DECL_EXPORT SodepValue +class Q_DECL_EXPORT Value { public: - SodepValue(); + Value(); - explicit SodepValue(const QString &content); - explicit SodepValue(qint32 content); - explicit SodepValue(double content); + explicit Value(const QString &content); + explicit Value(qint32 content); + explicit Value(double content); - SodepValue(const SodepValue &other); + Value(const Value &other); - ~SodepValue(); + ~Value(); - SodepValue &operator=(const SodepValue &other); + Value &operator=(const Value &other); QStringList childrenNames() const; - QList &children(const QString &name); - const QList &children(const QString &name) const; + QList &children(const QString &name); + const QList &children(const QString &name) const; QString toString() const; qint32 toInt() const; @@ -56,7 +58,10 @@ public: bool isValid() const; private: - SodepValuePrivate * const d; + ValuePrivate * const d; }; +} // namespace Jolie + #endif + diff --git a/private/qtjolie-branch/tests/CMakeLists.txt b/private/qtjolie-branch/tests/CMakeLists.txt index d7bdde02c..b9a52d695 100644 --- a/private/qtjolie-branch/tests/CMakeLists.txt +++ b/private/qtjolie-branch/tests/CMakeLists.txt @@ -17,12 +17,12 @@ MACRO(SODEP_EXECUTABLE_TESTS) ENDMACRO(SODEP_EXECUTABLE_TESTS) SODEP_UNIT_TESTS( - sodepvaluetest - sodepfaulttest - sodepmessagetest - sodepmetaservicetest + testvalue + testfault + testmessage + testmetaservice ) SODEP_EXECUTABLE_TESTS( - sodepprintertest + testprinter ) diff --git a/private/qtjolie-branch/tests/sodepfaulttest.cpp b/private/qtjolie-branch/tests/testfault.cpp similarity index 81% rename from private/qtjolie-branch/tests/sodepfaulttest.cpp rename to private/qtjolie-branch/tests/testfault.cpp index 6702112bb..93c84332d 100644 --- a/private/qtjolie-branch/tests/sodepfaulttest.cpp +++ b/private/qtjolie-branch/tests/testfault.cpp @@ -21,17 +21,19 @@ #include #include -#include -#include "sodeptesthelpers.h" +#include +#include "testhelpers.h" -class SodepFaultTest : public QObject +using namespace Jolie; + +class TestFault : public QObject { Q_OBJECT private slots: void shouldHandleInvalids() { - SodepFault f; + Fault f; QCOMPARE(f.name(), QString()); QVERIFY(!f.data().isValid()); @@ -40,7 +42,7 @@ private slots: } void shouldVerifyInitialState() { - SodepFault f1("blup"), f2("blop", SodepValue(42)); + Fault f1("blup"), f2("blop", Value(42)); QCOMPARE(f1.name(), QString("blup")); QVERIFY(!f1.data().isValid()); @@ -58,18 +60,18 @@ private slots: void shouldBeSerializable_data() { - SodepValue v(42); + Value v(42); QByteArray vSerial = QByteArray::fromHex("020000002A00000000"); - QTest::addColumn("original"); + QTest::addColumn("original"); QTest::addColumn("serialized"); - QTest::newRow("empty fault") << SodepFault() + QTest::newRow("empty fault") << Fault() << QByteArray::fromHex("00"); - QTest::newRow("no value fault") << SodepFault("foo") + QTest::newRow("no value fault") << Fault("foo") << QByteArray::fromHex("0100000003")+QByteArray("foo") + QByteArray::fromHex("0000000000"); - QTest::newRow("value fault") << SodepFault("bar", v) + QTest::newRow("value fault") << Fault("bar", v) << QByteArray::fromHex("0100000003")+QByteArray("bar") + vSerial; } @@ -78,9 +80,9 @@ private slots: { QBuffer buffer; - QFETCH(SodepFault, original); + QFETCH(Fault, original); QFETCH(QByteArray, serialized); - SodepFault result; + Fault result; buffer.open(QIODevice::WriteOnly); sodepWrite(buffer, original); @@ -95,6 +97,6 @@ private slots: } }; -QTEST_MAIN(SodepFaultTest) +QTEST_MAIN(TestFault) -#include "sodepfaulttest.moc" +#include "testfault.moc" diff --git a/private/qtjolie-branch/tests/sodeptesthelpers.h b/private/qtjolie-branch/tests/testhelpers.h similarity index 79% rename from private/qtjolie-branch/tests/sodeptesthelpers.h rename to private/qtjolie-branch/tests/testhelpers.h index e2ab8ba5d..2cf3a6ae2 100644 --- a/private/qtjolie-branch/tests/sodeptesthelpers.h +++ b/private/qtjolie-branch/tests/testhelpers.h @@ -23,14 +23,14 @@ #include -#include -#include -#include +#include +#include +#include #include -Q_DECLARE_METATYPE(SodepValue); +Q_DECLARE_METATYPE(Jolie::Value); -inline void sodepCompare(const SodepValue &v1, const SodepValue &v2) +inline void sodepCompare(const Jolie::Value &v1, const Jolie::Value &v2) { QCOMPARE(v1.isValid(), v2.isValid()); @@ -47,8 +47,8 @@ inline void sodepCompare(const SodepValue &v1, const SodepValue &v2) QCOMPARE(v1Names, v2Names); foreach (const QString &name, v1Names) { - QList v1Values = v1.children(name); - QList v2Values = v2.children(name); + QList v1Values = v1.children(name); + QList v2Values = v2.children(name); QCOMPARE(v1Values.size(), v2Values.size()); @@ -58,18 +58,18 @@ inline void sodepCompare(const SodepValue &v1, const SodepValue &v2) } } -Q_DECLARE_METATYPE(SodepFault); +Q_DECLARE_METATYPE(Jolie::Fault); -inline void sodepCompare(const SodepFault &f1, const SodepFault &f2) +inline void sodepCompare(const Jolie::Fault &f1, const Jolie::Fault &f2) { QCOMPARE(f1.isValid(), f2.isValid()); QCOMPARE(f1.name(), f2.name()); sodepCompare(f1.data(), f2.data()); } -Q_DECLARE_METATYPE(SodepMessage); +Q_DECLARE_METATYPE(Jolie::Message); -inline void sodepCompare(const SodepMessage &m1, const SodepMessage &m2) +inline void sodepCompare(const Jolie::Message &m1, const Jolie::Message &m2) { QCOMPARE(m1.resourcePath(), m2.resourcePath()); QCOMPARE(m1.operationName(), m2.operationName()); diff --git a/private/qtjolie-branch/tests/sodepmessagetest.cpp b/private/qtjolie-branch/tests/testmessage.cpp similarity index 85% rename from private/qtjolie-branch/tests/sodepmessagetest.cpp rename to private/qtjolie-branch/tests/testmessage.cpp index 712f58743..744ca40e1 100644 --- a/private/qtjolie-branch/tests/sodepmessagetest.cpp +++ b/private/qtjolie-branch/tests/testmessage.cpp @@ -21,18 +21,20 @@ #include #include -#include -#include "sodeptesthelpers.h" +#include +#include "testhelpers.h" -class SodepMessageTest : public QObject +using namespace Jolie; + +class TestMessage : public QObject { Q_OBJECT private slots: void shouldVerifyInitialState() { - SodepMessage m1("/foo", "bar", 1); - SodepMessage m2("/pata/pata", "pon", 2); + Message m1("/foo", "bar", 1); + Message m2("/pata/pata", "pon", 2); QCOMPARE(m1.resourcePath(), QString("/foo")); QCOMPARE(m1.operationName(), QString("bar")); @@ -51,23 +53,23 @@ private slots: void shouldBeSerializable_data() { - SodepValue v(42); + Value v(42); QByteArray vSerial = QByteArray::fromHex("020000002A00000000"); - SodepFault f("foo"); + Fault f("foo"); QByteArray fSerial = QByteArray::fromHex("0100000003")+QByteArray("foo") + QByteArray::fromHex("0000000000"); - QTest::addColumn("original"); + QTest::addColumn("original"); QTest::addColumn("serialized"); - QTest::newRow("no payload message") << SodepMessage("/pata", "pon", 1) + QTest::newRow("no payload message") << Message("/pata", "pon", 1) << QByteArray::fromHex("0000000000000001") + QByteArray::fromHex("00000005")+QByteArray("/pata") + QByteArray::fromHex("00000003")+QByteArray("pon") + QByteArray::fromHex("00") + QByteArray::fromHex("0000000000"); - SodepMessage payload("/pata", "pon", 1); + Message payload("/pata", "pon", 1); payload.setFault(f); payload.setData(v); QTest::newRow("payload message") << payload @@ -77,7 +79,7 @@ private slots: + fSerial + vSerial; - SodepMessage payloadId("/pata", "pon", 42); + Message payloadId("/pata", "pon", 42); payloadId.setFault(f); payloadId.setData(v); QTest::newRow("payload and id message") << payloadId @@ -92,9 +94,9 @@ private slots: { QBuffer buffer; - QFETCH(SodepMessage, original); + QFETCH(Message, original); QFETCH(QByteArray, serialized); - SodepMessage result; + Message result; buffer.open(QIODevice::WriteOnly); sodepWrite(buffer, original); @@ -109,6 +111,6 @@ private slots: } }; -QTEST_MAIN(SodepMessageTest) +QTEST_MAIN(TestMessage) -#include "sodepmessagetest.moc" +#include "testmessage.moc" diff --git a/private/qtjolie-branch/tests/sodepmetaservicetest.cpp b/private/qtjolie-branch/tests/testmetaservice.cpp similarity index 62% rename from private/qtjolie-branch/tests/sodepmetaservicetest.cpp rename to private/qtjolie-branch/tests/testmetaservice.cpp index 79049a4bb..f5f4064d4 100644 --- a/private/qtjolie-branch/tests/sodepmetaservicetest.cpp +++ b/private/qtjolie-branch/tests/testmetaservice.cpp @@ -22,17 +22,18 @@ #include #include -#include -#include -#include -#include "sodeptesthelpers.h" +#include +#include +#include +#include "testhelpers.h" #ifndef DATA_DIR #error "DATA_DIR is not set. A directory containing test jolie scripts is required for this test" #endif +using namespace Jolie; -void dump(const SodepValue &value, int level) +void dump(const Value &value, int level) { QString indent; @@ -43,15 +44,15 @@ void dump(const SodepValue &value, int level) qDebug() << (indent+value.toString()) << value.toInt() << value.toDouble(); foreach (const QString &name, value.childrenNames()) { - QList children = value.children(name); + QList children = value.children(name); qDebug() << (indent+"Children:") << name; - foreach (const SodepValue &child, children) { + foreach (const Value &child, children) { dump(child, level+1); } } } -void dump(const SodepMessage &message) +void dump(const Message &message) { qDebug() << "Resource :" << message.resourcePath(); qDebug() << "Operation:" << message.operationName(); @@ -61,18 +62,18 @@ void dump(const SodepMessage &message) dump(message.data(), 1); } -class SodepMetaServiceTest : public QObject +class TestMetaService : public QObject { Q_OBJECT QProcess m_metaserviceProcess; - SodepClient *m_client; + Client *m_client; public: - SodepMetaServiceTest() + TestMetaService() : QObject() { - qRegisterMetaType(); + qRegisterMetaType(); } private slots: @@ -82,12 +83,12 @@ private slots: QVERIFY2(m_metaserviceProcess.waitForStarted(), "Looks like you don't have Jolie's metaservice command"); QTest::qWait(1000); - m_client = new SodepClient("localhost", 9000); + m_client = new Client("localhost", 9000); } void cleanupTestCase() { - SodepMessage message("/", "shutdown"); + Message message("/", "shutdown"); m_client->callNoReply(message); delete m_client; @@ -108,34 +109,34 @@ private slots: QFETCH(QString, resourcePrefix); QFETCH(QString, fileName); - SodepMessage message("/", "loadEmbeddedJolieService"); - SodepValue value; - value.children("resourcePrefix") << SodepValue(resourcePrefix); - value.children("filepath") << SodepValue(QString(DATA_DIR"/")+fileName); + Message message("/", "loadEmbeddedJolieService"); + Value value; + value.children("resourcePrefix") << Value(resourcePrefix); + value.children("filepath") << Value(QString(DATA_DIR"/")+fileName); message.setData(value); - SodepMessage reply = m_client->call(message); + Message reply = m_client->call(message); - SodepMessage expected("/", "loadEmbeddedJolieService"); - expected.setData(SodepValue(resourcePrefix)); + Message expected("/", "loadEmbeddedJolieService"); + expected.setData(Value(resourcePrefix)); sodepCompare(reply, expected); } void shouldListServices() { - SodepMessage message("/", "getServices"); + Message message("/", "getServices"); - SodepMessage reply = m_client->call(message); - SodepMessage expected("/", "getServices"); - SodepValue value; + Message reply = m_client->call(message); + Message expected("/", "getServices"); + Value value; - SodepValue s1; - s1.children("isEmbedded") << SodepValue(1); - s1.children("resourceName") << SodepValue("Math"); - SodepValue s2; - s2.children("isEmbedded") << SodepValue(1); - s2.children("resourceName") << SodepValue("Printer"); + Value s1; + s1.children("isEmbedded") << Value(1); + s1.children("resourceName") << Value("Math"); + Value s2; + s2.children("isEmbedded") << Value(1); + s2.children("resourceName") << Value("Printer"); value.children("service") << s1 << s2; expected.setData(value); @@ -147,26 +148,26 @@ private slots: { QTest::addColumn("path"); QTest::addColumn("method"); - QTest::addColumn("data"); - QTest::addColumn("replyData"); + QTest::addColumn("data"); + QTest::addColumn("replyData"); - QTest::newRow("printer service") << "/Printer" << "printInput" << SodepValue("Patapatapon!") << SodepValue("success"); - QTest::newRow("math service") << "/Math" << "twice" << SodepValue(10.5) << SodepValue(21.0); + QTest::newRow("printer service") << "/Printer" << "printInput" << Value("Patapatapon!") << Value("success"); + QTest::newRow("math service") << "/Math" << "twice" << Value(10.5) << Value(21.0); } void shouldPlaceServiceCalls() { QFETCH(QString, path); QFETCH(QString, method); - QFETCH(SodepValue, data); - QFETCH(SodepValue, replyData); + QFETCH(Value, data); + QFETCH(Value, replyData); - SodepMessage message(path, method); + Message message(path, method); message.setData(data); - SodepMessage reply = m_client->call(message); + Message reply = m_client->call(message); - SodepMessage expected("/", method); + Message expected("/", method); expected.setData(replyData); sodepCompare(reply, expected); @@ -184,18 +185,18 @@ private slots: { QFETCH(QString, serviceName); - SodepMessage message("/", "unloadEmbeddedService"); - SodepValue value(serviceName); + Message message("/", "unloadEmbeddedService"); + Value value(serviceName); message.setData(value); - SodepMessage reply = m_client->call(message); + Message reply = m_client->call(message); - SodepMessage expected("/", "unloadEmbeddedService"); + Message expected("/", "unloadEmbeddedService"); sodepCompare(reply, expected); } }; -QTEST_MAIN(SodepMetaServiceTest) +QTEST_MAIN(TestMetaService) -#include "sodepmetaservicetest.moc" +#include "testmetaservice.moc" diff --git a/private/qtjolie-branch/tests/sodepprintertest.cpp b/private/qtjolie-branch/tests/testprinter.cpp similarity index 92% rename from private/qtjolie-branch/tests/sodepprintertest.cpp rename to private/qtjolie-branch/tests/testprinter.cpp index a553284c1..69e1b5b0d 100644 --- a/private/qtjolie-branch/tests/sodepprintertest.cpp +++ b/private/qtjolie-branch/tests/testprinter.cpp @@ -25,10 +25,12 @@ #include #include -#include -#include +#include +#include #include +using namespace Jolie; + class MainWindow : public QWidget { Q_OBJECT @@ -56,8 +58,8 @@ public: private slots: void sendMessage() { - SodepMessage message("/", "printInput"); - message.setData(SodepValue(m_lineEdit->text())); + Message message("/", "printInput"); + message.setData(Value(m_lineEdit->text())); sodepWrite(m_socket, message); qDebug("Message sent:"); @@ -90,4 +92,4 @@ int main(int argc, char **argv) return app.exec(); } -#include "sodepprintertest.moc" +#include "testprinter.moc" diff --git a/private/qtjolie-branch/tests/sodepvaluetest.cpp b/private/qtjolie-branch/tests/testvalue.cpp similarity index 83% rename from private/qtjolie-branch/tests/sodepvaluetest.cpp rename to private/qtjolie-branch/tests/testvalue.cpp index f07692c9e..217ae5383 100644 --- a/private/qtjolie-branch/tests/sodepvaluetest.cpp +++ b/private/qtjolie-branch/tests/testvalue.cpp @@ -21,18 +21,20 @@ #include #include -#include +#include -#include "sodeptesthelpers.h" +#include "testhelpers.h" -class SodepValueTest : public QObject +using namespace Jolie; + +class TestValue : public QObject { Q_OBJECT private slots: void shouldHandleInvalids() { - SodepValue v; + Value v; QCOMPARE(v.toInt(), 0); QCOMPARE(v.toDouble(), 0.0); @@ -47,7 +49,7 @@ private slots: void shouldRespectIntValues() { - SodepValue v1(42), v2; + Value v1(42), v2; QCOMPARE(v1.toInt(), 42); QCOMPARE(v2.toInt(), 0); @@ -66,7 +68,7 @@ private slots: void shouldRespectDoubleValues() { - SodepValue v1(0.42), v2; + Value v1(0.42), v2; QCOMPARE(v1.toDouble(), 0.42); QCOMPARE(v2.toDouble(), 0.0); @@ -85,7 +87,7 @@ private slots: void shouldRespectStringValues() { - SodepValue v1("42"), v2; + Value v1("42"), v2; QCOMPARE(v1.toString(), QString("42")); QCOMPARE(v2.toString(), QString()); @@ -104,10 +106,10 @@ private slots: void shouldHandleChildren() { - SodepValue v; + Value v; - v.children("first") << SodepValue(7) << SodepValue(8); - v.children("second") << SodepValue(42); + v.children("first") << Value(7) << Value(8); + v.children("second") << Value(42); QCOMPARE(v.children("second").size(), 1); QCOMPARE(v.children("second")[0].toInt(), 42); @@ -121,22 +123,22 @@ private slots: void shouldBeSerializable_data() { - QTest::addColumn("original"); + QTest::addColumn("original"); QTest::addColumn("serialized"); - QTest::newRow("empty value") << SodepValue() + QTest::newRow("empty value") << Value() << QByteArray::fromHex("0000000000"); - QTest::newRow("double value") << SodepValue(0.42) + QTest::newRow("double value") << Value(0.42) << QByteArray::fromHex("033FDAE147AE147AE100000000"); - QTest::newRow("int value") << SodepValue(42) + QTest::newRow("int value") << Value(42) << QByteArray::fromHex("020000002A00000000"); - QTest::newRow("string value") << SodepValue("foo") + QTest::newRow("string value") << Value("foo") << QByteArray::fromHex("0100000003")+QByteArray("foo") + QByteArray::fromHex("00000000"); - SodepValue complex("complex"); - complex.children("foo") << SodepValue(42); - complex.children("bar") << SodepValue(0.42); + Value complex("complex"); + complex.children("foo") << Value(42); + complex.children("bar") << Value(0.42); QTest::newRow("complex value") << complex << QByteArray::fromHex("0100000007")+QByteArray("complex") + QByteArray::fromHex("00000002") // two children @@ -152,9 +154,9 @@ private slots: { QBuffer buffer; - QFETCH(SodepValue, original); + QFETCH(Value, original); QFETCH(QByteArray, serialized); - SodepValue result; + Value result; buffer.open(QIODevice::WriteOnly); sodepWrite(buffer, original); @@ -169,6 +171,6 @@ private slots: } }; -QTEST_MAIN(SodepValueTest) +QTEST_MAIN(TestValue) -#include "sodepvaluetest.moc" +#include "testvalue.moc"