summaryrefslogtreecommitdiffstats
path: root/kjsembed/tests
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/tests
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
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
Diffstat (limited to 'kjsembed/tests')
-rw-r--r--kjsembed/tests/TestApplet.java17
-rw-r--r--kjsembed/tests/dcop.js40
-rw-r--r--kjsembed/tests/plugin.js40
-rw-r--r--kjsembed/tests/test.js11
-rw-r--r--kjsembed/tests/test.pngbin0 -> 798 bytes
-rw-r--r--kjsembed/tests/test.ui111
-rw-r--r--kjsembed/tests/test2.js4
-rwxr-xr-xkjsembed/tests/test_args.js9
-rw-r--r--kjsembed/tests/test_arrays.js49
-rw-r--r--kjsembed/tests/test_childevent.js45
-rw-r--r--kjsembed/tests/test_connect.js11
-rw-r--r--kjsembed/tests/test_connectsignal.js14
-rw-r--r--kjsembed/tests/test_customslots.js17
-rw-r--r--kjsembed/tests/test_datetime.js14
-rwxr-xr-xkjsembed/tests/test_dcop_interface.js45
-rw-r--r--kjsembed/tests/test_dcop_isregistered.js19
-rw-r--r--kjsembed/tests/test_dcopref.js27
-rw-r--r--kjsembed/tests/test_dcopref2.js23
-rw-r--r--kjsembed/tests/test_dcopstart.js27
-rw-r--r--kjsembed/tests/test_dom.js22
-rwxr-xr-xkjsembed/tests/test_gc.js21
-rw-r--r--kjsembed/tests/test_image.js18
-rwxr-xr-xkjsembed/tests/test_kconfig.js40
-rwxr-xr-xkjsembed/tests/test_kio.js26
-rw-r--r--kjsembed/tests/test_kparts_args.js16
-rw-r--r--kjsembed/tests/test_kropart.js5
-rwxr-xr-xkjsembed/tests/test_nogui.js3
-rw-r--r--kjsembed/tests/test_pixmap_slots.js11
-rw-r--r--kjsembed/tests/test_point.js22
-rw-r--r--kjsembed/tests/test_popupmenu.js15
-rw-r--r--kjsembed/tests/test_qcanvas.js29
-rw-r--r--kjsembed/tests/test_qcombobox.js8
-rw-r--r--kjsembed/tests/test_qdir.js9
-rw-r--r--kjsembed/tests/test_qframe.js33
-rw-r--r--kjsembed/tests/test_qlistview.js30
-rwxr-xr-xkjsembed/tests/test_qtabctl.js26
-rw-r--r--kjsembed/tests/test_qtimeedit.js8
-rw-r--r--kjsembed/tests/test_qtimeedit2.js13
-rwxr-xr-xkjsembed/tests/test_qtoolbox.js22
-rw-r--r--kjsembed/tests/test_rect.js38
-rw-r--r--kjsembed/tests/test_shellexec.js44
-rw-r--r--kjsembed/tests/test_size.js22
-rw-r--r--kjsembed/tests/test_splashscreen.js16
-rw-r--r--kjsembed/tests/test_stdio.js29
-rw-r--r--kjsembed/tests/testkjsembed.cpp64
-rw-r--r--kjsembed/tests/thisfail.js37
46 files changed, 1150 insertions, 0 deletions
diff --git a/kjsembed/tests/TestApplet.java b/kjsembed/tests/TestApplet.java
new file mode 100644
index 00000000..7d4bbfda
--- /dev/null
+++ b/kjsembed/tests/TestApplet.java
@@ -0,0 +1,17 @@
+import java.awt.*;
+
+public class TestApplet extends javax.swing.JApplet {
+ String parameter;
+
+ public void init() {
+ parameter = getParameter( "TEXT" );
+ if( parameter == null )
+ parameter = "No value found";
+ }
+
+ public void paint( Graphics screen ) {
+ Graphics2D screen2D = (Graphics2D) screen;
+ screen2D.drawString( "I got value '" + parameter + "'.", 5, 50);
+ }
+
+}
diff --git a/kjsembed/tests/dcop.js b/kjsembed/tests/dcop.js
new file mode 100644
index 00000000..03e8ac87
--- /dev/null
+++ b/kjsembed/tests/dcop.js
@@ -0,0 +1,40 @@
+#!/usr/bin/env kjscmd
+
+println( "Hello World" );
+
+var d = new DCOPClient();
+
+if ( d.attach())
+{
+ println("Attached...");
+ if( d.isAttached() )
+ {
+ println( "send test..." )
+ if (d.send( "kded","kmilod", "displayText(QString)", "Test") )
+ println("send worked...");
+ else
+ println("send failed...");
+ println( "call test..." )
+ var dta = d.call( "kded","kmilod", "pollMilliSeconds()");
+ println( dta );
+ println( "call test with args" )
+ var dta = d.call( "KWeatherService","WeatherService", "wind(QString)", "KMKE");
+ println( dta );
+
+
+ var ref = d.call("rssservice", "RSSService", "add(QString)", "http://www.freshmeat.net/rdf.xml");
+ if( ref )
+ {
+ println( "Got ref");
+ var data = ref.call("maxAge()");
+ println(data);
+ }
+
+ }
+ else
+ println( "Error!" )
+}
+else
+ println("Failed...");
+
+println( "Done" );
diff --git a/kjsembed/tests/plugin.js b/kjsembed/tests/plugin.js
new file mode 100644
index 00000000..04d91a4f
--- /dev/null
+++ b/kjsembed/tests/plugin.js
@@ -0,0 +1,40 @@
+
+var plugins = Factory.listBindingPlugins();
+println("Currently Usable Plugins:");
+for ( var idx = 0; idx < plugins.length; ++idx)
+ println(plugins[idx]);
+
+try {
+var invalid1 = new NotReallyThere(this);
+}
+catch(ex) {
+println('Exception: '+ex);
+}
+
+var foo1 = new MyCustomObject(this);
+var foo2 = new MyCustomObject(this);
+
+foo1.setThing("Test");
+
+println( foo1.On );
+println( foo1.Off );
+
+foo2.setMode(foo2.On);
+foo2.setThing(foo2.thing());
+
+if( foo2.mode() == foo1.On )
+{
+ var foo3 = foo2;
+ println("Foo3 thing " + foo3.thing());
+
+}
+
+var foo4 = new MyCustomQObject(this);
+
+foo4.mode = foo4.On;
+foo4.thing = "Test";
+
+if( foo4.mode )
+{
+ println( foo4.thing );
+}
diff --git a/kjsembed/tests/test.js b/kjsembed/tests/test.js
new file mode 100644
index 00000000..1810c2b1
--- /dev/null
+++ b/kjsembed/tests/test.js
@@ -0,0 +1,11 @@
+print( "Hello World" )
+warn( "Beware World" )
+
+dlg = Factory.loadui( "test.ui" )
+dlg.caption = "Testing KJSEmbed"
+
+dlg.exec()
+
+print( "line=" + dlg.child("KLineEdit1").text )
+print( "date=" + dlg.child("DateEdit1").date )
+print( "time=" + dlg.child("TimeEdit1").time )
diff --git a/kjsembed/tests/test.png b/kjsembed/tests/test.png
new file mode 100644
index 00000000..257b90eb
--- /dev/null
+++ b/kjsembed/tests/test.png
Binary files differ
diff --git a/kjsembed/tests/test.ui b/kjsembed/tests/test.ui
new file mode 100644
index 00000000..fb9cdc26
--- /dev/null
+++ b/kjsembed/tests/test.ui
@@ -0,0 +1,111 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>Form1</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>297</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;h1&gt;Test Dialog&lt;/h1&gt;</string>
+ </property>
+ </widget>
+ <widget class="QDateEdit" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>DateEdit1</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Line edit:</string>
+ </property>
+ </widget>
+ <widget class="QTimeEdit" row="3" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TimeEdit1</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>KLineEdit1</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Date edit:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel2_4</cstring>
+ </property>
+ <property name="text">
+ <string>Time edit:</string>
+ </property>
+ </widget>
+ <spacer row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>161</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="4" column="2">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Close</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>Form1</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kjsembed/tests/test2.js b/kjsembed/tests/test2.js
new file mode 100644
index 00000000..8e633efb
--- /dev/null
+++ b/kjsembed/tests/test2.js
@@ -0,0 +1,4 @@
+
+print( "line=" + dlg.child("KLineEdit1").text )
+print( "date=" + dlg.child("DateEdit1").date )
+print( "time=" + dlg.child("TimeEdit1").time )
diff --git a/kjsembed/tests/test_args.js b/kjsembed/tests/test_args.js
new file mode 100755
index 00000000..5915cbf1
--- /dev/null
+++ b/kjsembed/tests/test_args.js
@@ -0,0 +1,9 @@
+#!/usr/local/kde/bin/kjscmd
+
+
+for ( var i = 0 ; i < application.args.length ; i++ ) {
+ println( 'Arg' + i + ': ' + application.args[i] );
+}
+
+part.view().show();
+application.exec();
diff --git a/kjsembed/tests/test_arrays.js b/kjsembed/tests/test_arrays.js
new file mode 100644
index 00000000..4f505d8a
--- /dev/null
+++ b/kjsembed/tests/test_arrays.js
@@ -0,0 +1,49 @@
+#!/usr/bin/env kjscmd
+
+var empty = [];
+var map1 = [];
+
+var array = ["Test A", "Test B", "Test C", "Test D"];
+var map2 = {"Test 1":"Test Map A", "Test 2":"Test Map B","Test 3":"Test Map C","Test 4":"Test Map D"};
+
+map1["Test 1"] = "Test Map A";
+map1["Test 2"] = "Test Map B";
+map2.length = 1;
+empty.length = 3;
+
+list = ["Test A"];
+list[3] = "Test B";
+list[5] = "Test C";
+list[7] = "Test D";
+
+println( "Sparse value 2:" + list[2] );
+try {
+ println( "Array: " + array.length );
+ println( "Array max value: " + array[array.length - 1] );
+} catch(x) { println( "Error: " + x); }
+
+try {
+ println( "Map1: " + map1.length );
+ println( "Map1 max value: " + map1[map1.length - 1] );
+} catch(x) { println( "Error: " + x); }
+
+try {
+ println( "Map2: " + map2.length );
+ println( "Map2 max value: " + map2[map2.length - 1] );
+} catch(x) { println( "Error: " + x); }
+
+try {
+ println( "List: " + list.length );
+ println( "List max value: " + list[list.length - 1] );
+} catch(x) { println( "Error: " + x); }
+
+try {
+ println( "Empty: " + empty.length );
+ println( "Empty max value: " + empty[empty.length - 1] );
+} catch(x) { println( "Error: " + x); }
+
+System.KJSConfig.writeListEntry("Test Array", array );
+System.KJSConfig.writeListEntry("Test Map1", map1 );
+System.KJSConfig.writeListEntry("Test Map2", map2 );
+System.KJSConfig.writeListEntry("Test List", list );
+System.KJSConfig.writeListEntry("Test Empty", empty ); \ No newline at end of file
diff --git a/kjsembed/tests/test_childevent.js b/kjsembed/tests/test_childevent.js
new file mode 100644
index 00000000..363f3492
--- /dev/null
+++ b/kjsembed/tests/test_childevent.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env kjscmd
+
+/**
+ * Test of QChildEvent handling. This example will not work at the moment
+ * because support for these events is disabled. The problem occurs because we
+ * reenter the interpreter if the object was created by js.
+ */
+
+var top = new QVBox();
+var hbox = new QHBox(top, 'button_hbox');
+var add = new QPushButton(hbox, 'add_button');
+var del = new QPushButton(hbox, 'del_button');
+
+add.text = 'Add';
+del.text = 'Delete';
+
+top.childInsertEvent = function(ev)
+{
+ println( 'Inserted!!!!!' );
+}
+
+top.childRemoveEvent = function(ev)
+{
+ println( 'Removed! ' + ev.className );
+}
+
+top.addSlot = function()
+{
+ l = new QLabel( this, 'demo_label' );
+ l.text = 'Hello World';
+ l.show();
+}
+
+top.delSlot = function()
+{
+ if ( top.childCount() > 2 ) {
+ top.child( top.childCount()-1 ).deleteLater();
+ }
+}
+
+top.connect( add, 'clicked()', top, 'addSlot' );
+top.connect( del, 'clicked()', top, 'delSlot' );
+
+top.show();
+application.exec();
diff --git a/kjsembed/tests/test_connect.js b/kjsembed/tests/test_connect.js
new file mode 100644
index 00000000..abeb14bb
--- /dev/null
+++ b/kjsembed/tests/test_connect.js
@@ -0,0 +1,11 @@
+var box = new QHBox( 'tree_view' );
+box.margin = 6;
+
+var led = new KLed( box );
+
+var btn = new QCheckBox(box);
+btn.text = 'Light'
+
+btn.connect( 'toggled(bool)', led, 'toggle()' );
+
+box.show();
diff --git a/kjsembed/tests/test_connectsignal.js b/kjsembed/tests/test_connectsignal.js
new file mode 100644
index 00000000..e0392375
--- /dev/null
+++ b/kjsembed/tests/test_connectsignal.js
@@ -0,0 +1,14 @@
+var box = new QHBox( 'tree_view' );
+box.margin = 6;
+
+var led = new KLed( box );
+var check = new QCheckBox(box);
+var check2 = new QCheckBox(box);
+
+check.text = 'Light';
+check2.text = 'Bounce';
+
+check.connect( 'toggled(bool)', led, 'toggle()' );
+check2.connect( 'toggled(bool)', check, 'toggled(bool)' );
+
+box.show();
diff --git a/kjsembed/tests/test_customslots.js b/kjsembed/tests/test_customslots.js
new file mode 100644
index 00000000..0c1dd05c
--- /dev/null
+++ b/kjsembed/tests/test_customslots.js
@@ -0,0 +1,17 @@
+#!/usr/bin/env kjscmd
+
+var dateTime = new QDateTimeEdit(this);
+dateTime.connect( dateTime, 'valueChanged(const QDateTime&)', this, 'changed');
+
+var jsDate = new Date();
+dateTime.setDateTime( jsDate );
+
+dateTime.show();
+application.exec();
+
+function changed( time )
+{
+ println( time.toString() );
+ println( jsDate.toString() );
+}
+
diff --git a/kjsembed/tests/test_datetime.js b/kjsembed/tests/test_datetime.js
new file mode 100644
index 00000000..b35853ad
--- /dev/null
+++ b/kjsembed/tests/test_datetime.js
@@ -0,0 +1,14 @@
+#!/usr/bin/env kjscmd
+
+var realDate = new Date();
+var dtEdit = new QDateTimeEdit(this);
+dtEdit.dateTime = realDate;
+
+var dt = dtEdit.dateTime;
+if( dt.toString() == realDate.toString() )
+ println( "Times match" );
+else
+{
+ println( "Time got " + dt.toString() );
+ println( "Time wanted " + realDate.toString() );
+}
diff --git a/kjsembed/tests/test_dcop_interface.js b/kjsembed/tests/test_dcop_interface.js
new file mode 100755
index 00000000..f0da8c27
--- /dev/null
+++ b/kjsembed/tests/test_dcop_interface.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env kjscmd
+
+function exitJavascript(exitValue )
+{
+ println("Exiting the javascript now with " + exitValue);
+ exit(exitValue);
+}
+
+function doSomthing( message, maxTimes )
+{
+ println( message + " " + maxTimes );
+ for( var times = 0; times < maxTimes; times++)
+ println(message);
+ return "Javascript said '" + message + "' " + maxTimes + " times.";
+}
+
+function test()
+{
+ println("this is a test");
+ return 1;
+}
+
+function pixmap(color)
+{
+ var pixmap = new Pixmap();
+ pixmap.resize( 25,25 );
+ pixmap.fill( color );
+ return pixmap;
+}
+
+function makeRef()
+{
+ var client = new DCOPClient();
+ var ref = new DCOPRef(client.appId(), "someInterface");
+ return ref;
+}
+
+var dcop = new DCOPInterface(this, "someInterface"); // Create the DCOP object.
+dcop.publish("void exitJavascript(int)"); // Publish a javascript function.
+dcop.publish("QString doSomthing(QString,int)"); // Publish another javascript function.
+dcop.publish("int test()");
+dcop.publish("QPixmap pixmap(QString)");
+dcop.publish("DCOPRef makeRef()");
+
+application.exec(); // Start the event loop
diff --git a/kjsembed/tests/test_dcop_isregistered.js b/kjsembed/tests/test_dcop_isregistered.js
new file mode 100644
index 00000000..c9f813da
--- /dev/null
+++ b/kjsembed/tests/test_dcop_isregistered.js
@@ -0,0 +1,19 @@
+#!/usr/bin/env kjscmd
+
+var d = new DCOPClient();
+
+if ( d.attach())
+{
+ println("Attached...");
+ if (!d.isApplicationRegistered( "kate" ) )
+ {
+ var appID = d.dcopStart("kate");
+ println( appID + " started" );
+ }
+ else
+ println( "its already registered" );
+}
+else
+ println("Failed...");
+
+println( "Done" );
diff --git a/kjsembed/tests/test_dcopref.js b/kjsembed/tests/test_dcopref.js
new file mode 100644
index 00000000..3576a4aa
--- /dev/null
+++ b/kjsembed/tests/test_dcopref.js
@@ -0,0 +1,27 @@
+#!/usr/bin/env kjscmd
+
+println( "Hello World" );
+
+var d = new DCOPClient();
+
+if ( d.attach())
+{
+ println("Attached...");
+ if( d.isAttached() )
+ {
+ var ref = d.call("kdesktop", "KDesktopIface", "background()");
+ if( ref )
+ {
+ println( "Got ref");
+ var data = ref.call("isCommon()");
+ println("Returned a : " + data);
+ }
+
+ }
+ else
+ println( "Error!" )
+}
+else
+ println("Failed...");
+
+println( "Done" );
diff --git a/kjsembed/tests/test_dcopref2.js b/kjsembed/tests/test_dcopref2.js
new file mode 100644
index 00000000..02cd3df3
--- /dev/null
+++ b/kjsembed/tests/test_dcopref2.js
@@ -0,0 +1,23 @@
+#!/usr/bin/env kjscmd
+
+println( "Hello World" );
+
+var d = new DCOPClient();
+
+if ( d.attach())
+{
+ println("Attached...");
+ if( d.isAttached() )
+ {
+ var ref = new DCOPRef();
+ ref.setRef( "KWeatherService", "WeatherService" );
+ println ( ref.call( "date(QString)", "KMKE") );
+
+ }
+ else
+ println( "Error!" )
+}
+else
+ println("Failed...");
+
+println( "Done" );
diff --git a/kjsembed/tests/test_dcopstart.js b/kjsembed/tests/test_dcopstart.js
new file mode 100644
index 00000000..e2dee415
--- /dev/null
+++ b/kjsembed/tests/test_dcopstart.js
@@ -0,0 +1,27 @@
+#!/usr/bin/env kjscmd
+
+var d = new DCOPClient();
+
+if ( d.attach())
+{
+ println("Attached...");
+ if( d.isAttached() )
+ {
+ var app = d.dcopStart("kwrite");
+ if( app != "" )
+ {
+ println( "Got ref");
+ var worked = d.send(app, "EditInterface#1","setText(QString)", "This is a test");
+ println("Returned a : " + worked);
+ }
+ else
+ println( "Error: no appname returned." );
+
+ }
+ else
+ println( "Error!" )
+}
+else
+ println("Failed...");
+
+println( "Done" );
diff --git a/kjsembed/tests/test_dom.js b/kjsembed/tests/test_dom.js
new file mode 100644
index 00000000..97188438
--- /dev/null
+++ b/kjsembed/tests/test_dom.js
@@ -0,0 +1,22 @@
+//
+// Tests the DOM methods
+//
+
+var box = console.getElementById('HBox');
+var btn = box.child('RunButton');
+
+print('Button: ');
+println(btn);
+
+println( 'Property: enabled' );
+print( 'hasAttribute: ' );
+println( btn.hasAttribute('enabled') );
+print( 'getAttribute: ' );
+println( btn.getAttribute('enabled') );
+print( 'setAttribute: ' );
+println( btn.setAttribute('enabled', false) );
+print( 'getAttribute: ' );
+println( btn.getAttribute('enabled') );
+
+println();
+println( 'Now the console will be displayed with button disabled' );
diff --git a/kjsembed/tests/test_gc.js b/kjsembed/tests/test_gc.js
new file mode 100755
index 00000000..aa1e11af
--- /dev/null
+++ b/kjsembed/tests/test_gc.js
@@ -0,0 +1,21 @@
+print( "Hello World" )
+var arr = new Array();
+
+for( var idx = 0; idx < 500; ++idx )
+{
+ arr[idx] = new QLabel(this);
+ arr[idx].text = "foo " + idx;
+}
+
+for( var idx = 0; idx < 500; ++idx )
+{
+ println( arr[idx].text );
+ arr[idx] = new QLabel(this);
+ arr[idx].text = "bar " + idx;
+}
+
+for( var idx = 0; idx < 500; ++idx )
+{
+ println( arr[idx].text );
+}
+
diff --git a/kjsembed/tests/test_image.js b/kjsembed/tests/test_image.js
new file mode 100644
index 00000000..309ff18f
--- /dev/null
+++ b/kjsembed/tests/test_image.js
@@ -0,0 +1,18 @@
+
+var img = new Image();
+var imgfx = new ImageFX();
+
+println( 'Trying to load an image...' );
+var result = img.load('test.png');
+println( 'Result: ' + result );
+
+println();
+println( 'Width=' + img.width() + ", " + 'Height=' + img.height() );
+
+println( 'Trying to charcoal the image...' );
+img = imgfx.charcoal(img, 2.0);
+img = imgfx.rotate( img, img.Rotate180 );
+
+println( 'Trying to save the image...' );
+var result2 = img.save('out.png');
+println( 'Result2: ' + result2 );
diff --git a/kjsembed/tests/test_kconfig.js b/kjsembed/tests/test_kconfig.js
new file mode 100755
index 00000000..519f13fb
--- /dev/null
+++ b/kjsembed/tests/test_kconfig.js
@@ -0,0 +1,40 @@
+#!/usr/bin/env kjscmd
+
+var confName = "jsconfigrc";
+var groupName = "Blah";
+
+var conf = new Config(this, confName);
+
+var grp = conf.group();
+
+println( "Group=" + grp );
+
+conf.setGroup(groupName);
+conf.writeColorEntry("Test Color", "blue");
+conf.writeListEntry("Test Array", ["A Value","B Value", "C Value"]);
+conf.writeEntry("Test Text", "this is a test");
+conf.sync();
+
+var newData = conf.readListEntry("Test Array");
+var newColor = conf.readColorEntry("Test Color");
+var newText = conf.readEntry("Test Text");
+println("Reread Active Config");
+println("Groups: " + conf.groupList());
+println(newData);
+println(newColor);
+println(newText);
+
+
+var newConf = new Config(this, confName);
+println("Reread Saved Config");
+println("Groups: " + newConf.groupList());
+newConf.setGroup(groupName);
+
+newData = newConf.readListEntry("Test Array");
+newColor = newConf.readColorEntry("Test Color", "red");
+newText = newConf.readEntry("Test Text", "Wrong Text");
+
+println(newData);
+println(newColor);
+println(newText);
+
diff --git a/kjsembed/tests/test_kio.js b/kjsembed/tests/test_kio.js
new file mode 100755
index 00000000..11bd6a1c
--- /dev/null
+++ b/kjsembed/tests/test_kio.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env kjscmd
+
+var net = new NetAccess( this, 'net' );
+
+var loc = '/tmp/test.jpg';
+
+var ret = net.download( 'http://www.kde.org/media/images/kde_logo.jpg', loc );
+
+if ( ret ) {
+ var mime = net.mimetype( loc );
+ print( "Mimetype = " + mime + '\n' );
+ var img = new Image();
+ img.load( loc );
+ if ( !img.isOk() ) {
+ warn( 'Failed to load image '+loc);
+ return;
+ } else {
+ print( 'Image ' + loc + ' is OK \n' );
+ }
+ var lbl = new QLabel(this);
+ lbl.pixmap = img.pixmap();
+ lbl.show();
+}
+
+net.del( loc );
+application.exec();
diff --git a/kjsembed/tests/test_kparts_args.js b/kjsembed/tests/test_kparts_args.js
new file mode 100644
index 00000000..aee1745e
--- /dev/null
+++ b/kjsembed/tests/test_kparts_args.js
@@ -0,0 +1,16 @@
+#!/usr/bin/env kjscmd
+
+var mw = new KMainWindow();
+var box = new QVBox( mw );
+mw.setCentralWidget( box );
+
+var args = [ "WIDTH=300", "HEIGHT=250", "CODE=TestApplet.class", "CLASSPATH=.", "TEXT=Foobar" ]
+var part = Factory.createROPart( "application/x-java-applet",
+ "'KParts/ReadOnlyPart' in ServiceTypes",
+ box, "foobar",
+ args );
+
+part.openURL( "./TestApplet.class" );
+
+mw.show();
+application.exec();
diff --git a/kjsembed/tests/test_kropart.js b/kjsembed/tests/test_kropart.js
new file mode 100644
index 00000000..1e2d4344
--- /dev/null
+++ b/kjsembed/tests/test_kropart.js
@@ -0,0 +1,5 @@
+var box = new QHBox( this );
+var view = Factory.createROPart( "cat", box, "view" );
+
+box.show();
+application.exec();
diff --git a/kjsembed/tests/test_nogui.js b/kjsembed/tests/test_nogui.js
new file mode 100755
index 00000000..e7002ec4
--- /dev/null
+++ b/kjsembed/tests/test_nogui.js
@@ -0,0 +1,3 @@
+#!/usr/bin/env kjscmd
+
+println( 'Script executed ok' );
diff --git a/kjsembed/tests/test_pixmap_slots.js b/kjsembed/tests/test_pixmap_slots.js
new file mode 100644
index 00000000..f2ca40fa
--- /dev/null
+++ b/kjsembed/tests/test_pixmap_slots.js
@@ -0,0 +1,11 @@
+#!/usr/bin/env kjscmd
+
+var img = new Image();
+img.load("test.png");
+
+var pix = img.pixmap();
+var btn = new QToolButton(this);
+btn.pixmap = pix;
+btn.setIcon( pix );
+btn.show();
+application.exec();
diff --git a/kjsembed/tests/test_point.js b/kjsembed/tests/test_point.js
new file mode 100644
index 00000000..6c4bae57
--- /dev/null
+++ b/kjsembed/tests/test_point.js
@@ -0,0 +1,22 @@
+
+var x = 10;
+var y = 10;
+
+var point = new Point(x,y);
+var point2 = new Point();
+point2.setX(point.x());
+point2.setY(point.y());
+
+if( point.x() != x )
+{
+ println( "X not "+ x +" " + point.x());
+ exit(1);
+}
+
+if( point.y() != y )
+{
+ println( "Y not "+ y +" " + point.y());
+ exit(1);
+}
+
+println( "All tests passed"); \ No newline at end of file
diff --git a/kjsembed/tests/test_popupmenu.js b/kjsembed/tests/test_popupmenu.js
new file mode 100644
index 00000000..6d60231c
--- /dev/null
+++ b/kjsembed/tests/test_popupmenu.js
@@ -0,0 +1,15 @@
+#!/usr/bin/env kjscmd
+var menu = new QPopupMenu(this);
+var subMenu = new QPopupMenu(menu);
+var pix = new Pixmap();
+pix.resize(12,12);
+pix.fill("blue");
+
+menu.insertItem("Test");
+menu.insertItem(pix, "Test pix");
+
+subMenu.insertItem("Test Sub", menu);
+subMenu.insertItem(pix, "Test sub pix", menu);
+
+menu.show();
+application.exec();
diff --git a/kjsembed/tests/test_qcanvas.js b/kjsembed/tests/test_qcanvas.js
new file mode 100644
index 00000000..c5ffd7f9
--- /dev/null
+++ b/kjsembed/tests/test_qcanvas.js
@@ -0,0 +1,29 @@
+#!/usr/bin/env kjscmd
+
+c = new QCanvas();
+
+item = new QCanvasText( '<font="blue">hi</font>', c );
+item.move( 50, 50 );
+item.show();
+
+item = new QCanvasText( '<font="blue">hi</font>', c );
+item.move( 150, 50 );
+item.show();
+
+item = new QCanvasText( '<font="blue">hixxx</font>', c );
+item.move( 50, 150 );
+item.show();
+
+item = new QCanvasText( '<font="blue">hixxxxxxx</font>', c );
+item.move( 150, 150 );
+item.show();
+
+view = new QCanvasView();
+view.setCanvas( c );
+
+view.update();
+view.show();
+
+//load( '../docs/examples/docviewer/docviewer.js' );
+
+application.exec();
diff --git a/kjsembed/tests/test_qcombobox.js b/kjsembed/tests/test_qcombobox.js
new file mode 100644
index 00000000..03111692
--- /dev/null
+++ b/kjsembed/tests/test_qcombobox.js
@@ -0,0 +1,8 @@
+var h=new QHBox(this);
+var combo = new QComboBox(h, "combo");
+combo.insertItem("Item 1");
+combo.insertItem("Item 2");
+combo.insertItem("Item 3");
+combo.insertItem("Item 4");
+h.show();
+application.exec();
diff --git a/kjsembed/tests/test_qdir.js b/kjsembed/tests/test_qdir.js
new file mode 100644
index 00000000..c51f15e0
--- /dev/null
+++ b/kjsembed/tests/test_qdir.js
@@ -0,0 +1,9 @@
+#!/usr/bin/env kjscmd
+
+var dir = new QDir(); // CWD
+println( dir.path() );
+
+var files = dir.entryList( '*.js' );
+for ( i in files ) {
+ println( files[i] );
+}
diff --git a/kjsembed/tests/test_qframe.js b/kjsembed/tests/test_qframe.js
new file mode 100644
index 00000000..218b2e7f
--- /dev/null
+++ b/kjsembed/tests/test_qframe.js
@@ -0,0 +1,33 @@
+#!/usr/bin/env kjscmd
+var mw = new KMainWindow(this);
+var hbox = new QHBox( mw );
+
+var f1 = new QLabel( hbox );
+f1.frameShape = QLabel.Box;
+f1.frameShadow = QLabel.Raised;
+f1.lineWidth = 4;
+f1.margin = 4;
+f1.midLineWidth = 1;
+f1.paletteBackgroundColor = "red";
+f1.text = "Frame 1";
+
+var f2 = new QLabel( hbox );
+f2.frameShape = QLabel.WinPanel;
+f2.frameShadow = QLabel.Sunken;
+f2.lineWidth = 4;
+f2.margin = 4;
+f2.midLineWidth = 1;
+f2.paletteBackgroundColor = "white";
+f2.text = "Frame 2";
+
+var f3 = new QLabel( hbox );
+f3.frameShape = QLabel.Box;
+f3.lineWidth = 4;
+f3.margin = 4;
+f3.midLineWidth = 1;
+f3.paletteBackgroundColor = "blue";
+f3.text = "Frame 3";
+
+mw.setCentralWidget(hbox);
+mw.show();
+application.exec();
diff --git a/kjsembed/tests/test_qlistview.js b/kjsembed/tests/test_qlistview.js
new file mode 100644
index 00000000..2f8f37bf
--- /dev/null
+++ b/kjsembed/tests/test_qlistview.js
@@ -0,0 +1,30 @@
+var lv = new QListView();
+lv.rootIsDecorated = true;
+lv.addColumn('Name');
+lv.addColumn('Description');
+
+var i = new QListViewItem( lv );
+i.setText( 0, 'One' );
+i.setText( 1, 'First item' );
+
+var j = new QListViewItem( lv );
+j.setText( 0, 'Two' );
+j.setText( 1, 'Second item' );
+
+var k = new QListViewItem( i );
+k.setText( 0, 'Three' );
+k.setText( 1, 'Third item' );
+
+var l = new QCheckListItem( lv );
+l.setText(0, 'Four' );
+
+lv.show();
+
+var lvi = lv.firstChild();
+while( lvi )
+{
+ println( lvi.text(0) );
+ lvi = lvi.nextSibling();
+}
+
+application.exec();
diff --git a/kjsembed/tests/test_qtabctl.js b/kjsembed/tests/test_qtabctl.js
new file mode 100755
index 00000000..60eebfdf
--- /dev/null
+++ b/kjsembed/tests/test_qtabctl.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env kjscmd
+
+var vbox = new QVBox();
+var tw = new QTabWidget(vbox);
+var okButton = new QToolButton(vbox);
+
+okButton.text = "Ok";
+
+var c1 = new QToolButton( tw );
+var c2 = new QToolButton( tw );
+
+function tabchanged(q) {
+ alert( "Tab Changed, " + q.text );
+}
+
+c1.text = "Tab1's button";
+c2.text = "Tab2's button";
+
+tw.addTab(c1, "1");
+tw.addTab(c2, "2");
+
+vbox.connect(tw, "currentChanged(QWidget*)", this, "tabchanged");
+vbox.connect(okButton, "clicked()", this, "exit");
+vbox.show();
+
+application.exec();
diff --git a/kjsembed/tests/test_qtimeedit.js b/kjsembed/tests/test_qtimeedit.js
new file mode 100644
index 00000000..632c4929
--- /dev/null
+++ b/kjsembed/tests/test_qtimeedit.js
@@ -0,0 +1,8 @@
+var h = new QHBox(this);
+var dt = new QTimeEdit(h, 'tc');
+var n = new Date(); // now
+
+dt.time = n; // set the control to now
+var t = dt.time; // get the time out
+
+println( t.getHours().toString()+':'+t.getMinutes().toString()); // always puts out 23:59
diff --git a/kjsembed/tests/test_qtimeedit2.js b/kjsembed/tests/test_qtimeedit2.js
new file mode 100644
index 00000000..825fa10f
--- /dev/null
+++ b/kjsembed/tests/test_qtimeedit2.js
@@ -0,0 +1,13 @@
+var vbox=new QVBox();
+var te=new QTimeEdit(vbox);
+var okButton=new QToolButton(vbox);
+okButton.text="Ok";
+
+function TimeChanged(q) {
+ alert("Time Changed: " +q);
+}
+
+vbox.connect(te, "valueChanged(const QTime&)", this, "TimeChanged");
+vbox.connect(okButton, "clicked()", this, "exit");
+vbox.show();
+application.exec();
diff --git a/kjsembed/tests/test_qtoolbox.js b/kjsembed/tests/test_qtoolbox.js
new file mode 100755
index 00000000..c56e1d4a
--- /dev/null
+++ b/kjsembed/tests/test_qtoolbox.js
@@ -0,0 +1,22 @@
+#!/usr/bin/env kjscmd
+
+var vbox = new QVBox(this);
+var tb = new QToolBox(vbox);
+
+var c1 = new QPushButton( tb );
+var c2 = new QPushButton( tb );
+
+function itemchanged(idx) {
+ alert( "Tab Changed, " + tb.item(idx).text );
+}
+
+c1.text = "Tab1's button";
+c2.text = "Tab2's button";
+
+tb.addItem(c1, "1");
+tb.addItem(c2, "2");
+
+vbox.connect(tb, "currentChanged(int)", this, "itemchanged");
+vbox.show();
+
+application.exec();
diff --git a/kjsembed/tests/test_rect.js b/kjsembed/tests/test_rect.js
new file mode 100644
index 00000000..24f8cc69
--- /dev/null
+++ b/kjsembed/tests/test_rect.js
@@ -0,0 +1,38 @@
+
+var x = 10;
+var y = 10;
+var w = 25;
+var h = 25;
+
+var rect = new Rect(x,y,w,h);
+var rect2 = new Rect();
+rect2.setX(rect.x());
+rect2.setY(rect.y());
+rect2.setHeight(rect.height());
+rect2.setWidth(rect.width());
+
+if( rect.x() != x )
+{
+ println( "X not "+ x +" " + rect.x());
+ exit(1);
+}
+
+if( rect.y() != y )
+{
+ println( "Y not "+ y +" " + rect.y());
+ exit(1);
+}
+
+if( rect.width() != w )
+{
+ println( "W not "+ w +" " + rect.width());
+ exit(1);
+}
+
+if( rect.height() != h )
+{
+ println( "H not "+ h +" " + rect.height());
+ exit(1);
+}
+
+println( "All tests passed"); \ No newline at end of file
diff --git a/kjsembed/tests/test_shellexec.js b/kjsembed/tests/test_shellexec.js
new file mode 100644
index 00000000..51a2fbdd
--- /dev/null
+++ b/kjsembed/tests/test_shellexec.js
@@ -0,0 +1,44 @@
+#!/usr/bin/env kjscmd
+
+println( "Hello World" );
+var proc = new Process(this);
+proc.connect( proc, "readyReadStdout()", this, "stdOut" );
+proc.connect( proc, "readyReadStderr()", this, "stdError" );
+proc.connect( proc, "processExited()", this, "done" );
+
+proc.addArgument("ps");
+proc.addArgument("-l");
+
+if ( !proc.start() )
+{
+ println( "Could not start process" );
+}
+
+println( "test single cmd" );
+
+var output = shell("ps aux");
+println( "Shell responds: " + output );
+
+application.exec();
+
+function done()
+{
+ while ( proc.canReadLineStdout )
+ stdOut();
+ while ( proc.canReadLineStderr )
+ stdError();
+ println("Process done with " + proc.exitStatus );
+ exit(0);
+}
+
+function stdError( )
+{
+ var errorMessage = proc.readLineStderr();
+ println( "StdErr: " + errorMessage );
+}
+
+function stdOut( )
+{
+ var message = proc.readLineStdout();
+ println( "StdOut: " + message );
+} \ No newline at end of file
diff --git a/kjsembed/tests/test_size.js b/kjsembed/tests/test_size.js
new file mode 100644
index 00000000..511b3530
--- /dev/null
+++ b/kjsembed/tests/test_size.js
@@ -0,0 +1,22 @@
+
+var w = 25;
+var h = 25;
+
+var size = new Size(w,h);
+var size2 = new Size();
+size2.setHeight(size.height());
+size2.setWidth(size.width());
+
+if( size.width() != w )
+{
+ println( "W not "+ w +" " + size.width());
+ exit(1);
+}
+
+if( size.height() != h )
+{
+ println( "H not "+ h +" " + size.height());
+ exit(1);
+}
+
+println( "All tests passed");
diff --git a/kjsembed/tests/test_splashscreen.js b/kjsembed/tests/test_splashscreen.js
new file mode 100644
index 00000000..bb465df0
--- /dev/null
+++ b/kjsembed/tests/test_splashscreen.js
@@ -0,0 +1,16 @@
+var lab = new QLabel(this);
+var splash = new QSplashScreen(this);
+var pix = new Pixmap();
+pix.resize(128,128);
+pix.fill("blue");
+
+splash.setPixmap( pix );
+splash.show();
+for( var x = 0; x < 1000; ++x)
+{
+ splash.message("Count: " + x);
+ lab.text = "Count: " + x;
+}
+lab.show();
+splash.finish(lab);
+application.exec();
diff --git a/kjsembed/tests/test_stdio.js b/kjsembed/tests/test_stdio.js
new file mode 100644
index 00000000..932f7496
--- /dev/null
+++ b/kjsembed/tests/test_stdio.js
@@ -0,0 +1,29 @@
+#!/usr/bin/env kjscmd
+
+println( '==============================' );
+
+println( 'Text with newline' );
+System.stdout.println( 'Text with newline' );
+
+System.stdout.print( 'There should be an OK after the colon: ' );
+System.stdout.println( 'OK' );
+
+System.stdout.println( 'stdin is readable: ' + System.stdin.isReadable() );
+System.stdout.println( 'stdin is writable: ' + System.stdin.isWritable() );
+
+System.stdout.println( 'stdout is readable: ' + System.stdout.isReadable() );
+System.stdout.println( 'stdout is writable: ' + System.stdout.isWritable() );
+
+System.stdout.println( 'stderr is readable: ' + System.stderr.isReadable() );
+System.stdout.println( 'stderr is writable: ' + System.stderr.isWritable() );
+
+System.stdout.println( 'There should be an exception now: ' );
+System.stdin.println( 'INVALID' );
+
+System.stdout.println( 'There should be another exception: ' );
+System.stdout.readLine( 'INVALID' );
+
+println( '==============================' );
+System.stdout.println( dump(System.stdin) );
+
+System.exit(0);
diff --git a/kjsembed/tests/testkjsembed.cpp b/kjsembed/tests/testkjsembed.cpp
new file mode 100644
index 00000000..8cb33adc
--- /dev/null
+++ b/kjsembed/tests/testkjsembed.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2001-2002, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <kjs/interpreter.h>
+
+#include <kjsembed/jsconsolewidget.h>
+#include <kjsembed/jsobjectproxy.h>
+#include <kjsembed/dialogfactory.h>
+#include <kjsembed/factory.h>
+#include <kjsembed/securitypolicy.h>
+
+using namespace KJSEmbed;
+
+int main( int argc, char **argv )
+{
+ KAboutData about( "test-kjsembed", I18N_NOOP("KJS Embed Test"), "0.1",
+ I18N_NOOP("Test"),
+ KAboutData::License_LGPL, I18N_NOOP("(c) 2001-2002 Richard Moore") );
+ KCmdLineArgs::init( argc, argv, &about );
+ KApplication app;
+
+ // Setup Interpreter
+ KJS::Interpreter *js = Factory::defaultJS();
+ KJS::Object global = js->globalObject();
+
+ // Create Console
+ JSConsoleWidget *console = new JSConsoleWidget( js );
+
+ console->addBindings( global );
+ Factory::publish( &app, js, global, "app" );
+ Factory::publish( console, js, global, "console" );
+
+ // Setup Window
+ app.setMainWidget( console );
+ app.connect( &app, SIGNAL( lastWindowClosed() ), SLOT(quit()) );
+ console->resize( 600, 450 );
+ console->show();
+
+ return app.exec();
+}
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/tests/thisfail.js b/kjsembed/tests/thisfail.js
new file mode 100644
index 00000000..081d274e
--- /dev/null
+++ b/kjsembed/tests/thisfail.js
@@ -0,0 +1,37 @@
+
+var dcop = new Dcop(this);
+dcop.attach();
+
+println("this works");
+var foo = dcop.registeredApplications();
+println(foo);
+
+var s = this;
+//var s = foo;
+//var s = dcop;
+//var s = Factory;
+
+println("1this works");
+try {
+println(dump(s));
+}
+catch(y) {
+println('yyyyyy failed ' + y);
+}
+
+println("22this works"+s);
+try {
+dump(s);
+}
+catch(x) {
+println('xxxxxxxx failed ' + x);
+}
+
+println("2this works");
+dumpCompletion(s);
+println("/2this works");
+
+println("3this fails");
+var bar = dumpCompletion(s);
+println( typeof(bar) );
+println("done -------------");