diff options
Diffstat (limited to 'sc/qa/complex/dataPilot')
-rw-r--r-- | sc/qa/complex/dataPilot/CheckDataPilot.java | 403 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/_XDataPilotDescriptor.java | 464 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/_XDataPilotTable.java | 135 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/_XNamed.java | 159 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/_XPropertySet.java | 631 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/interfaceTests/beans/makefile.mk | 46 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/interfaceTests/container/makefile.mk | 46 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/interfaceTests/sheet/makefile.mk | 46 | ||||
-rw-r--r-- | sc/qa/complex/dataPilot/makefile.mk | 59 |
9 files changed, 1989 insertions, 0 deletions
diff --git a/sc/qa/complex/dataPilot/CheckDataPilot.java b/sc/qa/complex/dataPilot/CheckDataPilot.java new file mode 100644 index 000000000000..b042f259072e --- /dev/null +++ b/sc/qa/complex/dataPilot/CheckDataPilot.java @@ -0,0 +1,403 @@ +/************************************************************************* + * + * 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.dataPilot; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +// import com.sun.star.sheet.TableFilterField; +import com.sun.star.sheet.XDataPilotDescriptor; +import com.sun.star.sheet.XDataPilotTable; +import com.sun.star.sheet.XDataPilotTables; +import com.sun.star.sheet.XDataPilotTablesSupplier; +// import com.sun.star.sheet.XSheetFilterDescriptor; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import complex.dataPilot._XPropertySet; +import complex.dataPilot._XNamed; +import complex.dataPilot._XDataPilotDescriptor; +import complex.dataPilot._XDataPilotTable; +// import complexlib.ComplexTestCase; +import lib.StatusException; +import lib.TestParameters; +import util.SOfficeFactory; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + + +/** + * check the DataPilot of Calc. + */ +public class CheckDataPilot { + /** The data pilot field object **/ + private XInterface mDataPilotFieldObject = null; + /** The data pilot table object **/ + private XInterface mDataPilotTableObject = null; + + + private XSpreadsheetDocument xSheetDoc = null; + + /** + * A field is filled some values. This integer determines the size of the + * field in x and y direction. + */ + private int mMaxFieldIndex = 6; + + /** + * The test parameters + */ + private static TestParameters param = null; + + /** + * Get all test methods + * @return The test methods + */ + public String[] getTestMethodNames() { + return new String[]{"testDataPilotTableObject", + "testDataPilotFieldObject"}; + } + + /** + * Test the data pilot field object: + * simply execute the interface tests in a row + */ + @Test public void testDataPilotFieldObject() { + System.out.println("Starting 'testDataPilotFieldObject'"); + // _XNamed + XNamed xNamed = UnoRuntime.queryInterface( + XNamed.class, mDataPilotFieldObject); + + _XNamed _xNamed = new _XNamed(xNamed/*, log*/, param); + assertTrue("_getName failed.",_xNamed._getName()); + assertTrue("_setName failed.",_xNamed._setName()); + + // _XPropertySet + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, mDataPilotFieldObject); + _XPropertySet _xProp = new _XPropertySet(xProp/*, log*/, param); + assertTrue("_getPropertySetInfo failed.",_xProp._getPropertySetInfo()); + assertTrue("_addPropertyChangeListener failed.",_xProp._addPropertyChangeListener()); + assertTrue("_addVetoableChangeListener failed.",_xProp._addVetoableChangeListener()); + assertTrue("_setPropertyValue failed.",_xProp._setPropertyValue()); + assertTrue("_getPropertyValue failed.",_xProp._getPropertyValue()); + assertTrue("_removePropertyChangeListener failed.",_xProp._removePropertyChangeListener()); + assertTrue("_removeVetoableChangeListener failed.",_xProp._removeVetoableChangeListener()); + + } + + /** + * Test the data pilot table object: + * simply execute the interface tests in a row + */ + @Test public void testDataPilotTableObject() { + System.out.println("Starting 'testDataPilotTableObject'"); + // _XNamed + XNamed xNamed = UnoRuntime.queryInterface( + XNamed.class, mDataPilotTableObject); + _XNamed _xNamed = new _XNamed(xNamed/*, log*/, param); + assertTrue("_getName failed.",_xNamed._getName()); + assertTrue("_setName failed.",_xNamed._setName()); + + // _XDataPilotTable + XDataPilotTable xDataPilotTable = + UnoRuntime.queryInterface(XDataPilotTable.class, + mDataPilotTableObject); + _XDataPilotTable _xDataPilotTable = + new _XDataPilotTable(xDataPilotTable/*, log*/, param); + assertTrue("before failed.", _xDataPilotTable.before()); + assertTrue("_getOutputRange failed.", _xDataPilotTable._getOutputRange()) ; +// assertTrue("_refresh failed.", _xDataPilotTable._refresh()) ; + + // _XDataPilotDescriptor + XDataPilotDescriptor xDataPilotDescriptor = + UnoRuntime.queryInterface(XDataPilotDescriptor.class, + mDataPilotTableObject); + _XDataPilotDescriptor _xDataPilotDescriptor = + new _XDataPilotDescriptor(xDataPilotDescriptor/*, log*/, param); + assertTrue("before failed.", _xDataPilotDescriptor.before()); + assertTrue("_setTag failed.", _xDataPilotDescriptor._setTag()) ; + assertTrue("_getTag failed.", _xDataPilotDescriptor._getTag()) ; + assertTrue("_getFilterDescriptor failed.", _xDataPilotDescriptor._getFilterDescriptor()) ; + assertTrue("_getDataPilotFields failed.", _xDataPilotDescriptor._getDataPilotFields()) ; + assertTrue("_getColumnFields failed.", _xDataPilotDescriptor._getColumnFields()) ; + assertTrue("_getRowFields failed.", _xDataPilotDescriptor._getRowFields()) ; + assertTrue("_getDataFields failed.", _xDataPilotDescriptor._getDataFields()) ; + assertTrue("_getHiddenFields failed.", _xDataPilotDescriptor._getHiddenFields()) ; + assertTrue("_getPageFields failed.", _xDataPilotDescriptor._getPageFields()) ; + assertTrue("_setSourceRange failed.", _xDataPilotDescriptor._setSourceRange()) ; + assertTrue("_getSourceRange failed.", _xDataPilotDescriptor._getSourceRange()) ; + } + + /** + * create an environment for the test + */ + @Before public void before() { +// Object oInterface = null; + + // SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)param.getMSF() ); + final XMultiServiceFactory xMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + SOfficeFactory SOF = SOfficeFactory.getFactory(xMsf); + + param = new TestParameters(); + param.put("ServiceFactory", xMsf); + + // the cell range + CellRangeAddress sCellRangeAdress = new CellRangeAddress(); + sCellRangeAdress.Sheet = 0; + sCellRangeAdress.StartColumn = 1; + sCellRangeAdress.StartRow = 0; + sCellRangeAdress.EndColumn = mMaxFieldIndex-1; + sCellRangeAdress.EndRow = mMaxFieldIndex - 1; + + // position of the data pilot table + CellAddress sCellAdress = new CellAddress(); + sCellAdress.Sheet = 0; + sCellAdress.Column = 7; + sCellAdress.Row = 8; + + try { + System.out.println( "Creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(); + throw new StatusException( "Couldn't create document", e ); + } + + System.out.println("Getting a sheet"); + XSpreadsheets xSpreadsheets = xSheetDoc.getSheets(); + XSpreadsheet oSheet = null; + XSpreadsheet oSheet2 = null; + XIndexAccess oIndexAccess = + UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); + + try { + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0)); + oSheet2 = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexAccess.getByIndex(1)); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + throw new StatusException( "Couldn't get a spreadsheet", e); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + throw new StatusException( "Couldn't get a spreadsheet", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new StatusException( "Couldn't get a spreadsheet", e); + } + + try { + System.out.println("Filling a table"); + for (int i = 1; i < mMaxFieldIndex; i++) { + oSheet.getCellByPosition(i, 0).setFormula("Col" + i); + oSheet.getCellByPosition(0, i).setFormula("Row" + i); + oSheet2.getCellByPosition(i, 0).setFormula("Col" + i); + oSheet2.getCellByPosition(0, i).setFormula("Row" + i); + } + + for (int i = 1; i < mMaxFieldIndex; i++) + { + for (int j = 1; j < mMaxFieldIndex; j++) + { + oSheet.getCellByPosition(i, j).setValue(i * (j + 1)); + oSheet2.getCellByPosition(i, j).setValue(i * (j + 2)); + } + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + throw new StatusException("Couldn't fill some cells", e); + } + + // change a value of a cell and check the change in the data pilot + // (for the XDataPilotTable.refresh() test) + Object oChangeCell = null; + Object oCheckCell = null; + Integer aChangeValue = null; + try { + // cell of data + oChangeCell = oSheet.getCellByPosition(1, 5); + int x = sCellAdress.Column; + int y = sCellAdress.Row + 3; + // cell of the data pilot output + oCheckCell = oSheet.getCellByPosition(x, y); + aChangeValue = new Integer(27); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + throw new StatusException( "Couldn't get cells for changeing.", e); + } + + + // create the test objects + System.out.println("Getting test objects") ; + XDataPilotTablesSupplier DPTS = + UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet); + XDataPilotTables DPT = DPTS.getDataPilotTables(); + XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor(); + DPDsc.setSourceRange(sCellRangeAdress); + + XPropertySet fieldPropSet = null; + try { + Object oDataPilotField = DPDsc.getDataPilotFields().getByIndex(0); + fieldPropSet = + UnoRuntime.queryInterface(XPropertySet.class, oDataPilotField); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } + + try { + fieldPropSet.setPropertyValue("Function", + com.sun.star.sheet.GeneralFunction.SUM); + fieldPropSet.setPropertyValue("Orientation", + com.sun.star.sheet.DataPilotFieldOrientation.DATA); + } catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch(com.sun.star.beans.PropertyVetoException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch(com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } + + System.out.println("Insert the DataPilotTable"); + if (DPT.hasByName("DataPilotTable")) { + DPT.removeByName("DataPilotTable"); + } + DPT.insertNewByName("DataPilotTable", sCellAdress, DPDsc); + try { + mDataPilotTableObject = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),DPT.getByName(DPT.getElementNames()[0])); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new StatusException("Couldn't create a test environment", e); + } + + XIndexAccess IA = DPDsc.getDataPilotFields(); + try { + mDataPilotFieldObject = (XInterface)AnyConverter.toObject( + new Type(XInterface.class),IA.getByIndex(0)); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + throw new StatusException("Couldn't get data pilot field", e); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + throw new StatusException("Couldn't get data pilot field", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new StatusException("Couldn't get data pilot field", e); + } + + // Other parameters required for interface tests + param.put("OUTPUTRANGE", sCellAdress); + param.put("CELLFORCHANGE", oChangeCell); + param.put("CELLFORCHECK", oCheckCell); + param.put("CHANGEVALUE", aChangeValue); + param.put("FIELDSAMOUNT", new Integer(5)); + + } + + /* + * this method closes a calc document and resets the corresponding class variable xSheetDoc + */ + protected boolean closeSpreadsheetDocument() { + boolean worked = true; + + System.out.println(" disposing xSheetDoc "); + + try { + XCloseable oCloser = UnoRuntime.queryInterface( + XCloseable.class, xSheetDoc); + oCloser.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + worked = false; + System.out.println("Couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + worked = false; + System.out.println("Document already disposed"); + } catch (java.lang.NullPointerException e) { + worked = false; + System.out.println("Couldn't get XCloseable"); + } + + xSheetDoc = null; + + return worked; + } + + @After public void after() + { + closeSpreadsheetDocument(); + } + + + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + + +} diff --git a/sc/qa/complex/dataPilot/_XDataPilotDescriptor.java b/sc/qa/complex/dataPilot/_XDataPilotDescriptor.java new file mode 100644 index 000000000000..e611d8f4e147 --- /dev/null +++ b/sc/qa/complex/dataPilot/_XDataPilotDescriptor.java @@ -0,0 +1,464 @@ +/************************************************************************* + * + * 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.dataPilot; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.sheet.DataPilotFieldOrientation; +import com.sun.star.sheet.XDataPilotDescriptor; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.uno.UnoRuntime; +// import lib.MultiMethodTest; +// import lib.Status; +//import lib.StatusException; +import lib.TestParameters; +// import share.LogWriter; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotDescriptor</code> +* interface methods : +* <ul> +* <li><code> getTag()</code></li> +* <li><code> setTag()</code></li> +* <li><code> getSourceRange()</code></li> +* <li><code> setSourceRange()</code></li> +* <li><code> getFilterDescriptor()</code></li> +* <li><code> getDataPilotFields()</code></li> +* <li><code> getColumnFields()</code></li> +* <li><code> getRowFields()</code></li> +* <li><code> getPageFields()</code></li> +* <li><code> getDataFields()</code></li> +* <li><code> getHiddenFields()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'FIELDSAMOUNT'</code> (of type <code>Integer</code>): +* to have number of fields </li> +* <ul> <p> +* @see com.sun.star.sheet.XDataPilotDescriptor +*/ +public class _XDataPilotDescriptor { + + public XDataPilotDescriptor oObj = null; + CellRangeAddress CRA = new CellRangeAddress((short)1, 0, 0, 5, 5); + CellRangeAddress oldCRA = null ; + String sTag = new String ("XDataPilotDescriptor_Tag"); + String fieldsNames[]; + int fieldsAmount = 0; + int tEnvFieldsAmount = 0; + + /** + * The test parameters + */ + private TestParameters param = null; + + /** + * The log writer + */ +// private LogWriter log = null; + + /** + * Constructor: gets the object to test, a logger and the test parameters + * @param xObj The test object + * @param param The test parameters + */ + public _XDataPilotDescriptor(XDataPilotDescriptor xObj/*, + LogWriter log*/, TestParameters param) { + oObj = xObj; + // this.log = log; + this.param = param; + } + + /** + * Retrieves object relations. + + * @return + */ + public boolean before() { + Integer amount = (Integer)param.get("FIELDSAMOUNT"); + if (amount == null) { + System.out.println("Relation 'FIELDSAMOUNT' not found"); + return false; + } + tEnvFieldsAmount = amount.intValue(); + return true; + } + + /** + * Test calls the method and compares returned value with value that was set + * in method <code>setSourceRange()</code>. <p> + * Has <b> OK </b> status if all fields of cell range addresses are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setSourceRange() </code> : to have current source range </li> + * </ul> + * @return + */ + public boolean _getSourceRange(){ +// requiredMethod("setSourceRange()"); + boolean bResult = true; + + CellRangeAddress objRA = oObj.getSourceRange(); + bResult &= objRA.Sheet == CRA.Sheet; + bResult &= objRA.StartRow == CRA.StartRow; + bResult &= objRA.StartColumn == CRA.StartColumn; + bResult &= objRA.EndRow == CRA.EndRow; + bResult &= objRA.EndColumn == CRA.EndColumn; + + return bResult; + } + + /** + * Test gets the current source range, stores it and sets new source range.<p> + * Has <b> OK </b> status if the method successfully returns. <p> + * The following method tests are to be executed before : + * <ul> + * <li> <code> getColumnFields() </code> </li> + * <li> <code> getRowFields() </code> </li> + * <li> <code> getDataFields() </code> </li> + * <li> <code> getHiddenFields() </code> </li> + * <li> <code> getPageFields() </code> </li> + * </ul> + * @return + */ + public boolean _setSourceRange(){ +/* executeMethod("getColumnFields()") ; + executeMethod("getRowFields()") ; + executeMethod("getDataFields()") ; + executeMethod("getHiddenFields()") ; + executeMethod("getPageFields()") ; */ + + oldCRA = oObj.getSourceRange() ; + oObj.setSourceRange(CRA); + + return true; + } + + /** + * Test calls the method and checks returned value with value that was set + * by method <code>setTag()</code>. <p> + * Has <b> OK </b> status if returned value is equal to value that was set + * by method <code>setTag()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setTag() </code> : to have current tag </li> + * </ul> + * @return + */ + public boolean _getTag(){ +// requiredMethod("setTag()"); + boolean bResult = true; + + String objTag = oObj.getTag(); + bResult &= objTag.equals(sTag); + + return bResult; + } + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + * @return + */ + public boolean _setTag(){ + oObj.setTag(sTag); + return true; + } + + /** + * Test calls the method , checks returned value, compares + * number of fields goten from returned value and obtained by object + * relation <code>'FIELDSAMOUNT'</code> and set property + * <code>Orientation</code> to one of DataPilotFieldOrientation values. <p> + * Has <b> OK </b> status if returned value isn't null, number of fields + * goten from returned value is less than number of fields obtained by relation + * and no exceptions were thrown. <p> + * @return + */ + public boolean _getDataPilotFields(){ + boolean bResult = true; + XIndexAccess IA = null; + + IA = oObj.getDataPilotFields(); + if (IA == null) { + System.out.println("Returned value is null."); + return false; + } else {System.out.println("getDataPilotFields returned not Null value -- OK");} + + fieldsAmount = IA.getCount(); + if (fieldsAmount < tEnvFieldsAmount) { + System.out.println("Number of fields is less than number goten by relation."); + return false; + } else {System.out.println("count of returned fields -- OK");} + + fieldsNames = new String[tEnvFieldsAmount]; + int i = -1 ; + int cnt = 0 ; + while (++i < fieldsAmount) { + Object field; + try { + field = IA.getByIndex(i); + } catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + return false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + return false; + } + + XNamed named = UnoRuntime.queryInterface(XNamed.class, field); + String name = named.getName(); + + System.out.println("Field : '" + name + "' ... ") ; + + if (!name.equals("Data")) { + + fieldsNames[cnt] = name ; + + XPropertySet props = + UnoRuntime.queryInterface(XPropertySet.class, field); + + try { + switch (cnt % 5) { + case 0 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.COLUMN); + System.out.println(" Column") ; + break; + case 1 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.ROW); + System.out.println(" Row") ; + break; + case 2 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.DATA); + System.out.println(" Data") ; + break; + case 3 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.HIDDEN); + System.out.println(" Hidden") ; + break; + case 4 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.PAGE); + System.out.println(" Page") ; + props.setPropertyValue("CurrentPage", "20"); + break; + } } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + return false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + return false; + } catch (com.sun.star.beans.PropertyVetoException e) { + e.printStackTrace(); + return false; + } catch (com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace(); + return false; + } + if (++cnt > 4) + { + break; + } + } + else + { + return false; + } + } + + return bResult; + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returns true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + * @return + */ + public boolean _getColumnFields(){ +// requiredMethod("getDataPilotFields()"); + System.out.println("getColumnFields") ; + XIndexAccess IA = oObj.getColumnFields(); + return CheckNames(IA, 0); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + * @return + */ + public boolean _getDataFields(){ +// requiredMethod("getDataPilotFields()"); + System.out.println("getDataFields") ; + XIndexAccess IA = oObj.getDataFields(); + return CheckNames(IA, 2); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + * @return + */ + public boolean _getHiddenFields(){ +// requiredMethod("getDataPilotFields()"); + System.out.println("getHiddenFields") ; + XIndexAccess IA = oObj.getHiddenFields(); + return CheckNames(IA, 3); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + * @return + */ + public boolean _getRowFields(){ +// requiredMethod("getDataPilotFields()"); + System.out.println("getRowFields") ; + XIndexAccess IA = oObj.getRowFields(); + boolean bResult = CheckNames(IA, 1); + return bResult; + } + + /** + * setting of PageFields isn't supported by StarOffice Calc + * Has <b> OK </b> status if the returned IndexAccess + * isn't NULL. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + * @return + */ + public boolean _getPageFields(){ +// requiredMethod("getDataPilotFields()"); + System.out.println("getPageFields") ; + XIndexAccess IA = oObj.getPageFields(); + boolean bResult = CheckNames(IA, 4); + return bResult; + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null + * and no exceptions were thrown. <p> + * @return + */ + public boolean _getFilterDescriptor(){ + boolean bResult = oObj.getFilterDescriptor() != null; + return bResult; + } + + /** + * Method checks that the field with index <code>rem</code> exists + * in the array <code>IA</code>. + * @param IA collection of elements that support interface <code>XNamed</code> + * @param rem index of field in the array of field names that was stored in + * the method <code>getDataPilotFields()</code> + * @return true if required field name exists in passed collection; + * false otherwise + * @see com.sun.star.container.XNamed + */ + private boolean CheckNames(XIndexAccess IA, int rem) { + String name = null; + + if (IA == null) { + System.out.println("Null retruned.") ; + return false ; + } + + if (fieldsNames[rem] == null) { + System.out.println("No fields were set to this orientation - cann't check result") ; + return true ; + } + + if (IA.getCount() == 0) { + System.out.println("No fields found. Must be at least '" + + fieldsNames[rem] + "'") ; + return false ; + } + + try { + System.out.println("Fields returned ") ; + for (int i = 0; i < IA.getCount(); i++) { + Object field = IA.getByIndex(i); + XNamed named = UnoRuntime.queryInterface + (XNamed.class, field); + name = named.getName(); + System.out.println(" " + name) ; + if (fieldsNames[rem].equals(name)) { + System.out.println(" - OK") ; + return true ; + } + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + return false ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + return false ; + } + System.out.println(" - FAILED (field " + fieldsNames[rem] + " was not found.") ; + return false ; + } + + /** + * Recreates object(to back old orientations of the fields). + * + protected void after() { + disposeEnvironment(); + }*/ +} + diff --git a/sc/qa/complex/dataPilot/_XDataPilotTable.java b/sc/qa/complex/dataPilot/_XDataPilotTable.java new file mode 100644 index 000000000000..e27daffab985 --- /dev/null +++ b/sc/qa/complex/dataPilot/_XDataPilotTable.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + * 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.dataPilot; + +import com.sun.star.sheet.XDataPilotTable; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +// import lib.Status; +//import lib.StatusException; +import lib.TestParameters; +// import share.LogWriter; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotTable</code> +* interface methods : +* <ul> +* <li><code> getOutputRange()</code></li> +* <li><code> refresh()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>): +* to check value returned by method <code>getOutputRange()</code> </li> +* <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>): +* to check the method refresh(value of this cell will be changed)</li> +* <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>): +* to check the method refresh (value of this cell must be changed after refresh +* call) </li><ul> <p> +* @see com.sun.star.sheet.XDataPilotTable +* @see com.sun.star.table.CellAddress +*/ +public class _XDataPilotTable { + + public XDataPilotTable oObj = null; + XCell xCellForChange = null; + XCell xCellForCheck = null; + CellAddress OutputRange = null; + int changeValue = 0; + + /** + * The test parameters + */ + private TestParameters param = null; + + /** + * The log writer + */ + // private LogWriter log = null; + + /** + * Constructor: gets the object to test, a logger and the test parameters + * @param xObj The test object + + * @param param The test parameters + */ + public _XDataPilotTable(XDataPilotTable xObj/*, + LogWriter log*/, TestParameters param) { + oObj = xObj; + // this.log = log; + this.param = param; + } + + public boolean before() { + xCellForChange = (XCell)param.get("CELLFORCHANGE"); + xCellForCheck = (XCell)param.get("CELLFORCHECK"); + OutputRange = (CellAddress)param.get("OUTPUTRANGE"); + changeValue = ((Integer)param.get("CHANGEVALUE")).intValue(); + + if (xCellForChange == null || OutputRange == null || + xCellForCheck == null) { + System.out.println("Relation not found"); + return false; + } + return true; + } + /** + * Test calls the method and checks returned value using value obtained by + * object relation <code>'OUTPUTRANGE'</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + * @return + */ + public boolean _getOutputRange(){ + boolean bResult = true; + CellRangeAddress objRange = oObj.getOutputRange(); + bResult &= OutputRange.Sheet == objRange.Sheet; + bResult &= OutputRange.Row == objRange.StartRow; + bResult &= OutputRange.Column == objRange.StartColumn; + return bResult; + } + + /** + * Test sets new value of the cell obtained by object relation + * 'CELLFORCHANGE', and checks value of the cell obtained by object + * relation 'CELLFORCHECK'.<p> + * Has <b>OK</b> status if value of the cell obtained by object relation + * 'CELLFORCHECK' is changed. <p> + * @return + */ + public boolean _refresh(){ + xCellForChange.setValue(changeValue); + double oldData = xCellForCheck.getValue(); + oObj.refresh(); + double newData = xCellForCheck.getValue(); + System.out.println("Old data:" + oldData + "; new data:" + newData); + + return oldData != newData; + } +} + diff --git a/sc/qa/complex/dataPilot/_XNamed.java b/sc/qa/complex/dataPilot/_XNamed.java new file mode 100644 index 000000000000..ff4c647307d5 --- /dev/null +++ b/sc/qa/complex/dataPilot/_XNamed.java @@ -0,0 +1,159 @@ +/************************************************************************* + * + * 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.dataPilot; + +import com.sun.star.container.XNamed; +import lib.TestParameters; +// import share.LogWriter; +// import util.utils; + +/** +* Testing <code>com.sun.star.container.XNamed</code> +* interface methods : +* <ul> +* <li><code> getName()</code></li> +* <li><code> setName()</code></li> +* </ul> +* This test need the following object relations : +* <ul> +* <li> <code>'setName'</code> : of <code>Boolean</code> +* type. If it exists then <code>setName</code> method +* isn't to be tested and result of this test will be +* equal to relation value.</li> +* <ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.container.XNamed +*/ +public class _XNamed { + + /** + * The object that is testsed. + */ + public XNamed oObj = null; + + /** + * The test parameters + */ + private TestParameters param = null; + + /** + * The log writer + */ + // private LogWriter log = null; + + /** + * Constructor: gets the object to test, a logger and the test parameters + * @param xObj The test object + * @param log A log writer + * @param param The test parameters + */ + public _XNamed(XNamed xObj/*, LogWriter log*/, TestParameters param) { + oObj = xObj; + // this.log = log; + this.param = param; + } + + /** + * Test calls the method and checks return value and that + * no exceptions were thrown. <p> + * Has <b> OK </b> status if the method returns non null value + * and no exceptions were thrown. <p> + */ + public boolean _getName() { + + // write to log what we try next + System.out.println( "test for getName()" ); + + boolean result = true; + boolean loc_result = true; + String name = null; + String NewName = null; + + loc_result = ((name = oObj.getName()) != null); + System.out.println("getting the name \"" + name + "\""); + + if (loc_result) + { + System.out.println("... getName() - OK"); + } + else + { + System.out.println("... getName() - FAILED"); + } + result &= loc_result; + return result; + } + + /** + * Sets a new name for object and checks if it was properly + * set. Special cases for the following objects : + * <ul> + * <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li> + * <li><code>ScDDELinkObj</code> : name must contain link to cell in + * some external Sheet.</li> + * </ul> + * Has <b> OK </b> status if new name was successfully set, or if + * object environment contains relation <code>'setName'</code> with + * value <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getName() </code> : to be sure the method works</li> + * </ul> + */ + public boolean _setName(){ +// requiredMethod("getName()"); + System.out.println("testing setName() ... "); + + String oldName = oObj.getName(); + String NewName = oldName == null ? "XNamed" : oldName + "X" ; + + boolean result = true; + boolean loc_result = true; + System.out.println("set the name of object to \"" + NewName + "\""); + oObj.setName(NewName); + System.out.println("check that container has element with this name"); + + String name = oObj.getName(); + System.out.println("getting the name \"" + name + "\""); + loc_result = name.equals(NewName); + + if (loc_result) + { + System.out.println("... setName() - OK"); + } + else + { + System.out.println("... setName() - FAILED"); + } + result &= loc_result; + oObj.setName(oldName); + return result; + } +} + + diff --git a/sc/qa/complex/dataPilot/_XPropertySet.java b/sc/qa/complex/dataPilot/_XPropertySet.java new file mode 100644 index 000000000000..e598a0c28890 --- /dev/null +++ b/sc/qa/complex/dataPilot/_XPropertySet.java @@ -0,0 +1,631 @@ +/************************************************************************* + * + * 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.dataPilot; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyChangeEvent; +import com.sun.star.beans.XPropertyChangeListener; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.beans.XVetoableChangeListener; +import com.sun.star.lang.EventObject; +import java.util.Random; +import java.util.StringTokenizer; +import lib.TestParameters; +// import share.LogWriter; +//import lib.MultiMethodTest; +import util.ValueChanger; +import util.utils; + +/** +* Testing <code>com.sun.star.beans.XPropertySet</code> +* interface methods : +* <ul> +* <li><code>getPropertySetInfo()</code></li> +* <li><code>setPropertyValue()</code></li> +* <li><code>getPropertyValue()</code></li> +* <li><code>addPropertyChangeListener()</code></li> +* <li><code>removePropertyChangeListener()</code></li> +* <li><code>addVetoableChangeListener()</code></li> +* <li><code>removeVetoableChangeListener()</code></li> +* </ul> +* @see com.sun.star.beans.XPropertySet +*/ +public class _XPropertySet { + + /** + * The object that is testsed. + */ + private XPropertySet oObj = null; + + /** + * The test parameters + */ + private TestParameters param = null; + + /** + * The log writer + */ + // private LogWriter log = null; + + /** + * Flag that indicates change listener was called. + */ + boolean propertyChanged = false; + + + /** + * The own property change listener + */ + XPropertyChangeListener PClistener = new MyChangeListener(); + + /** + * Listener that must be called on bound property changing. + */ + public class MyChangeListener implements XPropertyChangeListener { + /** + * Just set <code>propertyChanged</code> flag to true. + */ + public void propertyChange(PropertyChangeEvent e) { + propertyChanged = true; + } + public void disposing (EventObject obj) {} + }; + + + /** + * Flag that indicates veto listener was called. + */ + boolean vetoableChanged = false; + + /** + * The own vetoable change listener + */ + XVetoableChangeListener VClistener = new MyVetoListener(); + + /** + * Listener that must be called on constrained property changing. + */ + public class MyVetoListener implements XVetoableChangeListener { + /** + * Just set <code>vetoableChanged</code> flag to true. + */ + public void vetoableChange(PropertyChangeEvent e) { + vetoableChanged = true; + } + public void disposing (EventObject obj) {} + }; + + + /** + * Properties to test + */ + PropsToTest PTT = new PropsToTest(); + + /** + * Structure that collects three properties of each type to test : + * Constrained, Bound and Normal. + */ + public class PropsToTest { + String constrained = null; + String bound = null; + String normal = null; + } + + /** + * Constructor: gets the object to test, a logger and the test parameters + * @param xObj The test object + * @param log A log writer + * @param param The test parameters + */ + public _XPropertySet(XPropertySet xObj/*, LogWriter log*/, TestParameters param) { + oObj = xObj; + // this.log = log; + this.param = param; + } + + /** + * Tests method <code>getPropertySetInfo</code>. After test completed + * call {@link #getPropsToTest} method to retrieve different kinds + * of properties to test then. <p> + * Has OK status if not null <code>XPropertySetInfo</code> + * object returned.<p> + * Since <code>getPropertySetInfo</code> is optional, it may return null, + * if it is not implemented. This method uses then an object relation + * <code>PTT</code> (Properties To Test) to determine available properties. + * All tests for services without <code>getPropertySetInfo</code> must + * provide this object relation. + */ + public boolean _getPropertySetInfo() { + XPropertySetInfo propertySetInfo = oObj.getPropertySetInfo(); + + if (propertySetInfo == null) { + System.out.println("getPropertySetInfo() method returned null"); + String[] ptt = (String[]) param.get("PTT"); + PTT.normal=ptt[0]; + PTT.bound=ptt[1]; + PTT.constrained=ptt[2]; + } else { + getPropsToTest(propertySetInfo); + } + + return true; + + } // end of getPropertySetInfo() + + /** + * Tests change listener which added for bound properties. + * Adds listener to bound property (if it exists), then changes + * its value and check if listener was called. <p> + * Method tests to be successfully completed before : + * <ul> + * <li> <code>getPropertySetInfo</code> : in this method test + * one of bound properties is retrieved. </li> + * </ul> <p> + * Has OK status if NO bound properties exist or if listener + * was successfully called. + */ + public boolean _addPropertyChangeListener() { + + propertyChanged = false; + boolean result = true; + + if ( PTT.bound.equals("none") ) { + System.out.println("*** No bound properties found ***"); + } else { + try { + oObj.addPropertyChangeListener(PTT.bound,PClistener); + Object gValue = oObj.getPropertyValue(PTT.bound); + oObj.setPropertyValue(PTT.bound, + ValueChanger.changePValue(gValue)); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } // end of try-catch + result = propertyChanged; + if (!propertyChanged) { + System.out.println("propertyChangeListener wasn't called for '"+ + PTT.bound+"'"); + } + } //endif + + return result; + + } // end of addPropertyChangeListener() + + /** + * Tests vetoable listener which added for constrained properties. + * Adds listener to constrained property (if it exists), then changes + * its value and check if listener was called. <p> + * Method tests to be successfully completed before : + * <ul> + * <li> <code>getPropertySetInfo</code> : in this method test + * one of constrained properties is retrieved. </li> + * </ul> <p> + * Has OK status if NO constrained properties exist or if listener + * was successfully called. + */ + public boolean _addVetoableChangeListener() { + +// requiredMethod("getPropertySetInfo()"); + + vetoableChanged = false; + boolean result = true; + + if ( PTT.constrained.equals("none") ) { + System.out.println("*** No constrained properties found ***"); + } else { + try { + oObj.addVetoableChangeListener(PTT.constrained,VClistener); + Object gValue = oObj.getPropertyValue(PTT.constrained); + oObj.setPropertyValue(PTT.constrained, + ValueChanger.changePValue(gValue)); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } // end of try-catch + result = vetoableChanged; + if (!vetoableChanged) { + System.out.println("vetoableChangeListener wasn't called for '"+ + PTT.constrained+"'"); + } + } //endif + + return result; + + } // end of addVetoableChangeListener() + + + /** + * Tests <code>setPropertyValue</code> method. + * Stores value before call, and compares it with value after + * call. <p> + * Method tests to be successfully completed before : + * <ul> + * <li> <code>getPropertySetInfo</code> : in this method test + * one of normal properties is retrieved. </li> + * </ul> <p> + * Has OK status if NO normal properties exist or if value before + * method call is not equal to value after. + */ + public boolean _setPropertyValue() { + +// requiredMethod("getPropertySetInfo()"); + + Object gValue = null; + Object sValue = null; + + boolean result = true; + + if ( PTT.normal.equals("none") ) { + System.out.println("*** No changeable properties found ***"); + } else { + try { + gValue = oObj.getPropertyValue(PTT.normal); + sValue = ValueChanger.changePValue(gValue); + oObj.setPropertyValue(PTT.normal, sValue); + sValue = oObj.getPropertyValue(PTT.normal); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.normal+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.normal+"'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.normal+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.normal+"'"); + e.printStackTrace(); + } // end of try-catch + result = !gValue.equals(sValue); + } //endif + + return result; + + } // end of setPropertyValue() + + /** + * Tests <code>getPropertyValue</code> method. + * Just call this method and checks for no exceptions <p> + * Method tests to be successfully completed before : + * <ul> + * <li> <code>getPropertySetInfo</code> : in this method test + * one of normal properties is retrieved. </li> + * </ul> <p> + * Has OK status if NO normal properties exist or if no + * exceptions were thrown. + */ + public boolean _getPropertyValue() { + +// requiredMethod("getPropertySetInfo()"); + + boolean result = true; + String toCheck = PTT.normal; + + if ( PTT.normal.equals("none") ) { + toCheck = oObj.getPropertySetInfo().getProperties()[0].Name; + System.out.println("All properties are Read Only"); + System.out.println("Using: "+toCheck); + } + + try { + Object gValue = oObj.getPropertyValue(toCheck); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to get property '"+ + PTT.normal+"'"); + e.printStackTrace(); + result = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to get property '"+ + PTT.normal+"'"); + e.printStackTrace(); + result = false; + } // end of try-catch + + return result; + } + + /** + * Tests <code>removePropertyChangeListener</code> method. + * Removes change listener, then changes bound property value + * and checks if the listener was NOT called. + * Method tests to be successfully completed before : + * <ul> + * <li> <code>addPropertyChangeListener</code> : here listener + * was added. </li> + * </ul> <p> + * Has OK status if NO bound properties exist or if listener + * was not called and no exceptions arose. + */ + public boolean _removePropertyChangeListener() { + +// requiredMethod("addPropertyChangeListener()"); + + propertyChanged = false; + boolean result = true; + + if ( PTT.bound.equals("none") ) { + System.out.println("*** No bound properties found ***"); + } else { + try { + propertyChanged = false; + oObj.removePropertyChangeListener(PTT.bound,PClistener); + Object gValue = oObj.getPropertyValue(PTT.bound); + oObj.setPropertyValue(PTT.bound, + ValueChanger.changePValue(gValue)); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.bound+"'"); + e.printStackTrace(); + } // end of try-catch + + result = !propertyChanged; + if (propertyChanged) { + System.out.println("propertyChangeListener was called after removing"+ + " for '"+PTT.bound+"'"); + } + } //endif + + return result; + + } // end of removePropertyChangeListener() + + + /** + * Tests <code>removeVetoableChangeListener</code> method. + * Removes vetoable listener, then changes constrained property value + * and checks if the listener was NOT called. + * Method tests to be successfully completed before : + * <ul> + * <li> <code>addPropertyChangeListener</code> : here vetoable listener + * was added. </li> + * </ul> <p> + * Has OK status if NO constrained properties exist or if listener + * was NOT called and no exceptions arose. + */ + public boolean _removeVetoableChangeListener() { + +// requiredMethod("addVetoableChangeListener()"); + + vetoableChanged = false; + boolean result = true; + + if ( PTT.constrained.equals("none") ) { + System.out.println("*** No constrained properties found ***"); + } else { + try { + oObj.removeVetoableChangeListener(PTT.constrained,VClistener); + Object gValue = oObj.getPropertyValue(PTT.constrained); + oObj.setPropertyValue(PTT.constrained, + ValueChanger.changePValue(gValue)); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("Exception occured while trying to change "+ + "property '"+ PTT.constrained+"'"); + e.printStackTrace(); + } // end of try-catch + + result = !vetoableChanged; + if (vetoableChanged) { + System.out.println("vetoableChangeListener was called after "+ + "removing for '"+PTT.constrained+"'"); + } + } //endif + + return result; + + } // end of removeVetoableChangeListener() + + + /** + * Gets the properties being tested. Searches and stores by one + * property of each kind (Bound, Vetoable, Normal). + */ + public PropsToTest getPropsToTest(XPropertySetInfo xPSI) { + + Property[] properties = xPSI.getProperties(); + String bound = ""; + String constrained = ""; + String normal = ""; + + for (int i = 0; i < properties.length; i++) { + + Property property = properties[i]; + String name = property.Name; + System.out.println("Checking '"+name+"'"); + boolean isWritable = ((property.Attributes & + PropertyAttribute.READONLY) == 0); + boolean isNotNull = ((property.Attributes & + PropertyAttribute.MAYBEVOID) == 0); + boolean isBound = ((property.Attributes & + PropertyAttribute.BOUND) != 0); + boolean isConstr = ((property.Attributes & + PropertyAttribute.CONSTRAINED) != 0); + boolean canChange = false; + + if ( !isWritable ) System.out.println("Property '"+name+"' is READONLY"); + + if (name.endsWith("URL")) isWritable = false; + if (name.startsWith("Fill")) isWritable = false; + if (name.startsWith("Font")) isWritable = false; + if (name.startsWith("IsNumbering")) isWritable = false; + if (name.startsWith("LayerName")) isWritable = false; + if (name.startsWith("Line")) isWritable = false; + + //if (name.equals("xinterfaceA") || name.equals("xtypeproviderA") + //|| name.equals("arAnyA")) isWritable=false; + + if ( isWritable && isNotNull ) canChange = isChangeable(name); + + if ( isWritable && isNotNull && isBound && canChange) { + bound+=name+";"; + } + + if ( isWritable && isNotNull && isConstr && canChange) { + constrained+=name+";"; + } + + if ( isWritable && isNotNull && canChange) normal+=name+";"; + + + } // endfor + + //get a random bound property + PTT.bound=getRandomString(bound); + System.out.println("Bound: "+PTT.bound); + + //get a random constrained property + PTT.constrained=getRandomString(constrained); + System.out.println("Constrained: "+PTT.constrained); + + //get a random normal property + PTT.normal=getRandomString(normal); + + return PTT; + + } + + /** + * Retrieves one random property name from list (property names separated + * by ';') of property names. + */ + public String getRandomString(String str) { + + String gRS = "none"; + Random rnd = new Random(); + + if (str.equals("")) str = "none"; + StringTokenizer ST=new StringTokenizer(str,";"); + int nr = rnd.nextInt(ST.countTokens()); + if (nr < 1) nr+=1; + for (int i=1; i<nr+1; i++) gRS = ST.nextToken(); + + return gRS; + + } + + public boolean isChangeable(String name) { + boolean hasChanged = false; + try { + Object getProp = oObj.getPropertyValue(name); + System.out.println("Getting: "+getProp); + + Object setValue = null; + if (getProp != null) { + if (!utils.isVoid(getProp)) + setValue = ValueChanger.changePValue(getProp); + else System.out.println("Property '"+name+ + "' is void but MAYBEVOID isn't set"); + } else System.out.println("Property '"+name+"'is null and can't be changed"); + if (name.equals("LineStyle")) setValue = null; + if (setValue != null) { + oObj.setPropertyValue(name, setValue); + System.out.println("Setting to :"+setValue); + hasChanged = (! getProp.equals(oObj.getPropertyValue(name))); + } else System.out.println("Couldn't change Property '"+name+"'"); + } catch (com.sun.star.beans.PropertyVetoException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } catch (com.sun.star.lang.IllegalArgumentException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } catch (com.sun.star.beans.UnknownPropertyException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } catch (com.sun.star.uno.RuntimeException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } catch (java.lang.ArrayIndexOutOfBoundsException e) { + System.out.println("'" + name + "' throws exception '" + e + "'"); + e.printStackTrace(); + } + + return hasChanged; + } + + +} // finish class _XPropertySet + diff --git a/sc/qa/complex/dataPilot/interfaceTests/beans/makefile.mk b/sc/qa/complex/dataPilot/interfaceTests/beans/makefile.mk new file mode 100644 index 000000000000..22b29f5e0585 --- /dev/null +++ b/sc/qa/complex/dataPilot/interfaceTests/beans/makefile.mk @@ -0,0 +1,46 @@ +#************************************************************************* +# +# 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 = DataPilotInterfaceBeans +PRJNAME = sc +PACKAGE = complex/dataPilot/interfaceTests/beans + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = _XPropertySet.java +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:b).class) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/sc/qa/complex/dataPilot/interfaceTests/container/makefile.mk b/sc/qa/complex/dataPilot/interfaceTests/container/makefile.mk new file mode 100644 index 000000000000..d8b4321f0fd1 --- /dev/null +++ b/sc/qa/complex/dataPilot/interfaceTests/container/makefile.mk @@ -0,0 +1,46 @@ +#************************************************************************* +# +# 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 = DataPilotInterfaceContainer +PRJNAME = sc +PACKAGE = complex/dataPilot/interfaceTests/container + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = _XNamed.java +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:b).class) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/sc/qa/complex/dataPilot/interfaceTests/sheet/makefile.mk b/sc/qa/complex/dataPilot/interfaceTests/sheet/makefile.mk new file mode 100644 index 000000000000..f62d17614222 --- /dev/null +++ b/sc/qa/complex/dataPilot/interfaceTests/sheet/makefile.mk @@ -0,0 +1,46 @@ +#************************************************************************* +# +# 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 = DataPilotInterfaceSheet +PRJNAME = sc +PACKAGE = complex/dataPilot/interfaceTests/sheet + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = _XDataPilotDescriptor.java _XDataPilotTable.java +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:b).class) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/sc/qa/complex/dataPilot/makefile.mk b/sc/qa/complex/dataPilot/makefile.mk new file mode 100644 index 000000000000..85512f8e5bc4 --- /dev/null +++ b/sc/qa/complex/dataPilot/makefile.mk @@ -0,0 +1,59 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../../.. +PRJNAME = sc +TARGET = qa_complex_datapilot + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/dataPilot +JAVATESTFILES = \ + CheckDataPilot.java + +JAVAFILES = $(JAVATESTFILES) \ + _XDataPilotDescriptor.java \ + _XDataPilotTable.java \ + _XNamed.java \ + _XPropertySet.java + +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END + |