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 --- kjsembed/tests/TestApplet.java | 17 +++++ kjsembed/tests/dcop.js | 40 +++++++++++ kjsembed/tests/plugin.js | 40 +++++++++++ kjsembed/tests/test.js | 11 +++ kjsembed/tests/test.png | Bin 0 -> 798 bytes kjsembed/tests/test.ui | 111 +++++++++++++++++++++++++++++++ kjsembed/tests/test2.js | 4 ++ kjsembed/tests/test_args.js | 9 +++ kjsembed/tests/test_arrays.js | 49 ++++++++++++++ kjsembed/tests/test_childevent.js | 45 +++++++++++++ kjsembed/tests/test_connect.js | 11 +++ kjsembed/tests/test_connectsignal.js | 14 ++++ kjsembed/tests/test_customslots.js | 17 +++++ kjsembed/tests/test_datetime.js | 14 ++++ kjsembed/tests/test_dcop_interface.js | 45 +++++++++++++ kjsembed/tests/test_dcop_isregistered.js | 19 ++++++ kjsembed/tests/test_dcopref.js | 27 ++++++++ kjsembed/tests/test_dcopref2.js | 23 +++++++ kjsembed/tests/test_dcopstart.js | 27 ++++++++ kjsembed/tests/test_dom.js | 22 ++++++ kjsembed/tests/test_gc.js | 21 ++++++ kjsembed/tests/test_image.js | 18 +++++ kjsembed/tests/test_kconfig.js | 40 +++++++++++ kjsembed/tests/test_kio.js | 26 ++++++++ kjsembed/tests/test_kparts_args.js | 16 +++++ kjsembed/tests/test_kropart.js | 5 ++ kjsembed/tests/test_nogui.js | 3 + kjsembed/tests/test_pixmap_slots.js | 11 +++ kjsembed/tests/test_point.js | 22 ++++++ kjsembed/tests/test_popupmenu.js | 15 +++++ kjsembed/tests/test_qcanvas.js | 29 ++++++++ kjsembed/tests/test_qcombobox.js | 8 +++ kjsembed/tests/test_qdir.js | 9 +++ kjsembed/tests/test_qframe.js | 33 +++++++++ kjsembed/tests/test_qlistview.js | 30 +++++++++ kjsembed/tests/test_qtabctl.js | 26 ++++++++ kjsembed/tests/test_qtimeedit.js | 8 +++ kjsembed/tests/test_qtimeedit2.js | 13 ++++ kjsembed/tests/test_qtoolbox.js | 22 ++++++ kjsembed/tests/test_rect.js | 38 +++++++++++ kjsembed/tests/test_shellexec.js | 44 ++++++++++++ kjsembed/tests/test_size.js | 22 ++++++ kjsembed/tests/test_splashscreen.js | 16 +++++ kjsembed/tests/test_stdio.js | 29 ++++++++ kjsembed/tests/testkjsembed.cpp | 64 ++++++++++++++++++ kjsembed/tests/thisfail.js | 37 +++++++++++ 46 files changed, 1150 insertions(+) create mode 100644 kjsembed/tests/TestApplet.java create mode 100644 kjsembed/tests/dcop.js create mode 100644 kjsembed/tests/plugin.js create mode 100644 kjsembed/tests/test.js create mode 100644 kjsembed/tests/test.png create mode 100644 kjsembed/tests/test.ui create mode 100644 kjsembed/tests/test2.js create mode 100755 kjsembed/tests/test_args.js create mode 100644 kjsembed/tests/test_arrays.js create mode 100644 kjsembed/tests/test_childevent.js create mode 100644 kjsembed/tests/test_connect.js create mode 100644 kjsembed/tests/test_connectsignal.js create mode 100644 kjsembed/tests/test_customslots.js create mode 100644 kjsembed/tests/test_datetime.js create mode 100755 kjsembed/tests/test_dcop_interface.js create mode 100644 kjsembed/tests/test_dcop_isregistered.js create mode 100644 kjsembed/tests/test_dcopref.js create mode 100644 kjsembed/tests/test_dcopref2.js create mode 100644 kjsembed/tests/test_dcopstart.js create mode 100644 kjsembed/tests/test_dom.js create mode 100755 kjsembed/tests/test_gc.js create mode 100644 kjsembed/tests/test_image.js create mode 100755 kjsembed/tests/test_kconfig.js create mode 100755 kjsembed/tests/test_kio.js create mode 100644 kjsembed/tests/test_kparts_args.js create mode 100644 kjsembed/tests/test_kropart.js create mode 100755 kjsembed/tests/test_nogui.js create mode 100644 kjsembed/tests/test_pixmap_slots.js create mode 100644 kjsembed/tests/test_point.js create mode 100644 kjsembed/tests/test_popupmenu.js create mode 100644 kjsembed/tests/test_qcanvas.js create mode 100644 kjsembed/tests/test_qcombobox.js create mode 100644 kjsembed/tests/test_qdir.js create mode 100644 kjsembed/tests/test_qframe.js create mode 100644 kjsembed/tests/test_qlistview.js create mode 100755 kjsembed/tests/test_qtabctl.js create mode 100644 kjsembed/tests/test_qtimeedit.js create mode 100644 kjsembed/tests/test_qtimeedit2.js create mode 100755 kjsembed/tests/test_qtoolbox.js create mode 100644 kjsembed/tests/test_rect.js create mode 100644 kjsembed/tests/test_shellexec.js create mode 100644 kjsembed/tests/test_size.js create mode 100644 kjsembed/tests/test_splashscreen.js create mode 100644 kjsembed/tests/test_stdio.js create mode 100644 kjsembed/tests/testkjsembed.cpp create mode 100644 kjsembed/tests/thisfail.js (limited to 'kjsembed/tests') 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 Binary files /dev/null and b/kjsembed/tests/test.png 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 @@ + +Form1 + + + Form1 + + + + 0 + 0 + 403 + 297 + + + + + unnamed + + + 11 + + + 6 + + + + TextLabel1 + + + <h1>Test Dialog</h1> + + + + + DateEdit1 + + + + + TextLabel2 + + + Line edit: + + + + + TimeEdit1 + + + + + KLineEdit1 + + + + + TextLabel2_3 + + + Date edit: + + + + + TextLabel2_4 + + + Time edit: + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 161 + 20 + + + + + + pushButton1 + + + &Close + + + + + + + pushButton1 + clicked() + Form1 + accept() + + + + + klineedit.h + + 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( 'hi', c ); +item.move( 50, 50 ); +item.show(); + +item = new QCanvasText( 'hi', c ); +item.move( 150, 50 ); +item.show(); + +item = new QCanvasText( 'hixxx', c ); +item.move( 50, 150 ); +item.show(); + +item = new QCanvasText( 'hixxxxxxx', 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 + * + * 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +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 -------------"); -- cgit v1.2.1