summaryrefslogtreecommitdiff
path: root/embeddedobj/qa
diff options
context:
space:
mode:
Diffstat (limited to 'embeddedobj/qa')
-rw-r--r--embeddedobj/qa/embedding/EmbeddingTest.java7
-rw-r--r--embeddedobj/qa/embedding/EmbeddingUnitTest.java91
-rw-r--r--embeddedobj/qa/embedding/Test01.java135
-rw-r--r--embeddedobj/qa/embedding/TestHelper.java36
-rw-r--r--embeddedobj/qa/embedding/makefile.mk84
5 files changed, 353 insertions, 0 deletions
diff --git a/embeddedobj/qa/embedding/EmbeddingTest.java b/embeddedobj/qa/embedding/EmbeddingTest.java
new file mode 100644
index 000000000000..bb57700abfed
--- /dev/null
+++ b/embeddedobj/qa/embedding/EmbeddingTest.java
@@ -0,0 +1,7 @@
+package complex.embedding;
+
+public interface EmbeddingTest
+{
+ boolean test();
+}
+
diff --git a/embeddedobj/qa/embedding/EmbeddingUnitTest.java b/embeddedobj/qa/embedding/EmbeddingUnitTest.java
new file mode 100644
index 000000000000..5f1b3f81c84a
--- /dev/null
+++ b/embeddedobj/qa/embedding/EmbeddingUnitTest.java
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex.embedding;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.lang.*;
+
+import complexlib.ComplexTestCase;
+
+import complex.embedding.*;
+
+import util.utils;
+import java.util.*;
+import java.io.*;
+
+/* This unit test for storage objects is designed to
+ * test most important statements from storage service
+ * specification.
+ *
+ * Regression tests are added to extend the tested
+ * functionalities.
+ */
+public class EmbeddingUnitTest extends ComplexTestCase
+{
+ private XMultiServiceFactory m_xMSF = null;
+
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "ExecuteTest01" };
+ }
+
+ public String getTestObjectName()
+ {
+ return "EmbeddingUnitTest";
+ }
+
+ public void before()
+ {
+ m_xMSF = (XMultiServiceFactory)param.getMSF();
+ if ( m_xMSF == null )
+ {
+ failed( "Can't create service factory!" );
+ return;
+ }
+ }
+
+ public void ExecuteTest01()
+ {
+ EmbeddingTest aTest = new Test01( m_xMSF, log );
+ assure( "Test01 failed!", aTest.test() );
+ }
+
+}
+
diff --git a/embeddedobj/qa/embedding/Test01.java b/embeddedobj/qa/embedding/Test01.java
new file mode 100644
index 000000000000..088500234abb
--- /dev/null
+++ b/embeddedobj/qa/embedding/Test01.java
@@ -0,0 +1,135 @@
+package complex.embedding;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XLoadable;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XShape;
+import com.sun.star.graphic.XGraphic;
+
+import com.sun.star.embed.*;
+
+import share.LogWriter;
+import complex.embedding.TestHelper;
+import complex.embedding.EmbeddingTest;
+
+public class Test01 implements EmbeddingTest {
+
+ XMultiServiceFactory m_xMSF;
+ TestHelper m_aTestHelper;
+
+ public Test01( XMultiServiceFactory xMSF, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_aTestHelper = new TestHelper( aLogWriter, "Test01: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ Object oDoc = m_xMSF.createInstance( "com.sun.star.comp.Draw.DrawingDocument" );
+ XLoadable xLoad = (XLoadable) UnoRuntime.queryInterface( XLoadable.class, oDoc );
+ if ( xLoad == null )
+ {
+ m_aTestHelper.Error( "Can not get XLoadable!" );
+ return false;
+ }
+
+ xLoad.initNew();
+
+ XDrawPagesSupplier xDPSupply = (XDrawPagesSupplier) UnoRuntime.queryInterface( XDrawPagesSupplier.class, oDoc );
+ if ( xDPSupply == null )
+ {
+ m_aTestHelper.Error( "Can not get XDrawPagesSupplier!" );
+ return false;
+ }
+
+ XDrawPages xDrawPages = xDPSupply.getDrawPages();
+ if ( xDrawPages == null )
+ {
+ m_aTestHelper.Error( "Can not get XDrawPages object!" );
+ return false;
+ }
+
+ if ( xDrawPages.getCount() == 0 )
+ {
+ m_aTestHelper.Error( "There must be at least one page in the document!" );
+ return false;
+ }
+
+ Object oPage = xDrawPages.getByIndex( 0 );
+ XDrawPage xPage = (XDrawPage) UnoRuntime.queryInterface( XDrawPage.class, oPage );
+ if ( xPage == null )
+ {
+ m_aTestHelper.Error( "Can not get access to drawing page!" );
+ return false;
+ }
+
+ XMultiServiceFactory xDrFactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class,
+ oDoc );
+ if ( xDrFactory == null )
+ {
+ m_aTestHelper.Error( "Can not get drawing factory!" );
+ return false;
+ }
+
+ Object oShape = xDrFactory.createInstance( "com.sun.star.drawing.OLE2Shape" );
+ XShape xShape = ( XShape ) UnoRuntime.queryInterface( XShape.class, oShape );
+ if ( xShape == null )
+ {
+ m_aTestHelper.Error( "Can not create new shape!" );
+ return false;
+ }
+
+ XPropertySet xShapeProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, oShape );
+ if ( xShapeProps == null )
+ {
+ m_aTestHelper.Error( "Can not get access to shapes properties!" );
+ return false;
+ }
+
+ xPage.add( xShape );
+ xShapeProps.setPropertyValue( "CLSID", "078B7ABA-54FC-457F-8551-6147e776a997" );
+
+ Object oEmbObj = xShapeProps.getPropertyValue( "EmbeddedObject" );
+ XEmbeddedObject xEmbObj = ( XEmbeddedObject ) UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+ if ( xEmbObj == null )
+ {
+ m_aTestHelper.Error( "Embedded object can not be accessed!" );
+ return false;
+ }
+
+ XEmbeddedClient xClient = xEmbObj.getClientSite();
+ if ( xClient == null )
+ {
+ m_aTestHelper.Error( "The client for the object must be set!" );
+ return false;
+ }
+
+ Object oReplacement = xShapeProps.getPropertyValue( "Graphic" );
+ XGraphic xReplGraph = ( XGraphic ) UnoRuntime.queryInterface( XGraphic.class, oReplacement );
+ if ( xReplGraph == null )
+ {
+ m_aTestHelper.Error( "The replacement graphic should be available!" );
+ return false;
+ }
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+}
+
diff --git a/embeddedobj/qa/embedding/TestHelper.java b/embeddedobj/qa/embedding/TestHelper.java
new file mode 100644
index 000000000000..fd0c26ebbc78
--- /dev/null
+++ b/embeddedobj/qa/embedding/TestHelper.java
@@ -0,0 +1,36 @@
+package complex.embedding;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.lang.*;
+import com.sun.star.embed.*;
+import com.sun.star.packages.*;
+import com.sun.star.io.*;
+import com.sun.star.beans.*;
+
+import share.LogWriter;
+
+public class TestHelper {
+
+ LogWriter m_aLogWriter;
+ String m_sTestPrefix;
+
+ public TestHelper( LogWriter aLogWriter, String sTestPrefix )
+ {
+ m_aLogWriter = aLogWriter;
+ m_sTestPrefix = sTestPrefix;
+ }
+
+ public void Error( String sError )
+ {
+ m_aLogWriter.println( m_sTestPrefix + "Error: " + sError );
+ }
+
+ public void Message( String sMessage )
+ {
+ m_aLogWriter.println( m_sTestPrefix + sMessage );
+ }
+}
+
diff --git a/embeddedobj/qa/embedding/makefile.mk b/embeddedobj/qa/embedding/makefile.mk
new file mode 100644
index 000000000000..78c6dfb8057d
--- /dev/null
+++ b/embeddedobj/qa/embedding/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..
+TARGET = EmbeddingUnitTest
+PRJNAME = embeddedobj
+PACKAGE = complex$/embedding
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+
+JAVAFILES =\
+ EmbeddingUnitTest.java\
+ EmbeddingTest.java\
+ TestHelper.java\
+ Test01.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE: target.mk
+
+RUN: run
+
+run:
+ java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+