diff options
Diffstat (limited to 'sw/qa/complex/checkColor')
-rwxr-xr-x | sw/qa/complex/checkColor/CheckChangeColor.java | 90 | ||||
-rwxr-xr-x | sw/qa/complex/checkColor/makefile.mk | 75 |
2 files changed, 165 insertions, 0 deletions
diff --git a/sw/qa/complex/checkColor/CheckChangeColor.java b/sw/qa/complex/checkColor/CheckChangeColor.java new file mode 100755 index 000000000000..8a8c563c7eea --- /dev/null +++ b/sw/qa/complex/checkColor/CheckChangeColor.java @@ -0,0 +1,90 @@ +package complex.checkColor; + +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.Size; +import com.sun.star.awt.WindowDescriptor; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XController; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; +import complexlib.ComplexTestCase; +import java.io.PrintWriter; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +/** + * Created because of complaint on dev@openoffice.org: check the changing of + * BackColor and IsLandscape properties on the PageStyle service. + */ +public class CheckChangeColor extends ComplexTestCase { + + private XToolkit xToolkit = null; + private XWindowPeer xWinPeer = null; + + /** + * Get all test method names. + * @return The test methods. + */ + public String[] getTestMethodNames() { + return new String[] {"checkChangeColor"}; + } + + + /** + * Check BackColor and IsLandscape properties, wait for an exception: test + * is ok if no exception happened. + */ + public void checkChangeColor() { + try { + XMultiServiceFactory m_xMSF_ = (XMultiServiceFactory)param.getMSF(); + XComponentLoader aLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,m_xMSF_.createInstance( "com.sun.star.frame.Desktop" )); + XComponent xDocument = (XComponent)UnoRuntime.queryInterface(XComponent.class, aLoader.loadComponentFromURL( "private:factory/swriter", "_blank", 0, new PropertyValue[ 0 ] ) ); + // xDocument.addEventListener( this ); + + XTextDocument oDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocument); + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc ); + + // XInterface xInterface = (XInterface) oDocMSF.createInstance( "com.sun.star.style.PageStyle" ); + + // create a supplier to get the Style family collection + XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, oDoc ); + + // get the NameAccess interface from the Style family collection + XNameAccess xNameAccess = xSupplier.getStyleFamilies(); + + XNameContainer xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" )); + + // create a PropertySet to set the properties for the new Pagestyle + XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") ); + + log.println("BackColor @ "+xPropertySet.getPropertyValue("BackColor").toString()); + log.println("IsLandscape @ "+xPropertySet.getPropertyValue("IsLandscape").toString()); + log.println("Size @ H:"+((Size)xPropertySet.getPropertyValue("Size")).Height+" W:"+((Size)xPropertySet.getPropertyValue("Size")).Width); + + log.println("Set Landscape"); + xPropertySet.setPropertyValue("IsLandscape",new Boolean(true) ); + log.println("Set BackColor"); + xPropertySet.setPropertyValue("BackColor",new Integer((int)255000000) ); + } + catch(Exception e) { + e.printStackTrace(); + failed("Exception."); + } + } +} diff --git a/sw/qa/complex/checkColor/makefile.mk b/sw/qa/complex/checkColor/makefile.mk new file mode 100755 index 000000000000..3048fb8fff95 --- /dev/null +++ b/sw/qa/complex/checkColor/makefile.mk @@ -0,0 +1,75 @@ +#************************************************************************* +# +# 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 = CheckChangeColor +PRJNAME = $(TARGET) +PACKAGE = complex$/checkColor + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar +JAVAFILES = CheckChangeColor.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 -------------------------------------- + +# 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 ------------------------------------------------------ + +.IF "$(depend)" == "" +ALL : ALLTAR +.ELSE +ALL: ALLDEP +.ENDIF + +.INCLUDE : target.mk + +RUN: run + +run: + +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_NOOFFICE) $(CT_TEST) |