From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- dcopjava/tests/Makefile.am | 17 +++++++ dcopjava/tests/main.cpp | 17 +++++++ dcopjava/tests/test.h | 46 ++++++++++++++++++ dcopjava/tests/test.java | 78 +++++++++++++++++++++++++++++++ dcopjava/tests/test_impl.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++ dcopjava/tests/test_impl.h | 38 +++++++++++++++ 6 files changed, 304 insertions(+) create mode 100644 dcopjava/tests/Makefile.am create mode 100644 dcopjava/tests/main.cpp create mode 100644 dcopjava/tests/test.h create mode 100644 dcopjava/tests/test.java create mode 100644 dcopjava/tests/test_impl.cpp create mode 100644 dcopjava/tests/test_impl.h (limited to 'dcopjava/tests') diff --git a/dcopjava/tests/Makefile.am b/dcopjava/tests/Makefile.am new file mode 100644 index 00000000..847d3c53 --- /dev/null +++ b/dcopjava/tests/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) + +check_PROGRAMS = server test.class + +server_SOURCES = main.cpp test.skel test_impl.cpp +server_LDFLAGS = $(all_libraries) +server_LDADD = $(LIB_KDECORE) + +# test_class_SOURCES = test.java + +test.class: test.java test_stub.java + $(JAVAC) -classpath $(kde_libraries)/java:. test.java + +test_stub.java: test.h test.kidl + dcopidl2java test.kidl + +CLEANFILES = test_stub.java test_stub.class diff --git a/dcopjava/tests/main.cpp b/dcopjava/tests/main.cpp new file mode 100644 index 00000000..2bdb0547 --- /dev/null +++ b/dcopjava/tests/main.cpp @@ -0,0 +1,17 @@ +#include +#include + + +#include "test_impl.h" + + +int main(int argc, char *argv[]) +{ + KApplication app(argc, argv, "test-server", false, false); + + app.dcopClient()->registerAs("test-server", false); + + test_impl *t = new test_impl; + + return app.exec(); +} diff --git a/dcopjava/tests/test.h b/dcopjava/tests/test.h new file mode 100644 index 00000000..5f215ce7 --- /dev/null +++ b/dcopjava/tests/test.h @@ -0,0 +1,46 @@ +#ifndef _TEST_H_ +#define _TEST_H_ + + +#include +#include + + +#include +#include + + +class test : virtual public DCOPObject +{ + K_DCOP + +public: + +k_dcop: + + virtual void noArg() = 0; + virtual ASYNC asyncNoArg() = 0; + + virtual void oneArg(bool val) = 0; + virtual bool returnFalse() = 0; + virtual bool returnTrue() = 0; + + virtual short shortArg(short in) = 0; + virtual int intArg(int in) = 0; + virtual long longArg(long in) = 0; + + virtual float floatArg(float in) = 0; + virtual double doubleArg(double in) = 0; + + virtual QString stringArg(QString in) = 0; + virtual QStringList stringListArg(QStringList in) = 0; + + virtual QCString cstringArg(QCString in) = 0; + + virtual DCOPRef DCOPRefArg(DCOPRef in) = 0; + +}; + + + +#endif diff --git a/dcopjava/tests/test.java b/dcopjava/tests/test.java new file mode 100644 index 00000000..72a40b95 --- /dev/null +++ b/dcopjava/tests/test.java @@ -0,0 +1,78 @@ +import org.kde.DCOP.*; + + +class test +{ + + public static void main(String[] argv) + { + test_stub test = new test_stub("test-server", "test"); + + System.out.println("Calling server without args:"); + test.noArg(); + System.out.println(""); + + System.out.println("Calling server asynchronously without args:"); + test.asyncNoArg(); + System.out.println(""); + + System.out.println("Calling server with one argument: bool=true:"); + test.oneArg(true); + System.out.println(""); + + System.out.println("Calling server with one argument: bool=false:"); + test.oneArg(false); + System.out.println(""); + + System.out.println("Calling server: returnFalse"); + boolean ret = test.returnFalse(); + System.out.print("Returned: "); + if (ret) + System.out.println("True"); + else + System.out.println("False"); + System.out.println(); + + System.out.println("Calling server: returnTrue"); + ret = test.returnTrue(); + System.out.print("Returned: "); + if (ret) + System.out.println("True"); + else + System.out.println("False"); + System.out.println(); + + System.out.println("Calling server: short"); + System.out.println(test.shortArg((short)(51))); + + System.out.println("Calling server: int"); + System.out.println(test.intArg(512)); + + System.out.println("Calling server: long"); + System.out.println(test.longArg(999999)); + + System.out.println("Calling server: float"); + System.out.println(test.floatArg(5.1212f)); + + System.out.println("Calling server: double"); + System.out.println(test.doubleArg(0.001122)); + + System.out.println("Calling server: String"); + System.out.println(test.stringArg("Hallo Server")); + + String[] in = { "alpha", "beta", "gamma", "delta" }; + System.out.println("Calling server: String[]"); + String[] out = test.stringListArg(in); + for (int i=0; i +#include + + +#include "test_impl.h" + + +void test_impl::noArg() +{ + printf("SERVER: noArg() called\n"); +} + + +void test_impl::asyncNoArg() +{ + printf("SERVER: asyncNoArg() called\n"); +} + + +void test_impl::oneArg(bool b) +{ + printf("SERVER: oneArg("); + printf(b ? "true" : "false"); + printf(") called\n"); +} + + +bool test_impl::returnFalse() +{ + printf("SERVER: returnFalse() called\n"); + return false; +} + + +bool test_impl::returnTrue() +{ + printf("SERVER: returnTrue() called\n"); + return true; +} + + +short test_impl::shortArg(short in) +{ + cout << "SERVER: short in: " << in << endl; + return 123; +} + + +int test_impl::intArg(int in) +{ + cout << "SERVER: int in: " << in << endl; + return 123456; +} + + +long test_impl::longArg(long in) +{ + cout << "SERVER: long in: " << in << endl; + return 1234567890; +} + + +float test_impl::floatArg(float in) +{ + cout << "SERVER: float in: " << in << endl; + return 12.34; +} + + +double test_impl::doubleArg(double in) +{ + cout << "SERVER: double in: " << in << endl; + return 12.12313123; +} + + +QString test_impl::stringArg(QString in) +{ + cout << "SERVER: QString in: " << in << endl; + return "Hello Java"; +} + + +QCString test_impl::cstringArg(QCString in) +{ + cout << "SERVER: QCString in: " << in << endl; + return "Hello Java"; +} + + +QStringList test_impl::stringListArg(QStringList in) +{ + cout << "SERVER: QStringList in: "; + for (uint i=0; i