summaryrefslogtreecommitdiffstats
path: root/khtml/java/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
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /khtml/java/tests
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.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/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khtml/java/tests')
-rw-r--r--khtml/java/tests/Makefile.am9
-rw-r--r--khtml/java/tests/badapplets/BadApplet.jarbin0 -> 7233 bytes
-rw-r--r--khtml/java/tests/badapplets/BadApplet.java202
-rw-r--r--khtml/java/tests/badapplets/applet.html14
-rw-r--r--khtml/java/tests/good_sites44
-rw-r--r--khtml/java/tests/testkjavaappletserver.cpp41
6 files changed, 310 insertions, 0 deletions
diff --git a/khtml/java/tests/Makefile.am b/khtml/java/tests/Makefile.am
new file mode 100644
index 000000000..ab392b874
--- /dev/null
+++ b/khtml/java/tests/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/khtml/java -I$(top_srcdir)/khtml \
+ -I$(top_srcdir) $(all_includes)
+
+check_PROGRAMS = testserver
+
+testserver_SOURCES = testkjavaappletserver.cpp
+testserver_LDADD = ../libkjava.la
+
+METASOURCES = AUTO
diff --git a/khtml/java/tests/badapplets/BadApplet.jar b/khtml/java/tests/badapplets/BadApplet.jar
new file mode 100644
index 000000000..fc9c274a2
--- /dev/null
+++ b/khtml/java/tests/badapplets/BadApplet.jar
Binary files differ
diff --git a/khtml/java/tests/badapplets/BadApplet.java b/khtml/java/tests/badapplets/BadApplet.java
new file mode 100644
index 000000000..c8217d256
--- /dev/null
+++ b/khtml/java/tests/badapplets/BadApplet.java
@@ -0,0 +1,202 @@
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.*;
+import javax.swing.*;
+import java.io.*;
+import java.net.*;
+import java.awt.datatransfer.*;
+
+public class BadApplet extends JApplet {
+ JTabbedPane tabs = new JTabbedPane();
+ JPanel FileSystemTests = new JPanel();
+ JPanel NetworkTests = new JPanel();
+ JPanel EnvironmentTests = new JPanel();
+
+ JButton writeFileButton = new JButton("Write File");
+ JButton readFileButton = new JButton("Read File");
+ JButton connectSocketButton = new JButton("Connect Socket");
+ JButton frameButton = new JButton("Open Frame Without Warning Tag");
+ JButton readSystemPropButton = new JButton("Read System Property");
+ JButton printButton = new JButton("Print");
+ JButton clipBoardButton = new JButton("Read Clipboard");
+
+ JTextField writePath = new JTextField( "/amd/ns/root/home/sbarnes/test.txt" );
+ JTextField readPath = new JTextField("/amd/ns/root/home/sbarnes/test.txt");
+ JTextField url = new JTextField("URL");
+ JTextField port = new JTextField("port");
+ JTextField systemProp = new JTextField("os.name");
+ JTextField output = new JTextField();
+
+ //Construct the applet
+ public BadApplet() {
+ try {
+ //event handlers ******************************************************
+ writeFileButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ writeFileButton_actionPerformed(e);
+ }
+ });
+ readFileButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ readFileButton_actionPerformed(e);
+ }
+ });
+ connectSocketButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ connectSocketButton_actionPerformed(e);
+ }
+ });
+ frameButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ frameButton_actionPerformed(e);
+ }
+ });
+ readSystemPropButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ readSystemPropButton_actionPerformed(e);
+ }
+ });
+ printButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ printButton_actionPerformed(e);
+ }
+ });
+ clipBoardButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ clipBoard_actionPerformed(e);
+ }
+ });
+
+ //do layout ***********************************************************
+ getContentPane().setLayout( new BorderLayout() );
+
+ FileSystemTests.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ FileSystemTests.add( writeFileButton );
+ FileSystemTests.add( writePath );
+ FileSystemTests.add( readFileButton );
+ FileSystemTests.add( readPath );
+
+ NetworkTests.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ NetworkTests.add( connectSocketButton );
+ NetworkTests.add( url );
+ NetworkTests.add( port );
+
+ EnvironmentTests.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ EnvironmentTests.add( frameButton );
+ EnvironmentTests.add( readSystemPropButton );
+ EnvironmentTests.add( systemProp );
+ EnvironmentTests.add( printButton );
+ EnvironmentTests.add( clipBoardButton );
+
+ tabs.add( FileSystemTests, "File System" );
+ tabs.add( NetworkTests, "Network" );
+ tabs.add( EnvironmentTests, "Environment" );
+
+ this.getContentPane().add( tabs, BorderLayout.CENTER );
+ this.getContentPane().add( output, BorderLayout.SOUTH );
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void paint( Graphics g )
+ {
+ System.out.println( "graphics g = " + g );
+ System.out.println( "clip area = " + g.getClip() );
+ System.out.println( "bounds of the clip area = " + g.getClipBounds() );
+
+ super.paint( g );
+ }
+
+ //Initialize the applet
+ public void init() {}
+
+ void writeFileButton_actionPerformed(ActionEvent e) {
+ try{
+ PrintWriter writer = new PrintWriter(new FileOutputStream(writePath.getText()));
+ writer.println("Here is some text");
+ writer.close();
+ output.setText("Write was successful");
+ } catch (Exception ex){output.setText(ex.getMessage());}
+ }
+
+ void readSystemPropButton_actionPerformed(ActionEvent e) {
+ try{
+ output.setText(System.getProperty(systemProp.getText()));
+ } catch (Exception ex){output.setText("Error getting prop: " + ex.getMessage());}
+ }
+
+ void readFileButton_actionPerformed(ActionEvent e) {
+ try{
+ BufferedReader reader = new BufferedReader(new FileReader(readPath.getText()));
+ output.setText("Read was successful: " + reader.readLine());
+ } catch (Exception ex){output.setText(ex.getMessage());}
+ }
+
+ void connectSocketButton_actionPerformed(ActionEvent e) {
+ try{
+ Integer thePort = new Integer(port.getText());
+ Socket socket = new Socket(url.getText(), thePort.intValue());
+ socket.getOutputStream();
+ output.setText("Socket connection successful");
+ } catch (Exception ex){output.setText("Socket unsuccessfull: " + ex.getMessage());}
+ }
+
+ void frameButton_actionPerformed(ActionEvent e) {
+ JFrame frame = new JFrame("Does this Frame have a warning sign");
+ frame.setSize(200,200);
+ frame.show();
+ if (frame.getWarningString() == null)
+ output.setText("No warning string in frame");
+ else
+ output.setText(frame.getWarningString());
+ }
+
+ void clipBoard_actionPerformed(ActionEvent e) {
+ try {
+ Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
+
+ Transferable trans = clip.getContents(null);
+ if (trans == null){
+ output.setText("Clipboard is empty");
+ return;
+ }
+ output.setText((String)trans.getTransferData(DataFlavor.stringFlavor));
+ }catch(Exception ex){ex.getMessage();}
+ }
+
+ void printButton_actionPerformed(ActionEvent e) {
+ try{
+ JFrame testFrame = new JFrame("test");
+ testFrame.getContentPane().add(this, BorderLayout.CENTER);
+ PrintJob printer = Toolkit.getDefaultToolkit().getPrintJob(testFrame, "Applet Print Test", null);
+
+ if (printer == null){
+ output.setText("PrintJob is null");
+ return;
+ }
+
+ Graphics g = printer.getGraphics();
+ g.drawString("This is the applet print test", 50, 50);
+ g.dispose();
+ printer.end();
+ }catch(Exception ex){ex.getMessage();}
+ }
+
+ //Main method
+ public static void main(String[] args) {
+ BadApplet applet = new BadApplet();
+
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
+ frame.setTitle("Applet Frame");
+ frame.getContentPane().add(applet, BorderLayout.CENTER);
+ frame.setSize(400,320);
+ frame.setVisible(true);
+
+ applet.init();
+ applet.start();
+ }
+
+}
diff --git a/khtml/java/tests/badapplets/applet.html b/khtml/java/tests/badapplets/applet.html
new file mode 100644
index 000000000..fe9e47ef9
--- /dev/null
+++ b/khtml/java/tests/badapplets/applet.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <title>SwingSet demo</title>
+ </head>
+
+ <body>
+ <h1>SwingSet demo</h1>
+ <applet code=BadApplet.class
+ archive="BadApplet.jar"
+ width=695 height=525>
+ </applet>
+ </body>
+</html>
diff --git a/khtml/java/tests/good_sites b/khtml/java/tests/good_sites
new file mode 100644
index 000000000..f9699fe2a
--- /dev/null
+++ b/khtml/java/tests/good_sites
@@ -0,0 +1,44 @@
+http Sites
+---------------------------------------------------------
+http://java.sun.com/products/plugin/1.3.1_01a/demos/applets.html
+www.soda.co.uk
+java.sun.com
+www.javaboutique.com
+www.teledyn.com/fun/SaubleBeach (redraw problems, also in netscape)
+www.fxapplets.com
+www.quote.com/quotecom/livecharts/
+games.yahoo.com/games/klondike.html (security exception)
+www.webtrac.co.za/cgi-bin/demo/demo.pl (classloader problem)
+www.sodaplay.com/constructor/player.htm
+www.sodaplay.com
+www.dseffects.com/applets.html
+www.controlzed.com
+javaboutique.internet.com/Durius/
+www.chess.net/play/java
+www.kmelektronik.de/root/index.html
+rdufour.mytradecenter.com/applets/Tetris/Tetris.html
+http://www.shiatsu-austria.at
+
+currently unavailable:
+----------------------
+screening.nasdaq.com/screening/NASDAQSearch.asp
+
+unavailable:
+------------
+www.indegocomputer.de
+http://aktien.onvista.de/risk-return-map/
+
+https Sites
+---------------------------------------------------------
+https://brokerage-m3.consors.de/ConSors/
+https://homebanking.dvg-ka.de/045/index.html
+https://spk-ihb.izb-hb.de/SPK_Deggendorf/index.html
+https://www3.genodirekt.de/homebank.nsf/(rzbks)/xxq1050x?OpenDocument
+https://banking.sonline.de/kreissparkasse-duesseldorf/
+
+Security Test Sites
+---------------------------------------------------------
+http://java.sun.com/sfaq/#examples
+http://www.heise.de/ct/browsercheck/java.shtml
+http://www.heise.de/ct/browsercheck/n4demo1.shtml
+
diff --git a/khtml/java/tests/testkjavaappletserver.cpp b/khtml/java/tests/testkjavaappletserver.cpp
new file mode 100644
index 000000000..f0c5da19a
--- /dev/null
+++ b/khtml/java/tests/testkjavaappletserver.cpp
@@ -0,0 +1,41 @@
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <qstring.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "java/kjavaappletserver.h"
+#include "java/kjavaapplet.h"
+#include "java/kjavaappletwidget.h"
+
+static KCmdLineOptions options[] =
+{
+ { "+[kdelibs_path]", "path to kdelibs directory", 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KCmdLineArgs::init( argc, argv, "testKJASSever", "testKJASServer", "test program", "0.0" );
+
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+
+ QString path_to_kdelibs = "/build/wynnw/kde-src";
+
+ KJavaAppletWidget *a = new KJavaAppletWidget;
+
+ a->show();
+
+ a->applet()->setBaseURL( "file:" + path_to_kdelibs + "/kdelibs/khtml/test/" );
+ a->applet()->setAppletName( "Lake" );
+ a->applet()->setAppletClass( "lake.class" );
+ a->applet()->setParameter( "image", "konqi.gif" );
+
+ a->showApplet();
+ a->applet()->start();
+
+ app.exec();
+}