summaryrefslogtreecommitdiffstats
path: root/dcopjava/tests
diff options
context:
space:
mode:
Diffstat (limited to 'dcopjava/tests')
-rw-r--r--dcopjava/tests/Makefile.am17
-rw-r--r--dcopjava/tests/main.cpp17
-rw-r--r--dcopjava/tests/test.h46
-rw-r--r--dcopjava/tests/test.java78
-rw-r--r--dcopjava/tests/test_impl.cpp108
-rw-r--r--dcopjava/tests/test_impl.h38
6 files changed, 304 insertions, 0 deletions
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 <kapplication.h>
+#include <dcopclient.h>
+
+
+#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 <qstring.h>
+#include <qstringlist.h>
+
+
+#include <dcopobject.h>
+#include <dcopref.h>
+
+
+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<out.length; ++i)
+ System.out.println(out[i]);
+
+ System.out.println("Calling server: CString");
+ System.out.println(test.cstringArg("Hallo Server"));
+
+ DCOPRef rin = new DCOPRef("app", "obj", "typ");
+ System.out.println("Calling server: DCOPRef");
+ DCOPRef rout = test.DCOPRefArg(rin);
+ System.out.println("Reference: " + rout.app() + ", " +
+ rout.object() + ", " + rout.type());
+ }
+}
diff --git a/dcopjava/tests/test_impl.cpp b/dcopjava/tests/test_impl.cpp
new file mode 100644
index 00000000..c220b3f8
--- /dev/null
+++ b/dcopjava/tests/test_impl.cpp
@@ -0,0 +1,108 @@
+#include <stream.h>
+#include <stdio.h>
+
+
+#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<in.count(); ++i)
+ cout << in[i] << ", ";
+ cout << endl;
+ QStringList result;
+ result << "one" << "two" << "three";
+ return result;
+}
+
+
+DCOPRef test_impl::DCOPRefArg(DCOPRef in)
+{
+ cout << "SERVER: DCOPRef in: " << in.app() << ", "
+ << in.object() << ", " << in.type() << endl;
+ return DCOPRef("application", "object", "type");
+}
diff --git a/dcopjava/tests/test_impl.h b/dcopjava/tests/test_impl.h
new file mode 100644
index 00000000..61986819
--- /dev/null
+++ b/dcopjava/tests/test_impl.h
@@ -0,0 +1,38 @@
+#include "test.h"
+
+
+class test_impl : virtual public test
+{
+public:
+
+ test_impl() : DCOPObject("test") {};
+
+ void noArg();
+
+ void asyncNoArg();
+
+ void oneArg(bool b);
+
+ bool returnFalse();
+
+ bool returnTrue();
+
+ short shortArg(short in);
+
+ int intArg(int in);
+
+ long longArg(long in);
+
+ float floatArg(float in);
+
+ double doubleArg(double in);
+
+ QString stringArg(QString in);
+
+ QCString cstringArg(QCString in);
+
+ QStringList stringListArg(QStringList in);
+
+ DCOPRef DCOPRefArg(DCOPRef in);
+
+};