diff options
Diffstat (limited to 'qadevOOo/tests/java/ifc/text')
73 files changed, 6901 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/text/_BaseFrame.java b/qadevOOo/tests/java/ifc/text/_BaseFrame.java new file mode 100644 index 000000000..8bfd80dc5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_BaseFrame.java @@ -0,0 +1,116 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.BaseFrame</code> +* service properties : +* <ul> +* <li><code> AnchorPageNo</code></li> +* <li><code> AnchorFrame</code></li> +* <li><code> BackColor</code></li> +* <li><code> BackGraphicURL</code></li> +* <li><code> BackGraphicFilter</code></li> +* <li><code> BackGraphicLocation</code></li> +* <li><code> LeftBorder</code></li> +* <li><code> RightBorder</code></li> +* <li><code> TopBorder</code></li> +* <li><code> BottomBorder</code></li> +* <li><code> BorderDistance</code></li> +* <li><code> LeftBorderDistance</code></li> +* <li><code> RightBorderDistance</code></li> +* <li><code> TopBorderDistance</code></li> +* <li><code> BottomBorderDistance</code></li> +* <li><code> BackTransparent</code></li> +* <li><code> ContentProtected</code></li> +* <li><code> FrameStyleName</code></li> +* <li><code> LeftMargin</code></li> +* <li><code> RightMargin</code></li> +* <li><code> TopMargin</code></li> +* <li><code> BottomMargin</code></li> +* <li><code> Height</code></li> +* <li><code> Width</code></li> +* <li><code> RelativeHeight</code></li> +* <li><code> RelativeWidth</code></li> +* <li><code> IsSyncWidthToHeight</code></li> +* <li><code> IsSyncHeightToWidth</code></li> +* <li><code> HoriOrient</code></li> +* <li><code> HoriOrientPosition</code></li> +* <li><code> HoriOrientRelation</code></li> +* <li><code> VertOrient</code></li> +* <li><code> VertOrientPosition</code></li> +* <li><code> VertOrientRelation</code></li> +* <li><code> HyperLinkURL</code></li> +* <li><code> HyperLinkTarget</code></li> +* <li><code> HyperLinkName</code></li> +* <li><code> Opaque</code></li> +* <li><code> PageToggle</code></li> +* <li><code> PositionProtected</code></li> +* <li><code> Print</code></li> +* <li><code> ShadowFormat</code></li> +* <li><code> ServerMap</code></li> +* <li><code> Size</code></li> +* <li><code> SizeProtected</code></li> +* <li><code> Surround</code></li> +* <li><code> SurroundAnchorOnly</code></li> +* <li><code> BackColorTransparency</code></li> +* <li><code> BackColorRGB</code></li> +* <li><code> BackGraphicTransparency</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.BaseFrame +*/ +public class _BaseFrame extends MultiPropertyTest { + public String str1 = "Graphics"; + public String str2 = "Watermark"; + + /** + * Redefined method returns value, that differs from property value. + */ + protected PropertyTester StringTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if (str1.equals(oldValue)) + return str2; + else + return str1; + } + }; + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _FrameStyleName() { + log.println("Testing with custom Property tester") ; + testProperty("FrameStyleName", StringTester) ; + } + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _BackColorTransparency() { + testProperty("BackColorTransparency", Integer.valueOf(10), Integer.valueOf(50)) ; + } + +} //finish class _BaseFrame + diff --git a/qadevOOo/tests/java/ifc/text/_BaseFrameProperties.java b/qadevOOo/tests/java/ifc/text/_BaseFrameProperties.java new file mode 100644 index 000000000..9b0cf03c8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_BaseFrameProperties.java @@ -0,0 +1,37 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import lib.MultiPropertyTest; + + +public class _BaseFrameProperties extends MultiPropertyTest { + protected PropertyTester FrameTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + Object frame = tEnv.getObjRelation("TextFrame"); + + return frame; + } + }; + + public void _AnchorFrame() { + log.println("Testing with custom Property tester"); + testProperty("AnchorFrame", FrameTester); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/text/_BaseIndex.java b/qadevOOo/tests/java/ifc/text/_BaseIndex.java new file mode 100644 index 000000000..006796724 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_BaseIndex.java @@ -0,0 +1,201 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexReplace; +import com.sun.star.text.XTextColumns; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiPropertyTest; + + +/** +* Testing <code>com.sun.star.text.BaseIndex</code> +* service properties : +* <ul> +* <li><code> Title</code></li> +* <li><code> IsProtected</code></li> +* <li><code> ParaStyleHeading</code></li> +* <li><code> ParaStyleLevel1</code></li> +* <li><code> ParaStyleLevel2</code></li> +* <li><code> ParaStyleLevel3</code></li> +* <li><code> ParaStyleLevel4</code></li> +* <li><code> ParaStyleLevel5</code></li> +* <li><code> ParaStyleLevel6</code></li> +* <li><code> ParaStyleLevel7</code></li> +* <li><code> ParaStyleLevel8</code></li> +* <li><code> ParaStyleLevel9</code></li> +* <li><code> ParaStyleLevel10</code></li> +* <li><code> ParaStyleSeparator</code></li> +* <li><code> TextColumns</code></li> +* <li><code> BackGraphicURL</code></li> +* <li><code> BackGraphicFilter</code></li> +* <li><code> BackGraphicLocation</code></li> +* <li><code> BackTransparent</code></li> +* <li><code> LevelFormat</code></li> +* <li><code> CreateFromChapter</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.BaseIndex +*/ +public class _BaseIndex extends MultiPropertyTest { + /** + * Redefined method returns object, that contains changed property value. + */ + protected PropertyTester CustomTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + XTextColumns TC = UnoRuntime.queryInterface( + XTextColumns.class, oldValue); + TC.setColumnCount((short) (TC.getColumnCount() + (short) 1)); + + return TC; + } + }; + + /** + * New value must be defined for this property. + */ + public void _TextColumns() { + log.println( + "Testing property 'TextColumns' with custom property tester"); + testProperty("TextColumns", CustomTester); + } + + /** + * The value of this property is a collection of document index + * level formats. This property is tested in the following manner : + * the property value (a collection) is obtained, the first element + * of this collection is replaced with new non-empty array + * (<code>PropertyValue[][]</code>) with some properties set. + * After that the collection is set back as property value. <p> + * + * Comparing of set and got <code>PropertyValue</code> arrays + * is difficult because values can be changed after setting + * by service implementation. <p> + * + * Has <b>OK</b> status if the collection again gotten, has a + * new first element (i.e. lengths of the old array and the array + * get are different or their contents differ). + */ + public void _LevelFormat() { + log.println( + "Testing property 'LevelFormat' with custom property tester"); + testProperty("LevelFormat", + new PropertyTester() { + PropertyValue[][] newVal = null; + PropertyValue[][] oldVal = null; + + @Override + protected Object getNewValue(String propName, Object oldValue) { + XIndexReplace indProp = UnoRuntime.queryInterface( + XIndexReplace.class, oldValue); + + try { + oldVal = (PropertyValue[][]) indProp.getByIndex(0); + + log.println("Get:"); + printLevelFormatProperty(oldValue); + + newVal = new PropertyValue[1][2]; + + for (int i = 0; i < newVal[0].length; i++) { + newVal[0][i] = new PropertyValue(); + } + + newVal[0][1].Name = "TokenType"; + newVal[0][1].Value = "TokenEntryText"; + newVal[0][0].Name = "Text"; + newVal[0][0].Value = "BaseIndex"; + + indProp.replaceByIndex(0, newVal); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception occurred while testing LevelFormat"); + e.printStackTrace(log); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception occurred while testing LevelFormat"); + e.printStackTrace(log); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception occurred while testing LevelFormat"); + e.printStackTrace(log); + } + + return indProp; + } + + @Override + protected void checkResult(String propName, Object oldValue, + Object newValue, Object resValue, + Exception exception) + throws Exception { + + super.checkResult(propName, oldValue, newValue, resValue, exception); + + PropertyValue[][] res = (PropertyValue[][]) UnoRuntime.queryInterface( + XIndexAccess.class, + resValue).getByIndex(0); + + log.println("Result:"); + printLevelFormatProperty(resValue); + + boolean result = (res.length != oldVal.length) || + !util.ValueComparer.equalValue(res, oldVal); + + tRes.tested(propName, result); + } + }); + } + + /** + * Outputs full description of 'LevelFormat' property + * value into <code>log</code>. + */ + private void printLevelFormatProperty(Object value) { + XIndexReplace indProp = UnoRuntime.queryInterface( + XIndexReplace.class, value); + PropertyValue[][] val = null; + + try { + log.println(" \u0421ollection has " + indProp.getCount() + + " elements : "); + + for (int i = 0; i < indProp.getCount(); i++) { + val = (PropertyValue[][]) indProp.getByIndex(i); + + log.println(" " + i + ": has " + val.length + " levels :"); + + for (int j = 0; j < val.length; j++) { + log.println(" " + j + " level :"); + + for (int k = 0; k < val[j].length; k++) { + log.println(" " + val[j][k].Name + "=" + + val[j][k].Value); + } + } + } + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception occurred while printing LevelFormat"); + e.printStackTrace(log); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception occurred while printing LevelFormat"); + e.printStackTrace(log); + } + } +} // finish class _NumberingRules diff --git a/qadevOOo/tests/java/ifc/text/_BaseIndexMark.java b/qadevOOo/tests/java/ifc/text/_BaseIndexMark.java new file mode 100644 index 000000000..a80d7488a --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_BaseIndexMark.java @@ -0,0 +1,36 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.BaseIndexMark</code> +* service properties : +* <ul> +* <li><code> AlternativeText</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.BaseIndexMark +*/ +public class _BaseIndexMark extends MultiPropertyTest { + +} // finish class _BaseIndexMark + + diff --git a/qadevOOo/tests/java/ifc/text/_CellProperties.java b/qadevOOo/tests/java/ifc/text/_CellProperties.java new file mode 100644 index 000000000..25b739cc7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_CellProperties.java @@ -0,0 +1,150 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +import com.sun.star.container.XNameContainer; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.xml.AttributeData; + +/** +* Testing <code>com.sun.star.text.CellProperties</code> +* service properties : +* <ul> +* <li><code> BackColor</code></li> +* <li><code> BackGraphicURL</code></li> +* <li><code> BackGraphicFilter</code></li> +* <li><code> BackGraphicLocation</code></li> +* <li><code> NumberFormat</code></li> +* <li><code> BackTransparent</code></li> +* <li><code> LeftBorder</code></li> +* <li><code> RightBorder</code></li> +* <li><code> TopBorder</code></li> +* <li><code> BottomBorder</code></li> +* <li><code> LeftBorderDistance</code></li> +* <li><code> RightBorderDistance</code></li> +* <li><code> TopBorderDistance</code></li> +* <li><code> BottomBorderDistance</code></li> +* <li><code> UserDefinedAttributes</code></li> +* <li><code> TextSection</code></li> +* <li><code> IsProtected</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'CellProperties.TextSection'</code> (of type +* <code>XInterface</code>): +* instance of <code>com.sun.star.text.TextSection</code></li> +* </ul> <p> +* The following predefined files needed to complete the test: +* <ul> +* <li> <code> crazy-blue.jpg </code> : jpeg image used to test +* BackGraphicURL()</li> +* <li> <code> space-metal.jpg </code> : jpeg image used to test +* BackGraphicURL()</li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.CellProperties +*/ +public class _CellProperties extends MultiPropertyTest { + + /** + * This property can be void, so new value must be specified from + * corresponding object relation. + */ + public void _TextSection() { + log.println("Testing with custom Property tester") ; + testProperty("TextSection", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + return tEnv.getObjRelation("CellProperties.TextSection"); + } + }); + } + + + /** + * Redefined method returns value, that differs from property value. + */ + public void _BackColor() { + final Short val1 = Short.valueOf( (short) 4 ); + final Short val2 = Short.valueOf( (short) 6 ); + log.println("Testing with custom Property tester") ; + testProperty("BackColor", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if ( oldValue.equals(val1) ) + return val2; + else + return val1; + } + }); + } + + + /** + * Redefined method returns value, that differs from property value. + */ + public void _BackGraphicURL() { + log.println("Testing with custom Property tester") ; + testProperty("BackGraphicURL", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if (oldValue.equals(util.utils.getFullTestURL + ("space-metal.jpg"))) + return util.utils.getFullTestURL("crazy-blue.jpg"); + else + return util.utils.getFullTestURL("space-metal.jpg"); + } + }); + } + + + /** + * Redefined method returns object, that contains changed property value. + */ + public void _UserDefinedAttributes() { + log.println("Testing with custom property tester"); + testProperty("UserDefinedAttributes", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + XNameContainer NC = null; + try { + NC = (XNameContainer) + AnyConverter.toObject(new Type(XNameContainer.class),oldValue); + NC.insertByName("MyAttribute", + new AttributeData("","CDATA","Value")); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Failed to check 'UserDefinedAttributes'"); + e.printStackTrace(log); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Failed to check 'UserDefinedAttributes'"); + e.printStackTrace(log); + } catch ( com.sun.star.container.ElementExistException e ) { + log.println("Failed to check 'UserDefinedAttributes'"); + e.printStackTrace(log); + } + return NC; + } + }); + } + +} //finish class _CellProperties + diff --git a/qadevOOo/tests/java/ifc/text/_CellRange.java b/qadevOOo/tests/java/ifc/text/_CellRange.java new file mode 100644 index 000000000..c2942a1c5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_CellRange.java @@ -0,0 +1,94 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.CellRange</code> +* service properties : +* <ul> +* <li><code> BackColor</code></li> +* <li><code> BackGraphicURL</code></li> +* <li><code> BackGraphicFilter</code></li> +* <li><code> BackGraphicLocation</code></li> +* <li><code> BackTransparent</code></li> +* <li><code> ChartColumnAsLabel</code></li> +* <li><code> ChartRowAsLabel</code></li> +* <li><code> NumberFormat</code></li> +* <li><code> TopMargin</code></li> +* <li><code> BottomMargin</code></li> +* +* The following predefined files needed to complete the test: +* <ul> +* <li> <code> crazy-blue.jpg </code> : jpeg image used to test +* BackGraphicURL()</li> +* <li> <code> space-metal.jpg </code> : jpeg image used to test +* BackGraphicURL()</li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.CellProperties +*/ +public class _CellRange extends MultiPropertyTest { + + /** + * Redefined method returns value, that differs from property value. + */ + public void _BackColor() { + final Short val1 = Short.valueOf( (short) 4 ); + final Short val2 = Short.valueOf( (short) 6 ); + log.println("Testing with custom Property tester") ; + testProperty("BackColor", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if ( oldValue.equals(val1) ) + return val2; + else + return val1; + } + }); + } + + /** + * This property could be changed only when graphic + * URL is set. + */ + public void _BackGraphicFilter() { + executeMethod("BackGraphicURL"); + testProperty("BackGraphicFilter"); + } + + /** + * Redefined method returns value, that differs from property value. + */ + public void _BackGraphicURL() { + log.println("Testing with custom Property tester") ; + testProperty("BackGraphicURL", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if (oldValue.equals(util.utils.getFullTestURL + ("space-metal.jpg"))) + return util.utils.getFullTestURL("crazy-blue.jpg"); + else + return util.utils.getFullTestURL("space-metal.jpg"); + } + }); + } +} + diff --git a/qadevOOo/tests/java/ifc/text/_Defaults.java b/qadevOOo/tests/java/ifc/text/_Defaults.java new file mode 100644 index 000000000..22ccb8872 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_Defaults.java @@ -0,0 +1,32 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.Defaults</code> +* +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.Defaults +*/ +public class _Defaults extends MultiPropertyTest { + +} //finish class _Defaults + diff --git a/qadevOOo/tests/java/ifc/text/_DocumentIndex.java b/qadevOOo/tests/java/ifc/text/_DocumentIndex.java new file mode 100644 index 000000000..5ee228341 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_DocumentIndex.java @@ -0,0 +1,45 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.DocumentIndex</code> +* service properties : +* <ul> +* <li><code> UseAlphabeticalSeparators</code></li> +* <li><code> UseKeyAsEntry</code></li> +* <li><code> UseCombinedEntries</code></li> +* <li><code> IsCaseSensitive</code></li> +* <li><code> UsePP</code></li> +* <li><code> UseDash</code></li> +* <li><code> UseUpperCase</code></li> +* <li><code> MainEntryCharacterStyleName</code></li> +* <li><code> DocumentIndexMarks</code></li> +* <li><code> Locale</code></li> +* <li><code> SortAlgorithm</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.DocumentIndex +*/ +public class _DocumentIndex extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/text/_DocumentIndexMark.java b/qadevOOo/tests/java/ifc/text/_DocumentIndexMark.java new file mode 100644 index 000000000..d78730727 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_DocumentIndexMark.java @@ -0,0 +1,38 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.DocumentIndexMark</code> +* service properties : +* <ul> +* <li><code> PrimaryKey</code></li> +* <li><code> SecondaryKey</code></li> +* <li><code> IsMainEntry</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.DocumentIndexMark +*/ +public class _DocumentIndexMark extends MultiPropertyTest { + +} // finish class _DocumentIndexMark + + diff --git a/qadevOOo/tests/java/ifc/text/_DocumentSettings.java b/qadevOOo/tests/java/ifc/text/_DocumentSettings.java new file mode 100644 index 000000000..0110aee3d --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_DocumentSettings.java @@ -0,0 +1,26 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +public class _DocumentSettings extends MultiPropertyTest +{ + +} diff --git a/qadevOOo/tests/java/ifc/text/_Footnote.java b/qadevOOo/tests/java/ifc/text/_Footnote.java new file mode 100644 index 000000000..4af172564 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_Footnote.java @@ -0,0 +1,47 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.Footnote</code> +* service properties : +* <ul> +* <li><code> ReferenceId</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.Footnote +*/ +public class _Footnote extends MultiPropertyTest { + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _ReferenceId() { + final Short val1 = Short.valueOf( (short) 1); + final Short val2 = Short.valueOf( (short) 2); + + log.println("Testing with custom Property tester"); + testProperty("ReferenceId", val1, val2); + } + +} //finish class _Footnote + diff --git a/qadevOOo/tests/java/ifc/text/_FootnoteSettings.java b/qadevOOo/tests/java/ifc/text/_FootnoteSettings.java new file mode 100644 index 000000000..77cc50d87 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_FootnoteSettings.java @@ -0,0 +1,95 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.FootnoteSettings</code> +* service properties : +* <ul> +* <li><code> CharStyleName</code></li> +* <li><code> NumberingType</code></li> +* <li><code> PageStyleName</code></li> +* <li><code> ParaStyleName</code></li> +* <li><code> Prefix</code></li> +* <li><code> StartAt</code></li> +* <li><code> Suffix</code></li> +* <li><code> BeginNotice</code></li> +* <li><code> EndNotice</code></li> +* <li><code> FootnoteCounting</code></li> +* <li><code> PositionEndOfDoc</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.FootnoteSettings +*/ +public class _FootnoteSettings extends MultiPropertyTest { + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _CharStyleName() { + log.println("Testing with custom Property tester") ; + testProperty("CharStyleName", "Endnote Symbol", "Endnote anchor") ; + } + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _PageStyleName() { + log.println("Testing with custom Property tester") ; + testProperty("PageStyleName", "Standard", "Endnote") ; + } + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _ParaStyleName() { + log.println("Testing with custom Property tester") ; + testProperty("ParaStyleName", "Standard", "Endnote") ; + } + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _NumberingType() { + Short val1 = Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT); + Short val2 = Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_PAGE); + log.println("Testing with custom Property tester") ; + testProperty("NumberingType", val1, val2) ; + } + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _FootnoteCounting() { + Short val1 = Short.valueOf( (short) 1 ); + Short val2 = Short.valueOf( (short) 2 ); + log.println("Testing with custom Property tester") ; + testProperty("FootnoteCounting", val1, val2) ; + } + +} + + diff --git a/qadevOOo/tests/java/ifc/text/_GenericTextDocument.java b/qadevOOo/tests/java/ifc/text/_GenericTextDocument.java new file mode 100644 index 000000000..237d281ec --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_GenericTextDocument.java @@ -0,0 +1,39 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.TextDocument</code> +* service properties : +* <ul> +* <li><code> CharLocale</code></li> +* <li><code> CharacterCount</code></li> +* <li><code> ParagraphCount</code></li> +* <li><code> WordCount</code></li> +* <li><code> WordSeparator</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.TextDocument +*/ +public class _GenericTextDocument extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/text/_LineNumberingProperties.java b/qadevOOo/tests/java/ifc/text/_LineNumberingProperties.java new file mode 100644 index 000000000..b85880dcc --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_LineNumberingProperties.java @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.LineNumberingProperties</code> +* service properties : +* <ul> +* <li><code> IsOn</code></li> +* <li><code> CharStyleName</code></li> +* <li><code> CountEmptyLines</code></li> +* <li><code> CountLinesInFrames</code></li> +* <li><code> Distance</code></li> +* <li><code> Interval</code></li> +* <li><code> SeparatorText</code></li> +* <li><code> SeparatorInterval</code></li> +* <li><code> NumberPosition</code></li> +* <li><code> NumberingType</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.LineNumberingProperties +*/ +public class _LineNumberingProperties extends MultiPropertyTest { + + /** + * This property can be VOID, and in case if it is so new + * value must be defined. + */ + public void _CharStyleName() { + log.println("Testing with custom Property tester") ; + testProperty("CharStyleName", "Endnote Symbol", "Endnote anchor") ; + } + +} + + diff --git a/qadevOOo/tests/java/ifc/text/_MailMerge.java b/qadevOOo/tests/java/ifc/text/_MailMerge.java new file mode 100644 index 000000000..b3c0e1fe4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_MailMerge.java @@ -0,0 +1,167 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.uno.UnoRuntime; + +public class _MailMerge extends MultiPropertyTest { + + /** + * Custom tester for properties which contains URLs. + * Switches between two valid folders + */ + protected PropertyTester URLTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if (oldValue.equals(util.utils.getOfficeTemp(tParam.getMSF()))) + return util.utils.getFullTestURL(""); else + return util.utils.getOfficeTemp(tParam.getMSF()); + } + } ; + + /** + * Custom tester for properties which contains document URLs. + * Switches between two document URLs. + */ + protected PropertyTester DocumentURLTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + if (oldValue.equals(util.utils.getFullTestURL("MailMerge.sxw"))) + return util.utils.getFullTestURL("sForm.sxw"); else + return util.utils.getFullTestURL("MailMerge.sxw"); + } + } ; + /** + * Tested with custom property tester. + */ + public void _ResultSet() { + String propName = "ResultSet"; + try{ + + log.println("try to get value from property..."); + UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName)); + + log.println("try to get value from object relation..."); + XResultSet newValue = UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("MailMerge.XResultSet")); + + log.println("set property to a new value..."); + oObj.setPropertyValue(propName, newValue); + + log.println("get the new value..."); + XResultSet getValue = UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName)); + + tRes.tested(propName, this.compare(newValue, getValue)); + } catch (com.sun.star.beans.PropertyVetoException e){ + log.println("could not set property '"+ propName +"' to a new value!"); + tRes.tested(propName, false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("could not set property '"+ propName +"' to a new value!"); + tRes.tested(propName, false); + } catch (com.sun.star.beans.UnknownPropertyException e){ + if (this.isOptional(propName)){ + // skipping optional property test + log.println("Property '" + propName + + "' is optional and not supported"); + tRes.tested(propName,true); + + } else { + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } + + /** + * Tested with custom property tester. + */ + + public void _ActiveConnection() { + String propName = "ActiveConnection"; + try{ + + log.println("try to get value from property..."); + UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName)); + + log.println("try to get value from object relation..."); + XConnection newValue = UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("MailMerge.XConnection")); + + log.println("set property to a new value..."); + oObj.setPropertyValue(propName, newValue); + + log.println("get the new value..."); + XConnection getValue = UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName)); + + tRes.tested(propName, this.compare(newValue, getValue)); + } catch (com.sun.star.beans.PropertyVetoException e){ + log.println("could not set property '"+ propName +"' to a new value! " + e.toString()); + tRes.tested(propName, false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("could not set property '"+ propName +"' to a new value! " + e.toString()); + tRes.tested(propName, false); + } catch (com.sun.star.beans.UnknownPropertyException e){ + if (this.isOptional(propName)){ + // skipping optional property test + log.println("Property '" + propName + + "' is optional and not supported"); + tRes.tested(propName,true); + + } else { + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } + + /** + * Tested with custom property tester. + */ + public void _DocumentURL() { + log.println("Testing with custom Property tester") ; + testProperty("DocumentURL", DocumentURLTester) ; + } + + /** + * Tested with custom property tester. + */ + public void _OutputURL() { + log.println("Testing with custom Property tester") ; + testProperty("OutputURL", URLTester) ; + } + + /** + * Forces environment recreation. + */ + @Override + protected void after() { + disposeEnvironment(); + } + + +} //finish class _MailMerge + diff --git a/qadevOOo/tests/java/ifc/text/_NumberingLevel.java b/qadevOOo/tests/java/ifc/text/_NumberingLevel.java new file mode 100644 index 000000000..e3eace420 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_NumberingLevel.java @@ -0,0 +1,163 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import lib.StatusException; +import lib.TestParameters; +import share.LogWriter; + +import com.sun.star.beans.PropertyValue; + + +/** +* Testing <code>com.sun.star.text.NumberingLevel</code><p> +* This service is currently known as property value of +* com.sun.star.text.ParagraphProperties.NumberingRules +* This test checks only for completeness of implemented properties. +* service properties : +* <ul> +* <li><code> Adjust</code></li> +* <li><code> ParentNumbering</code></li> +* <li><code> Prefix</code></li> +* <li><code> Suffix</code></li> +* <li><code> CharStyleName</code></li> +* <li><code> BulletId</code></li> +* <li><code> BulletChar</code></li> +* <li><code> BulletFontName</code></li> +* <li><code> BulletFont</code></li> +* <li><code> GraphicURL</code></li> +* <li><code> GraphicBitmap</code></li> +* <li><code> GraphicSize</code></li> +* <li><code> VertOrient</code></li> +* <li><code> StartWith</code></li> +* <li><code> LeftMargin</code></li> +* <li><code> SymbolTextDistance</code></li> +* <li><code> FirstLineOffset</code></li> +* <li><code> NumberingType</code></li> +* <li><code> HeadingStyleName</code></li> +* <li><code> BulletColor</code></li> +* <li><code> BulletRelSize</code></li> +* </ul> <p> +* +* @see com.sun.star.text.NumberingLevel +* @see com.sun.star.test.ParagraphProperties +* @see ifc.style._ParagraphProperties +*/ +public class _NumberingLevel { + + private HashMap<String, Boolean> NumberingLevel = new HashMap<String,Boolean>(); + private PropertyValue[] PropertyArray = null; + private LogWriter log = null; + + + /** + * returns an instance of _NumberingLevel + * @param log the log writer + * @param tParam the test parameters + * @param propertyValues a PropertyValue[] which should contain all properties of com.sun.star.text.NumberingLevel + */ + public _NumberingLevel(LogWriter log, TestParameters tParam, PropertyValue[] propertyValues){ + + this.PropertyArray = propertyValues; + + this.log = log; + + //key = PropertyName, value = Ooptional + NumberingLevel.put("Adjust", Boolean.FALSE); + NumberingLevel.put("ParentNumbering", Boolean.TRUE); + NumberingLevel.put("Prefix", Boolean.FALSE); + NumberingLevel.put("Suffix", Boolean.FALSE); + NumberingLevel.put("CharStyleName", Boolean.TRUE); + NumberingLevel.put("BulletId", Boolean.TRUE); + NumberingLevel.put("BulletChar", Boolean.FALSE); + NumberingLevel.put("BulletFontName", Boolean.FALSE); + NumberingLevel.put("BulletFont", Boolean.TRUE); + NumberingLevel.put("GraphicURL", Boolean.FALSE); + NumberingLevel.put("GraphicBitmap", Boolean.TRUE); + NumberingLevel.put("GraphicSize", Boolean.TRUE); + NumberingLevel.put("VertOrient", Boolean.TRUE); + NumberingLevel.put("StartWith", Boolean.TRUE); + NumberingLevel.put("LeftMargin", Boolean.FALSE); + NumberingLevel.put("SymbolTextDistance", Boolean.TRUE); + NumberingLevel.put("FirstLineOffset", Boolean.FALSE); + NumberingLevel.put("NumberingType", Boolean.FALSE); + NumberingLevel.put("HeadingStyleName", Boolean.FALSE); + NumberingLevel.put("BulletColor", Boolean.TRUE); + NumberingLevel.put("BulletRelSize", Boolean.TRUE); + + } + + /** + * This method checks the PropertyValue for completeness. If one or more properties + * are missing the return value is FALSE, else TRUE + * @return returns TRUE if PropertyValue[] is complete, else FALSE + */ + public boolean testPropertyArray(){ + + boolean status = true; + try{ + + // iterate over the given property array and remove it from the must list + for (int i = 0; i < PropertyArray.length; i++){ + String propertyName=PropertyArray[i].Name; + + if ( NumberingLevel.containsKey(propertyName) ) { + NumberingLevel.remove(propertyName); + } else { + if ( status ) { + log.println("FAILED: com.sun.star.text.NumberingLevel -> " + + "found not described property:"); + } + + status = false; + log.println("-> '" + propertyName + "'"); + } + + } + + // get rest of properties and check if they are optional + if (! NumberingLevel.isEmpty()){ + for (Map.Entry<String,Boolean> e : NumberingLevel.entrySet()) { + // if some elements are not optional -> failed + if (!e.getValue().booleanValue()) { + + if ( status ) { + log.println("FAILED: com.sun.star.text.NumberingLevel -> " + + "could not find not optional property:"); + } + + status = false; + log.println("-> '" + e.getKey() + "'"); + } + } + } + + }catch( Exception e ){ + throw new StatusException("ERROR: could not test all properties of com.sun.star.text.NumberingLevel",e); + } + + return status; + } + + +} // finish class _NumberingLevel diff --git a/qadevOOo/tests/java/ifc/text/_NumberingRules.java b/qadevOOo/tests/java/ifc/text/_NumberingRules.java new file mode 100644 index 000000000..925ccd4f6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_NumberingRules.java @@ -0,0 +1,39 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.NumberingRules</code> +* service properties : +* <ul> +* <li><code> IsAbsoluteMargins</code></li> +* <li><code> IsAutomatic</code></li> +* <li><code> IsContinuousNumbering</code></li> +* <li><code> Name</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.NumberingRules +*/ +public class _NumberingRules extends MultiPropertyTest { + +} // finish class _NumberingRules + + diff --git a/qadevOOo/tests/java/ifc/text/_PrintSettings.java b/qadevOOo/tests/java/ifc/text/_PrintSettings.java new file mode 100644 index 000000000..a1736adab --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_PrintSettings.java @@ -0,0 +1,47 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.PrintSettings</code> +* service properties : +* <ul> +* <li><code> PrintGraphics</code></li> +* <li><code> PrintTables</code></li> +* <li><code> PrintDrawings</code></li> +* <li><code> PrintLeftPages</code></li> +* <li><code> PrintRightPages</code></li> +* <li><code> PrintControls</code></li> +* <li><code> PrintReversed</code></li> +* <li><code> PrintPaperFromSetup</code></li> +* <li><code> PrintFaxName</code></li> +* <li><code> PrintAnnotationMode</code></li> +* <li><code> PrintProspect</code></li> +* <li><code> PrintPageBackground</code></li> +* <li><code> PrintBlackFonts</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.PrintSettings +*/ +public class _PrintSettings extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/text/_Text.java b/qadevOOo/tests/java/ifc/text/_Text.java new file mode 100644 index 000000000..abf93948c --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_Text.java @@ -0,0 +1,26 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +public class _Text extends MultiPropertyTest { + +} //finish class _BaseFrame + diff --git a/qadevOOo/tests/java/ifc/text/_TextColumns.java b/qadevOOo/tests/java/ifc/text/_TextColumns.java new file mode 100644 index 000000000..93ef30505 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextColumns.java @@ -0,0 +1,64 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +import com.sun.star.text.XTextColumns; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.text.TextColumns</code> +* service properties : +* <ul> +* <li><code> IsAutomatic</code></li> +* <li><code> AutomaticDistance</code></li> +* <li><code> SeparatorLineWidth</code></li> +* <li><code> SeparatorLineColor</code></li> +* <li><code> SeparatorLineRelativeHeight</code></li> +* <li><code> SeparatorLineVerticalAlignment</code></li> +* <li><code> SeparatorLineIsOn</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.TextColumns +*/ +public class _TextColumns extends MultiPropertyTest { + + + /** + * Redefined method returns specific value, that differs from property + * value. ( (oldValue + referenceValue) / 2 ). + */ + public void _AutomaticDistance() { + log.println("Testing with custom Property tester") ; + testProperty("AutomaticDistance", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + XTextColumns xTC = UnoRuntime.queryInterface + (XTextColumns.class,tEnv.getTestObject()); + int ref = xTC.getReferenceValue(); + int setting = ( ( (Integer) oldValue).intValue() + ref) / 2; + return Integer.valueOf(setting); + } + }); + } + + +} //finish class _TextColumns + diff --git a/qadevOOo/tests/java/ifc/text/_TextContent.java b/qadevOOo/tests/java/ifc/text/_TextContent.java new file mode 100644 index 000000000..f414e3c2b --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextContent.java @@ -0,0 +1,37 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.TextContent</code> +* service properties : +* <ul> +* <li><code> AnchorType</code></li> +* <li><code> AnchorTypes</code></li> +* <li><code> TextWrap</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.TextContent +*/ +public class _TextContent extends MultiPropertyTest { + +} //finish class _TextContent + diff --git a/qadevOOo/tests/java/ifc/text/_TextDocument.java b/qadevOOo/tests/java/ifc/text/_TextDocument.java new file mode 100644 index 000000000..4f668bcdc --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextDocument.java @@ -0,0 +1,39 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.text.TextDocument</code> +* service properties : +* <ul> +* <li><code> CharLocale</code></li> +* <li><code> CharacterCount</code></li> +* <li><code> ParagraphCount</code></li> +* <li><code> WordCount</code></li> +* <li><code> WordSeparator</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.text.TextDocument +*/ +public class _TextDocument extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/text/_TextEmbeddedObject.java b/qadevOOo/tests/java/ifc/text/_TextEmbeddedObject.java new file mode 100644 index 000000000..2ee2609f4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextEmbeddedObject.java @@ -0,0 +1,59 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import lib.MultiPropertyTest; + + +/** + * Testing <code>com.sun.star.text.TextEmbeddedObject</code> + * service properties : + * <ul> + * <li><code> CLSID</code></li> + * <li><code> Model</code></li> + * <li><code> Component</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextEmbeddedObject + */ +public class _TextEmbeddedObject extends MultiPropertyTest { + + /** + * This property can't be set, as soon as the object is inserted + * so the set method will be skipped. + */ + public void _CLSID() { + boolean result = false; + + try { + String clsid = (String) oObj.getPropertyValue("CLSID"); + log.println("Getting " + clsid); + log.println( + "According to the idl-description this property can't be set as soon as the Object is inserted in the document, so setting will be skipped"); + result=true; + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("Exception while getting Property 'CLSID' " + + e.getMessage()); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception while getting Property 'CLSID' " + + e.getMessage()); + } + + tRes.tested("CLSID", result); + } +} // finish class _TextEmbeddedObject diff --git a/qadevOOo/tests/java/ifc/text/_TextFieldMaster.java b/qadevOOo/tests/java/ifc/text/_TextFieldMaster.java new file mode 100644 index 000000000..cb343f482 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextFieldMaster.java @@ -0,0 +1,37 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.text.TextFieldMaster</code> + * service properties : + * <ul> + * <li><code> Name</code></li> + * <li><code> DependentTextFields</code></li> + * <li><code> InstanceName</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextFieldMaster + */ +public class _TextFieldMaster extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/text/_TextFrame.java b/qadevOOo/tests/java/ifc/text/_TextFrame.java new file mode 100644 index 000000000..a23d22862 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextFrame.java @@ -0,0 +1,61 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.text.TextFrame</code> + * service properties : + * <ul> + * <li><code> FrameHeightAbsolute</code></li> + * <li><code> FrameWidthAbsolute</code></li> + * <li><code> FrameWidthPercent</code></li> + * <li><code> FrameHeightPercent</code></li> + * <li><code> FrameIsAutomaticHeight</code></li> + * <li><code> SizeType</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextFrame + */ +public class _TextFrame extends MultiPropertyTest { + + /** + * Property tester which switches two shorts. + */ + protected PropertyTester WModeTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) + throws java.lang.IllegalArgumentException { + if (oldValue.equals(Short.valueOf(com.sun.star.text.WritingMode2.LR_TB))) + return Short.valueOf(com.sun.star.text.WritingMode2.TB_LR); else + return Short.valueOf(com.sun.star.text.WritingMode2.LR_TB); + } + } ; + + /** + * This property must have predefined values + */ + public void _WritingMode() { + log.println("Testing with custom Property tester") ; + testProperty("WritingMode", WModeTester) ; + } + +} //finish class _TextFrame + diff --git a/qadevOOo/tests/java/ifc/text/_TextGraphicObject.java b/qadevOOo/tests/java/ifc/text/_TextGraphicObject.java new file mode 100644 index 000000000..10d6e8d88 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextGraphicObject.java @@ -0,0 +1,162 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import com.sun.star.awt.Point; +import com.sun.star.container.XIndexContainer; +import com.sun.star.uno.UnoRuntime; + +import java.util.Random; + +import lib.MultiPropertyTest; + +import util.utils; + + +/** + * Testing <code>com.sun.star.text.TextGraphicObject</code> + * service properties : + * <ul> + * <li><code> ImageMap</code></li> + * <li><code> ContentProtected</code></li> + * <li><code> SurroundContour</code></li> + * <li><code> ContourOutside</code></li> + * <li><code> ContourPolyPolygon</code></li> + * <li><code> GraphicCrop</code></li> + * <li><code> HoriMirroredOnEvenPages</code></li> + * <li><code> HoriMirroredOnOddPages</code></li> + * <li><code> VertMirrored</code></li> + * <li><code> GraphicURL</code></li> + * <li><code> GraphicFilter</code></li> + * <li><code> ActualSize</code></li> + * <li><code> AdjustLuminance</code></li> + * <li><code> AdjustContrast</code></li> + * <li><code> AdjustRed</code></li> + * <li><code> AdjustGreen</code></li> + * <li><code> AdjustBlue</code></li> + * <li><code> Gamma</code></li> + * <li><code> GraphicIsInverted</code></li> + * <li><code> Transparency</code></li> + * <li><code> GraphicColorMode</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'ImageMap'</code> (an implementation of + * <code>com.sun.star.image.ImageMapObject</code>): + * is used to insert a new Map into collection + * from 'ImageMap' property. </li> + * <ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextGraphicObject + */ +public class _TextGraphicObject extends MultiPropertyTest { + public Random rdm = new Random(); + + /** + * The tester which can change a sequence of <code>Point</code>'s + * or create a new one if necessary. + */ + protected PropertyTester PointTester = new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) + throws java.lang.IllegalArgumentException { + if (utils.isVoid(oldValue)) { + return newPoint(); + } else { + return changePoint((Point[][]) oldValue); + } + } + }; + + /** + * Tested with custom <code>PointTester</code>. + */ + public void _ContourPolyPolygon() { + log.println("Testing with custom Property tester"); + testProperty("ContourPolyPolygon", PointTester); + } + + /** + * Retrieves an ImageMap from relation and inserts it to the collection + * obtained as property value. Then this collection is set back. + * After that property value is get again. The number of elements + * in the old collection and in just gotten collection is checked. + * + * Has <b>OK</b> status if the number of elements in the new obtained + * collection is greater than in old one. + */ + public void _ImageMap() { + boolean result = true; + + try { + XIndexContainer imgMap = UnoRuntime.queryInterface( + XIndexContainer.class, + oObj.getPropertyValue("ImageMap")); + int previous = imgMap.getCount(); + log.println("Count (previous) " + previous); + + Object im = tEnv.getObjRelation("IMGMAP"); + imgMap.insertByIndex(0, im); + oObj.setPropertyValue("ImageMap", imgMap); + imgMap = UnoRuntime.queryInterface( + XIndexContainer.class, + oObj.getPropertyValue("ImageMap")); + + int after = imgMap.getCount(); + log.println("Count (after) " + after); + result = previous < after; + } catch (Exception ex) { + result = false; + } + + tRes.tested("ImageMap", result); + } + + /** + * Creates a new random points sequence. + */ + public Point[][] newPoint() { + Point[][] res = new Point[1][185]; + + for (int i = 0; i < res[0].length; i++) { + res[0][i] = new Point(); + res[0][i].X = rd() * rd() * rd(); + res[0][i].Y = rd() * rd() * rd(); + } + + return res; + } + + public int rd() { + return rdm.nextInt(6); + } + + /** + * Changes the existing point sequence. + */ + public Point[][] changePoint(Point[][] oldPoint) { + Point[][] res = oldPoint; + + for (int i = 0; i < res[0].length; i++) { + res[0][i].X += 1; + res[0][i].Y += 1; + } + + return res; + } +} // finish class _TextGraphicObject diff --git a/qadevOOo/tests/java/ifc/text/_TextPortion.java b/qadevOOo/tests/java/ifc/text/_TextPortion.java new file mode 100644 index 000000000..24096fe6d --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextPortion.java @@ -0,0 +1,48 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +import com.sun.star.text.ControlCharacter; + +/** + * Testing <code>com.sun.star.text.TextPortion</code> + * service properties : + * <ul> + * <li><code> TextPortionType</code></li> + * <li><code> ControlCharacter</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextPortion + */ +public class _TextPortion extends MultiPropertyTest { + + /** + * This property can be void, so if old value is <code> null </code> + * new value must be specified. + */ + public void _ControlCharacter() { + testProperty("ControlCharacter", + Short.valueOf(ControlCharacter.LINE_BREAK), + Short.valueOf(ControlCharacter.PARAGRAPH_BREAK)) ; + } + +} //finish class _TextPortion + diff --git a/qadevOOo/tests/java/ifc/text/_TextSection.java b/qadevOOo/tests/java/ifc/text/_TextSection.java new file mode 100644 index 000000000..3c756a60f --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextSection.java @@ -0,0 +1,142 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +import com.sun.star.text.XTextColumns; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + +/** + * Testing <code>com.sun.star.text.TextSection</code> + * service properties : + * <ul> + * <li><code> Condition</code></li> + * <li><code> IsVisible</code></li> + * <li><code> IsProtected</code></li> + * <li><code> FileLink</code></li> + * <li><code> LinkRegion</code></li> + * <li><code> DDECommandType</code></li> + * <li><code> DDECommandFile</code></li> + * <li><code> DDECommandElement</code></li> + * <li><code> BackGraphicURL</code></li> + * <li><code> BackGraphicFilter</code></li> + * <li><code> BackGraphicLocation</code></li> + * <li><code> FootnoteIsCollectAtTextEnd</code></li> + * <li><code> FootnoteIsRestartNumbering</code></li> + * <li><code> FootnoteRestartNumberingAt</code></li> + * <li><code> FootnoteIsOwnNumbering</code></li> + * <li><code> FootnoteNumberingType</code></li> + * <li><code> FootnoteNumberingPrefix</code></li> + * <li><code> FootnoteNumberingSuffix</code></li> + * <li><code> EndnoteIsCollectAtTextEnd</code></li> + * <li><code> EndnoteIsRestartNumbering</code></li> + * <li><code> EndnoteRestartNumberingAt</code></li> + * <li><code> EndnoteIsOwnNumbering</code></li> + * <li><code> EndnoteNumberingType</code></li> + * <li><code> EndnoteNumberingPrefix</code></li> + * <li><code> EndnoteNumberingSuffix</code></li> + * <li><code> IsAutomaticUpdate</code></li> + * </ul> <p> + * The following predefined files needed to complete the test: + * <ul> + * <li> <code>crazy-blue.jpg, space-metal.jpg</code> : are used for + * setting 'BackGraphicURL' property. </li> + * <ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextSection + */ +public class _TextSection extends MultiPropertyTest { + + /** + * Only image file URL can be used as a value. + */ + public void _BackGraphicURL() { + log.println("Testing with custom Property tester") ; + testProperty("BackGraphicURL", + util.utils.getFullTestURL("crazy-blue.jpg"), + util.utils.getFullTestURL("space-metal.jpg")) ; + } + + /** + * This property can be void, so if old value is <code> null </code> + * new value must be specified. + */ + public void _FootnoteNumberingType() { + log.println("Testing with custom Property tester") ; + testProperty("FootnoteNumberingType", + Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT), + Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_PAGE)) ; + } + + + /** + * Custom property tester for property <code>TextColumns</code> + */ + protected PropertyTester TextColumnsTester = new PropertyTester() { + + @Override + protected Object getNewValue(String propName, Object oldValue) { + XTextColumns TC = null; + short val2set = 25; + + TC = (XTextColumns) tEnv.getObjRelation("TC"); + try { + val2set += ((XTextColumns) AnyConverter.toObject( + new Type(XTextColumns.class),oldValue)).getColumnCount(); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + log.println("Couldn't change Column count"); + } + TC.setColumnCount(val2set); + + return TC; + } + + @Override + protected boolean compare(Object obj1, Object obj2) { + short val1 = 0; + short val2 = 1; + try { + val1 = ((XTextColumns) AnyConverter.toObject( + new Type(XTextColumns.class),obj1)).getColumnCount(); + val2 = ((XTextColumns) AnyConverter.toObject( + new Type(XTextColumns.class),obj2)).getColumnCount(); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + log.println("comparing values failed"); + } + return val1 == val2; + } + + @Override + protected String toString(Object obj) { + return "XTextColumns: ColumnCount = "+ + ((XTextColumns) obj).getColumnCount(); + } + + }; + + public void _TextColumns() { + log.println("Testing with custom Property tester"); + testProperty("TextColumns", TextColumnsTester); + } + + +} //finish class _TextContent + diff --git a/qadevOOo/tests/java/ifc/text/_TextTable.java b/qadevOOo/tests/java/ifc/text/_TextTable.java new file mode 100644 index 000000000..ad3645d22 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextTable.java @@ -0,0 +1,110 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.text.TextTable</code> + * service properties : + * <ul> + * <li><code> BreakType</code></li> + * <li><code> LeftMargin</code></li> + * <li><code> RightMargin</code></li> + * <li><code> HoriOrient</code></li> + * <li><code> KeepTogether</code></li> + * <li><code> Split</code></li> + * <li><code> PageNumberOffset</code></li> + * <li><code> PageDescName</code></li> + * <li><code> RelativeWidth</code></li> + * <li><code> IsWidthRelative</code></li> + * <li><code> RepeatHeadline</code></li> + * <li><code> ShadowFormat</code></li> + * <li><code> TopMargin</code></li> + * <li><code> BottomMargin</code></li> + * <li><code> BackTransparent</code></li> + * <li><code> Width</code></li> + * <li><code> ChartRowAsLabel</code></li> + * <li><code> ChartColumnAsLabel</code></li> + * <li><code> TableBorder</code></li> + * <li><code> TableColumnSeparators</code></li> + * <li><code> TableColumnRelativeSum</code></li> + * <li><code> BackColor</code></li> + * <li><code> BackGraphicURL</code></li> + * <li><code> BackGraphicFilter</code></li> + * <li><code> BackGraphicLocation</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextTable + */ +public class _TextTable extends MultiPropertyTest { + + /** + * This property accepts only restricted range of values. + * The property value is switched between '' and 'Standard' + * strings. + */ + public void _PageDescName() { + testProperty("PageDescName", "Endnote", "Standard"); + } + + /** + * For setting this property, 'HoriOrient' property must be + * set to non-automatic. + */ + public void _Width() { + Short align = Short.valueOf(com.sun.star.text.HoriOrientation.CENTER); + try { + oObj.setPropertyValue("HoriOrient",align); + } + catch (com.sun.star.lang.IllegalArgumentException ex) {} + catch (com.sun.star.lang.WrappedTargetException ex) {} + catch (com.sun.star.beans.PropertyVetoException ex) {} + catch (com.sun.star.beans.UnknownPropertyException ex) {} + + testProperty("Width"); + } + + /** + * For setting this property, 'HoriOrient' property must be + * set to non-automatic. + */ + public void _RelativeWidth() { + Short align = Short.valueOf(com.sun.star.text.HoriOrientation.CENTER); + try { + oObj.setPropertyValue("HoriOrient",align); + } + catch (com.sun.star.lang.IllegalArgumentException ex) {} + catch (com.sun.star.lang.WrappedTargetException ex) {} + catch (com.sun.star.beans.PropertyVetoException ex) {} + catch (com.sun.star.beans.UnknownPropertyException ex) {} + + testProperty("RelativeWidth"); + } + + /** + * Forces environment recreation. + */ + @Override + protected void after() { + disposeEnvironment(); + } + +} // finish class _TextTable + diff --git a/qadevOOo/tests/java/ifc/text/_TextTableRow.java b/qadevOOo/tests/java/ifc/text/_TextTableRow.java new file mode 100644 index 000000000..7bd23f22e --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_TextTableRow.java @@ -0,0 +1,43 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.text.TextTableRow</code> + * service properties : + * <ul> + * <li><code> BackColor</code></li> + * <li><code> BackTransparent</code></li> + * <li><code> VertOrient</code></li> + * <li><code> BackGraphicURL</code></li> + * <li><code> BackGraphicFilter</code></li> + * <li><code> BackGraphicLocation</code></li> + * <li><code> TableColumnSeparators</code></li> + * <li><code> Height</code></li> + * <li><code> IsAutoHeight</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.TextTableRow + */ +public class _TextTableRow extends MultiPropertyTest { + +} // finish class _TextTableRow + diff --git a/qadevOOo/tests/java/ifc/text/_ViewSettings.java b/qadevOOo/tests/java/ifc/text/_ViewSettings.java new file mode 100644 index 000000000..676fe27db --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_ViewSettings.java @@ -0,0 +1,61 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.text.ViewSettings</code> + * service properties : + * <ul> + * <li><code> ShowAnnotations</code></li> + * <li><code> ShowBreaks</code></li> + * <li><code> ShowDrawings</code></li> + * <li><code> ShowFieldCommands</code></li> + * <li><code> ShowFootnoteBackground</code></li> + * <li><code> ShowGraphics</code></li> + * <li><code> ShowHiddenParagraphs</code></li> + * <li><code> ShowHiddenText</code></li> + * <li><code> ShowHoriRuler</code></li> + * <li><code> ShowHoriScrollBar</code></li> + * <li><code> ShowIndexMarkBackground</code></li> + * <li><code> ShowParaBreaks</code></li> + * <li><code> ShowProtectedSpaces</code></li> + * <li><code> ShowSoftHyphens</code></li> + * <li><code> ShowSpaces</code></li> + * <li><code> ShowTableBoundaries</code></li> + * <li><code> ShowTables</code></li> + * <li><code> ShowTabstops</code></li> + * <li><code> ShowTextBoundaries</code></li> + * <li><code> ShowTextFieldBackground</code></li> + * <li><code> ShowVertRuler</code></li> + * <li><code> ShowVertScrollBar</code></li> + * <li><code> SmoothScrolling</code></li> + * <li><code> IsVertRulerRightAligned</code></li> + * <li><code> ShowOnlineLayout</code></li> + * <li><code> ZoomType</code></li> + * <li><code> ZoomValue</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.text.ViewSettings + */ +public class _ViewSettings extends MultiPropertyTest { + +} // finish class _ViewSettings + diff --git a/qadevOOo/tests/java/ifc/text/_XAutoTextContainer.java b/qadevOOo/tests/java/ifc/text/_XAutoTextContainer.java new file mode 100644 index 000000000..fed159a32 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XAutoTextContainer.java @@ -0,0 +1,132 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.text.XAutoTextGroup; + +/** + * Testing <code>com.sun.star.text.XAutoTextContainer</code> + * interface methods : + * <ul> + * <li><code> insertNewByName()</code></li> + * <li><code> removeByName()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XAutoTextContainer + */ +public class _XAutoTextContainer extends MultiMethodTest { + public XAutoTextContainer oObj = null; + // every Thread must insert its own AutoTextContainer: + public String Name = ""; + + /** + * First removes old element from container with the specified name + * if it exists. Then tries to add a new group with the specified + * name. <p> + * + * Has <b>OK</b> status if not <code>null</code> + * <code>AutoTextGroup</code> instance is returned. + */ + public void _insertNewByName() { + System.out.println("Starting: insertNewByName"); + boolean result = true; + Name = "XAutoTextContainerx" + Thread.currentThread().getName(); + Name = Name.replace('-','x'); + Name = Name.replace(':','x'); + Name = Name.replace('.','x'); + XAutoTextGroup oGroup = null; + //first clear the container + log.println("remove old elements in container"); + System.out.println("remove old elements in container"); + try { + oObj.removeByName(Name); + log.println("old elements removed -> OK"); + System.out.println("old elements removed -> OK"); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("no old elements available -> OK"); + System.out.println("no old elements available -> OK"); + } + + // insert an element + log.println("insertNewByName"); + try { + System.out.println("Inserting element with name '" + Name + "'"); + log.println("Inserting element with name '" + Name + "'"); + oGroup = oObj.insertNewByName(Name); + System.out.println("done"); + } catch (com.sun.star.container.ElementExistException e) { + log.println("insertNewByName(): " + e); + result &= false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("insertNewByName(): " + e); + result &= false; + } + + result &= ( oGroup != null ); + tRes.tested("insertNewByName()", result); + } // end insertNewByName() + + /** + * First removes element by name which was added before, + * then tries to remove the element with the same name again. <p> + * + * Has <b> OK </b> status if in the first case no exceptions + * were thrown, and in the second case + * <code>NoSuchElementException</code> was thrown. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertNewByName() </code> : new element inserted here.</li> + * </ul> + */ + public void _removeByName() { + requiredMethod("insertNewByName()"); + + boolean result = true; + // remove the element + log.println("removeByName()"); + try { + log.println("Removing element with name '" + Name + "'"); + oObj.removeByName(Name); + result &= true; + } catch (com.sun.star.container.NoSuchElementException e) { + result = false; + log.println("removeByName(): " + e + " -> FAILED"); + } + + log.println("2nd removeByName()"); + try { + oObj.removeByName(Name); + log.println("No exceptions were thrown -> FAILED"); + result = false ; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("2nd removeByName(): -> OK"); + result &= true; + } + + tRes.tested("removeByName()", result); + + } // end removeByName() + +} /// finish class XAutoTextContainer + + diff --git a/qadevOOo/tests/java/ifc/text/_XAutoTextEntry.java b/qadevOOo/tests/java/ifc/text/_XAutoTextEntry.java new file mode 100644 index 000000000..5f9b19634 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XAutoTextEntry.java @@ -0,0 +1,69 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.text.XAutoTextEntry; +import com.sun.star.text.XTextDocument; + +/** + * Testing <code>com.sun.star.text.XAutoTextEntry</code> + * interface methods : + * <ul> + * <li><code> applyTo()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>): + * the text document for creating a text range.</li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XAutoTextEntry + */ +public class _XAutoTextEntry extends MultiMethodTest { + + public XAutoTextEntry oObj = null; + + /** + * Applies the entry to a range created for the text document obtained from + * relation 'TEXTDOC'. <p> + * Has <b> OK </b> status if text of the document was changed. <p> + */ + public void _applyTo() { + XTextDocument textDoc = (XTextDocument)tEnv.getObjRelation("TEXTDOC"); + if (textDoc == null) { + throw new StatusException + (Status.failed("Couldn't get relation 'TEXTDOC'")); + } + + String oldText = textDoc.getText().getString(); + oObj.applyTo(textDoc.getText().createTextCursor()); + String newText = textDoc.getText().getString(); + + log.println("Old text:\n" + oldText + "\nNew text:\n" + newText); + + tRes.tested("applyTo()", ! newText.equals(oldText)); + } + +} // finish class _XAutoTextEntry + + diff --git a/qadevOOo/tests/java/ifc/text/_XAutoTextGroup.java b/qadevOOo/tests/java/ifc/text/_XAutoTextGroup.java new file mode 100644 index 000000000..9a67c4301 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XAutoTextGroup.java @@ -0,0 +1,299 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.ValueComparer; + +import com.sun.star.text.XAutoTextGroup; +import com.sun.star.text.XTextRange; + +/** + * Testing <code>com.sun.star.text.XAutoTextGroup</code> + * interface methods : + * <ul> + * <li><code> getTitles()</code></li> + * <li><code> renameByName()</code></li> + * <li><code> insertNewByName()</code></li> + * <li><code> removeByName()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'TextRange'</code> (of type <code>XTextRange</code>): + * the range for which an entry is added. </li> + * <ul> <p> + * Test is multithread compliant. <p> + * @see com.sun.star.text.XAutoTextGroup + */ +public class _XAutoTextGroup extends MultiMethodTest { + + public XAutoTextGroup oObj = null; + + /** + * Unique number among different interface threads. + */ + protected static int uniq = 0 ; + + /** + * Unique string for AutoTextEntry names among different + * threads. + */ + protected String str = null ; + + /** + * Prefix for unique string. + * @see #str + */ + protected static final String pref = "XAutoTextGroup" ; + protected XTextRange oRange = null; + + /** + * Constructs a unique string for current interface thread + * for naming purposes. All old entries which names are + * started with prefix used for entry names, are deleted + * from the group (they can remain after previous unsuccessful + * test runs). The relation is obtained. + * + * @throws StatusException if the relation is not found. + */ + @Override + public void before() { + str = pref + uniq++ ; + String[] names = oObj.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]); + if (names[i].toUpperCase().indexOf(pref.toUpperCase()) > 0) { + try { + log.println(" ... removing ..."); + oObj.removeByName(names[i]) ; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Element '" + names[i] + "' not found."); + } + } + } + + oRange = (XTextRange) tEnv.getObjRelation("TextRange"); + if (oRange == null) { + throw new StatusException(Status.failed("No relation found")) ; + } + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getTitles() { + + String[] titles = oObj.getTitles(); + tRes.tested("getTitles()",titles != null); + } + + /** + * Firsts inserts a new <code>AutoTextEntry</code> using a range + * from relation, entry titles are checked before and after + * insertion, second tries to add an entry with the same name. <p> + * + * Has <b>OK</b> status if in the first case titles are changed, + * and in the second case <code>ElementExistException</code> is + * thrown. + */ + public void _insertNewByName() { + + boolean result = false; + + try { + String[] before = oObj.getTitles(); + oObj.insertNewByName(str, "For " + str,oRange); + String[] after = oObj.getTitles(); + result = !util.ValueComparer.equalValue(before, after); + } + catch (com.sun.star.container.ElementExistException ex) { + log.println("Exception occurred while testing insertNewByName"); + ex.printStackTrace(log); + result = false; + } + + try { + oObj.insertNewByName(str, "For " + str, oRange); + log.println( + "com::sun::star::container::ElementExistsException wasn't thrown"); + oObj.removeByName(str); + result &= false; + } catch (com.sun.star.container.ElementExistException ex) { + result &= true; + } catch (com.sun.star.container.NoSuchElementException ex) { + log.println("Wrong exception was thrown :"); + ex.printStackTrace(log); + result &= false; + } + + tRes.tested("insertNewByName()",result); + + } + + /** + * Removes <code>AutoTextEntry</code> added before and checks + * titles of the group before and after removing. <p> + * Has <b> OK </b> status if titles are not equal before and after + * removing and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertNewByName() </code> : the entry is + * inserted here. </li> + * </ul> + */ + public void _removeByName() { + requiredMethod("insertNewByName()") ; + + try { + String[] before = oObj.getTitles(); + oObj.removeByName(str); + String[] after = oObj.getTitles(); + tRes.tested("removeByName()", + !ValueComparer.equalValue(before,after)); + } + catch (com.sun.star.container.NoSuchElementException ex) { + log.println("Exception occurred while testing removeByName"); + ex.printStackTrace(log); + tRes.tested("removeByName()",false); + } + } + + /** + * Three cases are tested here : + * <ol> + * <li> Trying to rename an entry to a name, which already + * exists in the group. <code>ElementExistException</code> + * must be thrown. </li> + * <li> Trying to rename an element with non-existing name. + * <code>IllegalArgumentException</code> must be thrown.</li> + * <li> The normal situation : no exceptions must be thrown + * and element with a new name must arise. </li> + * </ol> + * + * Has <b>OK</b> status if all three cases were completed successfully. + */ + public void _renameByName() { + boolean result = false; + + try { + oObj.getTitles(); + oObj.getElementNames(); + oObj.insertNewByName(str,"For " + str,oRange); + oObj.insertNewByName(str + "dup","For " + str,oRange); + oObj.getTitles(); + oObj.getElementNames(); + result = true; + } catch (com.sun.star.container.ElementExistException e) { + log.println("Unexpected exception occurred :") ; + e.printStackTrace(log); + } finally { + if (!result) { + try { + oObj.removeByName(str); + } catch (com.sun.star.container.NoSuchElementException e) {} + try { + oObj.removeByName(str + "dup"); + } catch (com.sun.star.container.NoSuchElementException e) {} + tRes.tested("renameByName()", false); + } + } + + + try { + oObj.renameByName(str, str + "dup", "For "+str); + log.println( + "com::sun::star::container::ElementExistsException wasn't thrown"); + result = false; + } catch (com.sun.star.container.ElementExistException e) { + result = true; + } catch (com.sun.star.io.IOException e) { + log.println("Wrong exception was thrown :"); + e.printStackTrace(log); + result = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Wrong exception was thrown :"); + e.printStackTrace(log); + result = false; + } finally { + try { + oObj.removeByName(str); + } catch (com.sun.star.container.NoSuchElementException e) {} + try { + oObj.removeByName(str + "dup"); + } catch (com.sun.star.container.NoSuchElementException e) {} + } + + try { + oObj.renameByName("~"+str,str,str); + log.println( + "com::sun::star::lang::IllegalArgumentException wasn't thrown"); + result &= false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + result &= true; + } catch (com.sun.star.container.ElementExistException e) { + log.println("Unexpected exception :") ; + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.io.IOException e) { + log.println("Unexpected exception :") ; + e.printStackTrace(log) ; + result = false ; + } finally { + try { + oObj.removeByName(str); + } catch (com.sun.star.container.NoSuchElementException e) {} + } + + try { + oObj.insertNewByName(str, "For " + str, oRange); + + oObj.renameByName(str,str+"a",str+"b"); + result &= oObj.hasByName(str + "a"); + } catch (com.sun.star.container.ElementExistException ex) { + log.println("Exception occurred while testing renameByName"); + ex.printStackTrace(log); + result &=false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred while testing renameByName"); + ex.printStackTrace(log); + result &=false; + } catch (com.sun.star.io.IOException ex) { + log.println("Exception occurred while testing renameByName"); + ex.printStackTrace(log); + result &=false; + } finally { + try { + oObj.removeByName(str); + } catch (com.sun.star.container.NoSuchElementException e) {} + try { + oObj.removeByName(str + "a"); + } catch (com.sun.star.container.NoSuchElementException e) {} + } + + tRes.tested("renameByName()",result); + + } + +} // finish class _XAutoTextGroup + + diff --git a/qadevOOo/tests/java/ifc/text/_XBookmarksSupplier.java b/qadevOOo/tests/java/ifc/text/_XBookmarksSupplier.java new file mode 100644 index 000000000..d01fc5686 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XBookmarksSupplier.java @@ -0,0 +1,55 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XBookmarksSupplier; +import lib.MultiMethodTest; + + +/** + * Testing <code>com.sun.star.text.XBookmarksSupplier</code> + * interface methods : + * <ul> + * <li><code> getBookmarks()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XBookmarksSupplier + */ +public class _XBookmarksSupplier extends MultiMethodTest { + + public static XBookmarksSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the collection returned has at least + * one element. + */ + public void _getBookmarks() { + boolean res = false; + + XNameAccess the_bookmarks = oObj.getBookmarks(); + log.println("Found: "); + util.dbg.printArray(the_bookmarks.getElementNames()); + res = the_bookmarks.getElementNames().length>0; + + tRes.tested("getBookmarks()",res); + } + +} // finish class _XBookmarksSupplier diff --git a/qadevOOo/tests/java/ifc/text/_XChapterNumberingSupplier.java b/qadevOOo/tests/java/ifc/text/_XChapterNumberingSupplier.java new file mode 100644 index 000000000..3cac4bf7c --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XChapterNumberingSupplier.java @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XIndexReplace; +import com.sun.star.text.XChapterNumberingSupplier; + +/** + * Testing <code>com.sun.star.text.XChapterNumberingSupplier</code> + * interface methods : + * <ul> + * <li><code> getChapterNumberingRules()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XChapterNumberingSupplier + */ +public class _XChapterNumberingSupplier extends MultiMethodTest { + + public static XChapterNumberingSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the returned collection + * has at least one element. + */ + public void _getChapterNumberingRules() { + boolean res = false; + + XIndexReplace the_chapter = oObj.getChapterNumberingRules(); + res = the_chapter.hasElements(); + + tRes.tested("getChapterNumberingRules()",res); + } + +} // finish class _XChapterNumberingSupplier + diff --git a/qadevOOo/tests/java/ifc/text/_XDefaultNumberingProvider.java b/qadevOOo/tests/java/ifc/text/_XDefaultNumberingProvider.java new file mode 100644 index 000000000..6a98f0696 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XDefaultNumberingProvider.java @@ -0,0 +1,65 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.Locale; +import com.sun.star.text.XDefaultNumberingProvider; + +/** +* Testing <code>com.sun.star.text.XDefaultNumberingProvider</code> +* interface methods : +* <ul> +* <li><code> getDefaultOutlineNumberings()</code></li> +* <li><code> getDefaultContinuousNumberingLevels()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.text.XDefaultNumberingProvider +*/ +public class _XDefaultNumberingProvider extends MultiMethodTest { + + public static XDefaultNumberingProvider oObj = null; + private final Locale loc = new Locale("en", "EN", "") ; + + /** + * Just gets numberings for "en" locale. <p> + * Has <b>OK</b> status if not <code>null</code> value returned + * and no runtime exceptions occurred. + */ + public void _getDefaultOutlineNumberings() { + XIndexAccess xIA[] = oObj.getDefaultOutlineNumberings(loc) ; + + tRes.tested("getDefaultOutlineNumberings()", xIA != null) ; + } + + /** + * Just gets numberings for "en" locale. <p> + * Has <b>OK</b> status if not <code>null</code> value returned + * and no runtime exceptions occurred. + */ + public void _getDefaultContinuousNumberingLevels() { + PropertyValue[][] lev = oObj.getDefaultContinuousNumberingLevels(loc) ; + + tRes.tested("getDefaultContinuousNumberingLevels()", lev != null) ; + } +} + diff --git a/qadevOOo/tests/java/ifc/text/_XDocumentIndex.java b/qadevOOo/tests/java/ifc/text/_XDocumentIndex.java new file mode 100644 index 000000000..861dbd681 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XDocumentIndex.java @@ -0,0 +1,115 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDocumentIndex; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; + +/** + * Testing <code>com.sun.star.text.XDocumentIndex</code> + * interface methods : + * <ul> + * <li><code> getServiceName()</code></li> + * <li><code> update()</code></li> + * </ul> <p> + * + * This test needs the following object relations : + * <ul> + * <li> <code>'TextDoc'</code> (of type <code>XTextDocument</code>): + * the text document for creating and inserting index mark.</li> + * <ul> <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XDocumentIndex + */ +public class _XDocumentIndex extends MultiMethodTest { + + public XDocumentIndex oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the returned service name + * is equal to 'com.sun.star.text.DocumentIndex'. + */ + public void _getServiceName() { + String serv = oObj.getServiceName(); + tRes.tested("getServiceName()", + serv.equals("com.sun.star.text.DocumentIndex")); + } + + /** + * Gets the document from relation and insert a new index mark. + * Then it stores the text content of document index before + * update and after.<p> + * + * Has <b> OK </b> status if index content is changed and + * new index contains index mark inserted. <p> + */ + public void _update() { + boolean bOK = true; + + try { + XTextDocument xTextDoc = (XTextDocument) + tEnv.getObjRelation("TextDoc"); + XText xText = xTextDoc.getText(); + XTextRange xTR = xText.getEnd(); + xTR.setString("IndexMark"); + + XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + Object idxMark = xDocMSF.createInstance + ("com.sun.star.text.DocumentIndexMark"); + XTextContent xTC = UnoRuntime.queryInterface + (XTextContent.class, idxMark); + xText.insertTextContent(xTR, xTC, true); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't insert index mark."); + e.printStackTrace(log); + bOK = false ; + } + + String contentBefore = oObj.getAnchor().getString(); + log.println("Content before: '" + contentBefore + "'"); + + oObj.update(); + + waitForEventIdle(); + + + String contentAfter = oObj.getAnchor().getString(); + log.println("Content after: '" + contentAfter + "'"); + + bOK &= !contentAfter.equals(contentBefore); + bOK &= contentAfter.indexOf("IndexMark") > -1; + + tRes.tested("update()",bOK); + } + + + +} // finish class _XDocumentIndex + + diff --git a/qadevOOo/tests/java/ifc/text/_XDocumentIndexesSupplier.java b/qadevOOo/tests/java/ifc/text/_XDocumentIndexesSupplier.java new file mode 100644 index 000000000..7d985f822 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XDocumentIndexesSupplier.java @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.XDocumentIndexesSupplier; + +import lib.MultiMethodTest; + + +/** + * Testing <code>com.sun.star.text.XDocumentIndexesSupplier</code> + * interface methods : + * <ul> + * <li><code> getDocumentIndexes()()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XDocumentIndexesSupplier + */ +public class _XDocumentIndexesSupplier extends MultiMethodTest { + + public static XDocumentIndexesSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the collection returned has at least + * one element. + */ + public void _getDocumentIndexes() { + boolean res = false; + + XIndexAccess the_documentIndexes = oObj.getDocumentIndexes(); + res = the_documentIndexes.getCount()>0; + + tRes.tested("getDocumentIndexes()",res); + } + +} // finish class _XDocumentIndexesSupplier diff --git a/qadevOOo/tests/java/ifc/text/_XEndnotesSupplier.java b/qadevOOo/tests/java/ifc/text/_XEndnotesSupplier.java new file mode 100644 index 000000000..b08948a67 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XEndnotesSupplier.java @@ -0,0 +1,72 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.XEndnotesSupplier; + + +/** + * Testing <code>com.sun.star.text.XEndnotesSupplier</code> + * interface methods : + * <ul> + * <li><code> getEndnotes()</code></li> + * <li><code> getEndnoteSettings()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XEndnotesSupplier + */ +public class _XEndnotesSupplier extends MultiMethodTest { + + public static XEndnotesSupplier oObj = null; // oObj filled by MultiMethodTest + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the collection returned has at least + * one element. + */ + public void _getEndnotes() { + boolean res = false; + + XIndexAccess the_endnotes = oObj.getEndnotes(); + res = the_endnotes.hasElements(); + + tRes.tested("getEndnotes()",res); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getEndnoteSettings() { + boolean res = false; + + XPropertySet the_props = oObj.getEndnoteSettings(); + res = ( the_props != null ); + + tRes.tested("getEndnoteSettings()",res); + } + +} // finish class _XEndnotesSupplier + + diff --git a/qadevOOo/tests/java/ifc/text/_XFootnote.java b/qadevOOo/tests/java/ifc/text/_XFootnote.java new file mode 100644 index 000000000..6aedd2c75 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XFootnote.java @@ -0,0 +1,101 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import com.sun.star.text.XFootnote; + + +/** + * Testing <code>com.sun.star.text.XFootnote</code> + * interface methods : + * <ul> + * <li><code> getLabel()</code></li> + * <li><code> setLabel()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XFootnote + */ +public class _XFootnote extends MultiMethodTest { + + public XFootnote oObj = null; // oObj filled by MultiMethodTest + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getLabel(){ + + boolean result; + + // testing getLabel + log.println("Testing getLabel() ... "); + String oldLabel = oObj.getLabel(); + log.println("getLabel: Old Value: " + oldLabel); + result = (oldLabel != null); + if (result) { + log.println(" ... getLabel() - OK"); + } + else { + log.println(" ... getLabel() - FAILED"); + } + tRes.tested("getLabel()", result); + + } // finished getLabel + + + /** + * Sets a new label, then using <code>getLabel</code> method + * checks if the label was set. <p> + * + * Has <b>OK</b> status if set and get values are equal. + */ + public void _setLabel(){ + + boolean result; + String str = "New XFootnote Label"; + + // testing getLabel + log.println("Testing setLabel() ... "); + log.println("New label : " + str); + + String oldLabel = oObj.getLabel(); + log.println("Old label was: " + oldLabel); + oObj.setLabel(str); + + String res = oObj.getLabel(); + + log.println("verify setLabel result"); + result = res.equals(str); + if (result) { + log.println(" ... setLabel() - OK"); + } + else { + log.println(" ... setLabel() - FAILED"); + } + tRes.tested("setLabel()", result); + + log.println("restoring the old label value"); + oObj.setLabel(oldLabel); + } // finished setLabel + +} + + diff --git a/qadevOOo/tests/java/ifc/text/_XFootnotesSettingsSupplier.java b/qadevOOo/tests/java/ifc/text/_XFootnotesSettingsSupplier.java new file mode 100644 index 000000000..2b53b9e27 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XFootnotesSettingsSupplier.java @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.text.XFootnotesSettingsSupplier; + +/** + * Testing <code>com.sun.star.text.XFootnotesSettingsSupplier</code> + * interface methods : + * <ul> + * <li><code> getFootnoteSettings()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XFootnotesSettingsSupplier + */ +public class _XFootnotesSettingsSupplier extends MultiMethodTest { + public XFootnotesSettingsSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getFootnotesSettings(){ + boolean result = true; + XPropertySet footnoteSettings = null; + + footnoteSettings = oObj.getFootnotesSettings(); + result = footnoteSettings != null; + + tRes.tested("getFootnotesSettings()", result); + } + +} + diff --git a/qadevOOo/tests/java/ifc/text/_XFootnotesSupplier.java b/qadevOOo/tests/java/ifc/text/_XFootnotesSupplier.java new file mode 100644 index 000000000..1cd7b65d9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XFootnotesSupplier.java @@ -0,0 +1,73 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.XFootnotesSupplier; + +/** + * Testing <code>com.sun.star.text.XFootnotesSupplier</code> + * interface methods : + * <ul> + * <li><code> getFootnotes()</code></li> + * <li><code> getFootnoteSettings()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XFootnotesSupplier + */ +public class _XFootnotesSupplier extends MultiMethodTest { + public XFootnotesSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getFootnotes(){ + boolean result = true; + XIndexAccess footnotes = null; + + log.println("testing getFootnotes() ... "); + + footnotes = oObj.getFootnotes(); + result = footnotes != null; + tRes.tested("getFootnotes()", result); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getFootnoteSettings(){ + boolean result = true; + XPropertySet footnoteSettings = null; + + log.println("testing getFootnoteSettings() ... "); + + footnoteSettings = oObj.getFootnoteSettings(); + result = footnoteSettings != null; + + tRes.tested("getFootnoteSettings()", result); + } +} + diff --git a/qadevOOo/tests/java/ifc/text/_XLineNumberingProperties.java b/qadevOOo/tests/java/ifc/text/_XLineNumberingProperties.java new file mode 100644 index 000000000..cf39649b4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XLineNumberingProperties.java @@ -0,0 +1,52 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.text.XLineNumberingProperties; + +/** + * Testing <code>com.sun.star.text.XLineNumberingProperties</code> + * interface methods : + * <ul> + * <li><code> getLineNumberingProperties()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XLineNumberingProperties + */ +public class _XLineNumberingProperties extends MultiMethodTest { + + public XLineNumberingProperties oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getLineNumberingProperties() { + + XPropertySet getting = oObj.getLineNumberingProperties(); + tRes.tested("getLineNumberingProperties()",getting != null); + } + +} // finish class _XLineNumberingProperties + + diff --git a/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java b/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java new file mode 100644 index 000000000..5ac586b43 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XMailMergeBroadcaster.java @@ -0,0 +1,140 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.NamedValue; +import com.sun.star.task.XJob; +import com.sun.star.text.MailMergeEvent; +import com.sun.star.text.XMailMergeBroadcaster; +import com.sun.star.text.XMailMergeListener; + +/** +* Testing <code>com.sun.star.text.XMailMergeBroadcaster</code> +* interface methods: +* <ul> +* <li><code> addMailMergeEventListener() </code></li> +* <li><code> removeMailMergeEventListener() </code></li> +* </ul><p> +* This test needs the following object relations : +* <ul> +* <li> <code>'Job'</code> (of type <code>XJob</code>): +* used to fire MailMergeEvent</li> +* <li> <code>'executeArgs'</code> (of type <code>NamedValue[]</code>): +* used as parameter for <code>'Job'</code> </li> +* </ul> <p> +* +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.text.XMailMergeBroadcaster +*/ +public class _XMailMergeBroadcaster extends MultiMethodTest { + public static XMailMergeBroadcaster oObj = null; + protected boolean changed = false; + + + /** + * Class we need to test methods + */ + protected class MyMailMergeEventListener implements XMailMergeListener { + public void notifyMailMergeEvent ( MailMergeEvent oEvent ) { + System.out.println("Listener called"); + changed = true; + } + } + + protected XMailMergeListener listener = new MyMailMergeEventListener(); + + /** + * Tries to query the tested component for object relation + * <code>executeArgs</code> [<code>NamedValue</code>] and <code>Job</code> + * [<code>XJob</code>] + * @throw StatusException If relations are not found + */ + @Override + public void before() { + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs") ; + if (executeArgs == null) + throw new StatusException(Status.failed + ("'executeArgs' relation not found ")) ; + XJob Job = (XJob) tEnv.getObjRelation("Job") ; + if (Job == null) + throw new StatusException(Status.failed + ("'Job' relation not found ")) ; + } + + /** + * Test executes mail merge process<p> + * Has <b> OK </b> status if listener was called + */ + public void _addMailMergeEventListener() { + log.println("Testing addMailMergeEventListener ..."); + + oObj.addMailMergeEventListener( listener ); + + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs"); + XJob Job = (XJob) tEnv.getObjRelation("Job"); + + try { + Job.execute(executeArgs); + } catch ( com.sun.star.lang.IllegalArgumentException e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } catch ( com.sun.star.uno.Exception e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } + + tRes.tested("addMailMergeEventListener()", changed); + } + + /** + * Test executes mail merge process<p> + * Has <b> OK </b> status if listener was not called + */ + public void _removeMailMergeEventListener() { + log.println("Testing removeMailMergeEventListener ..."); + requiredMethod("addMailMergeEventListener()"); + changed = false; + + oObj.removeMailMergeEventListener( listener ); + + NamedValue[] executeArgs = (NamedValue[]) tEnv.getObjRelation("executeArgs"); + XJob Job = (XJob) tEnv.getObjRelation("Job"); + + try { + Job.execute(executeArgs); + } catch ( com.sun.star.lang.IllegalArgumentException e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } catch ( com.sun.star.uno.Exception e) { + throw new StatusException(Status.failed + ("'could not fire event: " + e)) ; + } + + waitForEventIdle(); + + tRes.tested("removeMailMergeEventListener()", !changed); + } + + +} // finished class _XMailMergeBroadcaster + diff --git a/qadevOOo/tests/java/ifc/text/_XPageCursor.java b/qadevOOo/tests/java/ifc/text/_XPageCursor.java new file mode 100644 index 000000000..6fdcd8bb3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XPageCursor.java @@ -0,0 +1,162 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XPageCursor; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; + + +/** + * Testing <code>com.sun.star.text.XPageCursor</code> + * interface methods : + * <ul> + * <li><code> jumpToFirstPage()</code></li> + * <li><code> jumpToLastPage()</code></li> + * <li><code> jumpToPage()</code></li> + * <li><code> getPage()</code></li> + * <li><code> jumpToNextPage()</code></li> + * <li><code> jumpToPreviousPage()</code></li> + * <li><code> jumpToEndOfPage()</code></li> + * <li><code> jumpToStartOfPage()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>): + * is used to insert text to document to fill at least two pages. </li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XPageCursor + */ +public class _XPageCursor extends MultiMethodTest { + + public XPageCursor oObj = null; // oObj filled by MultiMethodTest + short count = 0; + + /** + * First adds text to the document using relation to fill at least two + * pages. Then obtains the number of current page. <p> + * + * Has <b>OK</b> status if the returned value is positive. + */ + public void _getPage(){ + log.println( "test for getPage()" ); + XTextDocument myText = (XTextDocument)tEnv.getObjRelation( "TEXTDOC" ); + XText aText = myText.getText(); + XTextCursor myCursor = aText.createTextCursor(); + + try{ + for (int i = 0; i < 10; i++){ + for (int j = 0; j < 20; j++){ + aText.insertString(myCursor, "The quick brown fox ",false); + aText.insertString(myCursor, "jumps over the lazy dog ", + false); + } + aText.insertControlCharacter(myCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + } + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println( "Exception :" ); + e.printStackTrace(log); + } + + count = oObj.getPage(); + tRes.tested("getPage()", count > 0 ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToEndOfPage(){ + log.println( "test for jumpToEndOfPage()" ); + tRes.tested("jumpToEndOfPage()", oObj.jumpToEndOfPage()); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToFirstPage(){ + log.println( "test for jumpToFirstPage()" ); + tRes.tested("jumpToFirstPage()", oObj.jumpToFirstPage()); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToLastPage(){ + log.println( "test for jumpToLastPage()" ); + tRes.tested("jumpToLastPage()", oObj.jumpToLastPage()); + } + + /** + * First jumps to the first page to have at least one + * next page, then call the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToNextPage(){ + oObj.jumpToFirstPage() ; + log.println( "test for jumpToNextPage()" ); + tRes.tested("jumpToNextPage()", oObj.jumpToNextPage()); + } + + /** + * Tries to jump to the page with number 1. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToPage(){ + short n = 1; + log.println( "test for jumpToPage()" ); + tRes.tested("jumpToPage()", oObj.jumpToPage(n)); + } + + /** + * First jumps to the last page to have at least one + * previous page, then call the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToPreviousPage(){ + log.println( "test for jumpToPreviousPage()" ); + oObj.jumpToLastPage(); + tRes.tested("jumpToPreviousPage()", oObj.jumpToPreviousPage()); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _jumpToStartOfPage(){ + log.println( "test for jumpToStartOfPage()" ); + tRes.tested("jumpToStartOfPage()", oObj.jumpToStartOfPage()); + } +} // finish class _XPageCursor + diff --git a/qadevOOo/tests/java/ifc/text/_XPagePrintable.java b/qadevOOo/tests/java/ifc/text/_XPagePrintable.java new file mode 100644 index 000000000..5b1f69978 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XPagePrintable.java @@ -0,0 +1,152 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import util.utils; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XPagePrintable; + +/** + * Testing <code>com.sun.star.text.XPagePrintable</code> + * interface methods : + * <ul> + * <li><code> getPagePrintSettings()</code></li> + * <li><code> setPagePrintSettings()</code></li> + * <li><code> printPages()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XPagePrintable + */ +public class _XPagePrintable extends MultiMethodTest { + + public static XPagePrintable oObj = null; + public PropertyValue[] PrintSettings = new PropertyValue[0]; + + /** + * Types of print settings properties by order they returned by + * <code>getPagePrintSettings()</code>. + */ + public String[] types = new String[]{"Short","Short","Integer","Integer", + "Integer","Integer","Integer","Integer","Boolean"}; + + /** + * Calls the method and examines the returned array of properties. <p> + * + * Has <b>OK</b> status if all properties' types are correspond + * to their expected values of the <code>types</code> array. + * + * @see #types + */ + public void _getPagePrintSettings() { + boolean res = true; + PrintSettings = oObj.getPagePrintSettings(); + + for (int i=0;i<PrintSettings.length;i++) { + String the_type = PrintSettings[i].Value.getClass().toString(); + if (!the_type.endsWith(types[i])) { + log.println("Name: "+PrintSettings[i].Name); + log.println("Value: "+PrintSettings[i].Value); + log.println("Type"+the_type); + log.println("Expected: java.lang."+types[i]); + res = false; + } + } + + tRes.tested("getPagePrintSettings()",res); + } + + /** + * Changes a property 'IsLandscape' in existing print settings, + * and sets these settings back. <p> + * + * Has <b>OK</b> status if settings gotten again has the changed + * 'IsLandscape' property value. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getPagePrintSettings() </code> : to have existing + * print settings. </li> + * </ul> + */ + public void _setPagePrintSettings() { + requiredMethod("getPagePrintSettings()"); + boolean res = true; + + Boolean landscape = (Boolean) PrintSettings[8].Value; + Boolean newlandscape = Boolean.valueOf(!landscape.booleanValue()); + PrintSettings[8].Value = newlandscape; + oObj.setPagePrintSettings(PrintSettings); + res = oObj.getPagePrintSettings()[8].Value.equals(newlandscape); + + tRes.tested("setPagePrintSettings()",res); + } + + /** + * Creates print options for printing into file situated in the SOffice + * temporary directory. If the file already exists it is deleted. + * Then calls the method. <p> + * + * Has <b>OK</b> status if the file to which printing must be performed + * is exists. + */ + public void _printPages() throws Exception { + boolean res = true; + + try { + XMultiServiceFactory xMSF = tParam.getMSF(); + + String printFile = utils.getOfficeTemp(xMSF) + "XPagePrintable.prt"; + log.println("Printing to : "+ printFile); + + PropertyValue[] PrintOptions = new PropertyValue[1]; + PropertyValue firstProp = new PropertyValue(); + firstProp.Name = "FileName"; + + firstProp.Value = printFile; + firstProp.State = com.sun.star.beans.PropertyState.DEFAULT_VALUE; + PrintOptions[0] = firstProp; + + if (! util.utils.deleteFile(xMSF, printFile)){ + log.println("ERROR: could not remove '" + printFile + "'"); + res = false; + } + + oObj.printPages(PrintOptions); + + waitForEventIdle(); + + if (! util.utils.fileExists(xMSF, printFile)){ + log.println("ERROR: could not find '" + printFile + "'"); + res = false; + } + + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'printPages'"); + res = false; + ex.printStackTrace(log); + } + + tRes.tested("printPages()",res); + } + +} // finish class _XPagePrintable + diff --git a/qadevOOo/tests/java/ifc/text/_XParagraphCursor.java b/qadevOOo/tests/java/ifc/text/_XParagraphCursor.java new file mode 100644 index 000000000..1aa58a300 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XParagraphCursor.java @@ -0,0 +1,128 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import com.sun.star.text.XParagraphCursor; + +/** + * Testing <code>com.sun.star.text.XParagraphCursor</code> + * interface methods : + * <ul> + * <li><code> isStartOfParagraph()</code></li> + * <li><code> isEndOfParagraph()</code></li> + * <li><code> gotoStartOfParagraph()</code></li> + * <li><code> gotoEndOfParagraph()</code></li> + * <li><code> gotoNextParagraph()</code></li> + * <li><code> gotoPreviousParagraph()</code></li> + * </ul> <p> + * + * <b>Prerequisites :</b> the text must have at least + * two paragraphs. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XParagraphCursor + */ +public class _XParagraphCursor extends MultiMethodTest { + + public XParagraphCursor oObj = null; // oObj filled by MultiMethodTest + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _gotoEndOfParagraph(){ + log.println( "test for gotoEndOfParagraph()" ); + if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); + else log.println("This isn't the end of the paragraph"); + log.println("gotoEndOfParagraph()"); + boolean result = oObj.gotoEndOfParagraph(false); + tRes.tested("gotoEndOfParagraph()", result ); + if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph"); + else log.println("This isn't the end of the paragraph"); + if (!result) log.println("But 'gotoEndOfParagraph()' returns false"); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code>gotoPreviousParagraph()</code> : to be sure next paragraph + * exists. </li> + * </ul> + */ + public void _gotoNextParagraph(){ + requiredMethod( "gotoPreviousParagraph()" ); + log.println( "test for gotoNextParagraph()" ); + tRes.tested("gotoNextParagraph()", oObj.gotoNextParagraph(false) ); + } + + /** + * First moves the cursor to the next paragraph to be sure + * that previous paragraph exists and then calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _gotoPreviousParagraph(){ + //requiredMethod( "gotoNextParagraph()" ); + oObj.gotoNextParagraph(false); + log.println( "test for gotoPreviousParagraph()" ); + tRes.tested("gotoPreviousParagraph()", oObj.gotoPreviousParagraph(false) ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _gotoStartOfParagraph(){ + log.println( "test for gotoStartOfParagraph()" ); + tRes.tested("gotoStartOfParagraph()", oObj.gotoStartOfParagraph(false) ); + } + + /** + * Moves the cursor to the end of paragraph then check if it is + * at the end. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _isEndOfParagraph(){ + oObj.gotoEndOfParagraph(false); + log.println( "test for isEndOfParagraph()" ); + tRes.tested("isEndOfParagraph()", oObj.isEndOfParagraph() ); + } + + /** + * Moves the cursor to the start of paragraph then check if it is + * at the start. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value. + */ + public void _isStartOfParagraph(){ + oObj.gotoStartOfParagraph(false); + log.println( "test for isStartOfParagraph()" ); + tRes.tested("isStartOfParagraph()", oObj.isStartOfParagraph() ); + } + + } // finish class _XParagraphCursor + diff --git a/qadevOOo/tests/java/ifc/text/_XReferenceMarksSupplier.java b/qadevOOo/tests/java/ifc/text/_XReferenceMarksSupplier.java new file mode 100644 index 000000000..409155f7d --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XReferenceMarksSupplier.java @@ -0,0 +1,57 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XReferenceMarksSupplier; + +/** + * Testing <code>com.sun.star.text.XReferenceMarksSupplier</code> + * interface methods : + * <ul> + * <li><code> getReferenceMarks()</code></li> + * </ul> <p> + * + * <b>Prerequisites: </b> the reference mark collection + * must contain an element named 'SwXTextDocument' <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XReferenceMarksSupplier + */ +public class _XReferenceMarksSupplier extends MultiMethodTest { + + public static XReferenceMarksSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if there is an element + * named 'SwXTextDocument' in the returned collection. + */ + public void _getReferenceMarks() { + boolean res = false; + XNameAccess the_marks = oObj.getReferenceMarks(); + res = the_marks.hasByName("SwXTextDocument"); + tRes.tested("getReferenceMarks()",res); + } + +} // finish class _XReferenceMarksSupplier + + diff --git a/qadevOOo/tests/java/ifc/text/_XRelativeTextContentInsert.java b/qadevOOo/tests/java/ifc/text/_XRelativeTextContentInsert.java new file mode 100644 index 000000000..af6995662 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XRelativeTextContentInsert.java @@ -0,0 +1,126 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import util.XInstCreator; + +import com.sun.star.text.XRelativeTextContentInsert; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Testing <code>com.sun.star.text.XRelativeTextContentInsert</code> + * interface methods : + * <ul> + * <li><code> insertTextContentBefore()</code></li> + * <li><code> insertTextContentAfter()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'PARA'</code> (of type <code>XInstCreator</code>): + * the creator which can create instances of + * <code>com.sun.star.text.Paragraph</code> service. </li> + * <li> <code>'XTEXTINFO'</code> (of type <code>XInstCreator</code>): + * the creator which can create instances of some text content + * service (objects which implement <code>XTextContent</code>). + * </li> + * <ul> <p> + * + * Tested component <b>must implement</b> <code>XText</code> + * interface for proper testing. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XRelativeTextContentInsert + */ +public class _XRelativeTextContentInsert extends MultiMethodTest { + + public XRelativeTextContentInsert oObj = null; + public XTextContent content = null; + + /** + * First an instance of <code>Paragraph</code> service created + * using relation and inserted into text. Then an instance + * of text content is created and inserted after the paragraph. <p> + * + * Has <b>OK</b> status if no exceptions occurred. + */ + public void _insertTextContentAfter() { + + try { + XInstCreator para = (XInstCreator)tEnv.getObjRelation( "PARA" ); + XInterface oInt = para.createInstance(); + XTextContent new_content = (XTextContent) oInt; + XText theText = UnoRuntime.queryInterface(XText.class,oObj); + XTextCursor oCursor = theText.createTextCursor(); + XInstCreator info = (XInstCreator) + tEnv.getObjRelation( "XTEXTINFO" ); + oInt = info.createInstance(); + content = (XTextContent) oInt; + theText.insertTextContent(oCursor, content, false); + oObj.insertTextContentAfter(new_content,content); + tRes.tested("insertTextContentAfter()",true); + } + catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred while checking "+ + "insertTextContentAfter()"); + ex.printStackTrace(log); + tRes.tested("insertTextContentAfter()",false); + } + + + } // end _insertTextContentAfter() + + /** + * An instance of text content is created using relation + * and inserted before the paragraph which was added into + * text in <code>insertTextContentAfter</code> method test. <p> + * + * Has <b>OK</b> status if no exceptions occurred. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertTextContentAfter() </code> : here the + * <code>Paragraph</code> instance is inserted. </li> + * </ul> + */ + public void _insertTextContentBefore() { + requiredMethod("insertTextContentAfter()"); + try { + XInstCreator para = (XInstCreator)tEnv.getObjRelation( "PARA" ); + XInterface oInt = para.createInstance(); + XTextContent new_content = (XTextContent) oInt; + oObj.insertTextContentBefore(new_content,content); + tRes.tested("insertTextContentBefore()",true); + } + catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred while checking "+ + "insertTextContentBefore()"); + ex.printStackTrace(log); + tRes.tested("insertTextContentBefore()",false); + } + + + } // end _insertTextContentBefore() + +} + diff --git a/qadevOOo/tests/java/ifc/text/_XSentenceCursor.java b/qadevOOo/tests/java/ifc/text/_XSentenceCursor.java new file mode 100644 index 000000000..7729f42a6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XSentenceCursor.java @@ -0,0 +1,118 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XSentenceCursor; + +/** + * Testing <code>com.sun.star.text.XSentenceCursor</code> + * interface methods : + * <ul> + * <li><code> isStartOfSentence()</code></li> + * <li><code> isEndOfSentence()</code></li> + * <li><code> gotoNextSentence()</code></li> + * <li><code> gotoPreviousSentence()</code></li> + * <li><code> gotoStartOfSentence()</code></li> + * <li><code> gotoEndOfSentence()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XSentenceCursor + */ +public class _XSentenceCursor extends MultiMethodTest { + + public XSentenceCursor oObj = null; // oObj filled by MultiMethodTest + + /** + * First goes to next sentence (to be sure that previous exists), + * then calls the method. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _gotoPreviousSentence(){ + oObj.gotoNextSentence(false); + oObj.gotoNextSentence(false); + tRes.tested("gotoPreviousSentence()", oObj.gotoPreviousSentence(false) ); + } + + /** + * First goes to previous sentence (to be sure that next exists), + * then calls the method. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _gotoNextSentence(){ + oObj.gotoPreviousSentence(false) ; + oObj.gotoPreviousSentence(false) ; + tRes.tested("gotoNextSentence()", oObj.gotoNextSentence(false) ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> gotoPreviousSentence() </code> : to be sure the + * cursor is in range of some sentence. </li> + * </ul> + */ + public void _gotoEndOfSentence(){ + requiredMethod( "gotoPreviousSentence()" ); + tRes.tested("gotoEndOfSentence()", oObj.gotoEndOfSentence(false) ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> gotoPreviousSentence() </code> : to be sure the + * cursor is in range of some sentence. </li> + * </ul> + */ + public void _gotoStartOfSentence(){ + requiredMethod( "gotoPreviousSentence()" ); + tRes.tested("gotoStartOfSentence()", oObj.gotoStartOfSentence(false) ); + } + + /** + * First moves the cursor to the start of sentence and then calls + * the method. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _isStartOfSentence(){ + oObj.gotoStartOfSentence(false) ; + tRes.tested("isStartOfSentence()", oObj.isStartOfSentence() ); + } + + /** + * First moves the cursor to the end of sentence and then calls + * the method. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _isEndOfSentence(){ + oObj.gotoEndOfSentence(false) ; + tRes.tested("isEndOfSentence()", oObj.isEndOfSentence() ); + } + + } // finish class _XSentenceCursor + diff --git a/qadevOOo/tests/java/ifc/text/_XSimpleText.java b/qadevOOo/tests/java/ifc/text/_XSimpleText.java new file mode 100644 index 000000000..bd6d6e294 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XSimpleText.java @@ -0,0 +1,126 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; + +/** +* Testing <code>com.sun.star.text.XSimpleText</code> +* interface methods : +* <ul> +* <li><code> createTextCursor()</code></li> +* <li><code> createTextCursorByRange()</code></li> +* <li><code> insertString()</code></li> +* <li><code> insertControlCharacter()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.text.XSimpleText +*/ +public class _XSimpleText extends MultiMethodTest { + + XTextCursor oCursor = null; + public XSimpleText oObj = null; + + /** + * Creates text cursor. <p> + * Has <b> OK </b> status if not null value returned. <p> + */ + public void _createTextCursor() { + + log.println( "Testing createTextCursor()" ); + oCursor = oObj.createTextCursor(); + tRes.tested( "createTextCursor()", oCursor != null ); + } + + /** + * Inserts a string at the cursor position.<p> + * Has <b> OK </b> status if the whole result string has a string + * inserted as its substring. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> createTextCursor() </code> : to have a cursor + * where text should be inserted. </li> + * </ul> + */ + public void _insertString() { + requiredMethod("createTextCursor()"); + log.println( "Testing insertString" ); + String sStr = getInterfaceName() ; + oObj.insertString( oCursor, sStr, false ); + String gStr = oObj.getText().getString() ; + + tRes.tested( "insertString()", gStr != null && + gStr.indexOf(sStr) >= 0) ; + } + + /** + * Inserts paragraph break character into text and then checks + * if this character is present in the result string. <p> + * Has <b> OK </b> status if the result string has + * paragraph break character. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> createTextCursor </code> : to have a cursor object. </li> + * </ul> + */ + public void _insertControlCharacter() { + boolean bOK = true; + + requiredMethod("createTextCursor()"); + log.println( "Testing insertControlCharacter()" ); + try { + oObj.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + oObj.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false); + oObj.insertString(oObj.createTextCursor(),"newLine",false); + } + catch(com.sun.star.lang.IllegalArgumentException e ) { + // Some exception.FAILED + log.println(e.toString()); + bOK = false; + } + String gStr = oObj.getString() ; + + tRes.tested( "insertControlCharacter()", bOK && gStr != null && + gStr.indexOf("\n") > -1); + } + + /** + * Creates another text cursor using existing cursor's range. <p> + * Has <b> OK </b> status if not null value returned. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> createTextCursor </code> : to have a cursor object. </li> + * </ul> + */ + public void _createTextCursorByRange() { + + requiredMethod("createTextCursor()"); + oCursor.gotoStart(false); + log.println( "Testing createTextCursorByRange()" ); + XTextCursor oTCursor = oObj.createTextCursorByRange(oCursor); + tRes.tested("createTextCursorByRange()", oTCursor != null) ; + } +} // finish class _XSimpleText + diff --git a/qadevOOo/tests/java/ifc/text/_XText.java b/qadevOOo/tests/java/ifc/text/_XText.java new file mode 100644 index 000000000..02e2f5742 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XText.java @@ -0,0 +1,157 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import util.XInstCreator; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.uno.XInterface; +import lib.StatusException; + +/** + * Testing <code>com.sun.star.text.XText</code> + * interface methods : + * <ul> + * <li><code> insertTextContent()</code></li> + * <li><code> removeTextContent()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'XTEXTINFO'</code> (of type <code>lib.XInstCreator</code>): + * creator which can create instances of <code>XTextContent</code> + * implementations. </li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XText + */ +public class _XText extends MultiMethodTest { + + public static XText oObj = null; // oObj filled by MultiMethodTest + XTextCursor oCursor = null; // textcursor + XInstCreator info = null; // instance creator + XInterface oInt = null; // instance to insert and remove + + /** + * First an instance of text content is created using relation + * and inserted into text. Then the number of contents is checked + * using the relation. Second a <code>null</code> content is tried + * to insert. <p> + * + * Has <b> OK </b> status if in the first case after inserting number + * of content objects is greater than zero and in the second + * case <code>IllegalArgumentException</code> is thrown. <p> + */ + public void _insertTextContent() { + boolean result = false; + info = (XInstCreator)tEnv.getObjRelation( "XTEXTINFO" ); + oInt = info.createInstance(); + + // write to log what we try next + log.println( "test for createTextCursor()" ); + oCursor = oObj.createTextCursor(); + + // write to log what we try next + log.println( "test for insertTextContent()" ); + try { + oObj.insertTextContent(oCursor, (XTextContent)oInt, false); + } + catch( com.sun.star.lang.IllegalArgumentException iaE ){ + throw new StatusException("Couldn't insert textcontent",iaE); + } + + // get indexaccess to the tablecollection + XIndexAccess xIA = info.getCollection(); + + // this comparison works just because it has to be at least one + // table at this point regardless which thread inserted it + // there is although the possibility that the first threads call + // failed, the second not and comparison happens after second threads + // otherwise if something fails it should have thrown an exception + //tRes.tested("insertTextContent()", xIA.getCount() > 0 ); + + if (xIA != null ) { + result = (xIA.getCount()>0); + } else { + result = true; + } + + if (!result) log.println("The TextContent wasn't inserted"); + + + // try to insert an invalid TextContent + log.println( "test for insertTextContent" ); + try { + oObj.insertTextContent(oCursor, null, false); + log.println("The expected Exception doesn't occurred"); + result &= false; + } + catch( com.sun.star.lang.IllegalArgumentException iaE ){ + // Some exception.FAILED + log.println("Expected Exception occurred"); + String msg = iaE.getMessage(); + if (msg.equals("")) { + log.println("But there is not detailed message"); + } else { + log.println("Detailed message: "+msg); + } + + result &= true; + } + + tRes.tested("insertTextContent()", result ); + } + + + /** + * Removes the text content added before. <p> + * Has <b> OK </b> status if the method successfully returns + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertTextContent() </code> : inserts the content + * to be removed in this test. </li> + * </ul> + */ + public void _removeTextContent() { + + // leads to a method which should be called previously + requiredMethod( "insertTextContent()" ); + + // write to log what we try next + log.println( "test for removeTextContent" ); + try { + oObj.removeTextContent( (XTextContent)oInt ); + } + catch( com.sun.star.container.NoSuchElementException nseE ){ + // Some exception.FAILED + log.println(nseE.toString()); + return; + } + + // no exception occurred so it works + tRes.tested( "removeTextContent()", true ); + + } +} // finish class _XText + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextColumns.java b/qadevOOo/tests/java/ifc/text/_XTextColumns.java new file mode 100644 index 000000000..eaf103674 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextColumns.java @@ -0,0 +1,105 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.TextColumn; +import com.sun.star.text.XTextColumns; + +/** + * Testing <code>com.sun.star.text.XTextColumns</code> + * interface methods : + * <ul> + * <li><code> getReferenceValue()</code></li> + * <li><code> getColumnCount()</code></li> + * <li><code> setColumnCount()</code></li> + * <li><code> getColumns()</code></li> + * <li><code> setColumns()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextColumns + */ +public class _XTextColumns extends MultiMethodTest { + + public XTextColumns oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * positive value. + */ + public void _getColumnCount(){ + + short howmuch = oObj.getColumnCount(); + tRes.tested("getColumnCount()",howmuch >=0); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getColumns(){ + TextColumn[] cols = oObj.getColumns(); + tRes.tested("getColumns()",cols != null); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * positive value. + */ + public void _getReferenceValue(){ + + int ref = oObj.getReferenceValue(); + tRes.tested("getReferenceValue()",ref >0); + } + + /** + * Sets the column count property to some value + * then checks it by <code>getColumnCount</code> method. <p> + * + * Has <b>OK</b> status if set and get values are equal. + */ + public void _setColumnCount(){ + + oObj.setColumnCount((short) 3); + short howmuch = oObj.getColumnCount(); + tRes.tested("setColumnCount()",howmuch == 3); + } + + /** + * Sets columns to some array + * then checks it by <code>getColumns</code> method. <p> + * + * Has <b>OK</b> status if set and get arrays are equal. + */ + public void _setColumns(){ + + TextColumn newCol = new TextColumn(5,1,1); + TextColumn[] cols = {newCol}; + oObj.setColumns(cols); + TextColumn[] gCols = oObj.getColumns(); + tRes.tested("setColumns()",util.ValueComparer.equalValue(cols, gCols)); + } + +} // finish class _XTextColumns + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextContent.java b/qadevOOo/tests/java/ifc/text/_XTextContent.java new file mode 100644 index 000000000..bcb65b806 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextContent.java @@ -0,0 +1,108 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextRange; + +/** + * Testing <code>com.sun.star.text.XTextContent</code> + * interface methods : + * <ul> + * <li><code> attach()</code></li> + * <li><code> getAnchor()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'CONTENT'</code> <b>optional</b> + * (of type <code>XTextContent</code>): + * if this relation exists than it is used as the + * tested object. </li> + * <li> <code>'TEXT'</code> <b>optional</b> + * (of type <code>XText</code>): + * the relation must be specified if the 'CONTENT' + * relation exists. From this relation an anchor + * for <code>attach()</code> method is obtained.</li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextContent + */ +public class _XTextContent extends MultiMethodTest { + public XTextContent oObj = null; + public XTextRange oAnchor = null; + + /** + * Tries to get the anchor of the text content + * an XTextRange is returned. <p> + * The test is OK if a not null text range is returned + */ + public void _getAnchor() { + log.println("getAnchor()"); + oAnchor = oObj.getAnchor(); + tRes.tested("getAnchor()", oAnchor != null ) ; + + } // end getAnchor() + + /** + * Tries to attach the text content to the test range + * gotten with getAnchor(). If relations are found + * then they are used for testing. <p> + * + * The test is OK if the method works without error. + * @see #_getAnchor() + */ + public void _attach() { + requiredMethod("getAnchor()"); + try { + XTextContent aContent = (XTextContent) tEnv.getObjRelation("CONTENT"); + XTextRange aRange = (XTextRange) tEnv.getObjRelation("RANGE"); + + if ( aContent !=null) { + aContent.attach(aRange); + } else { + oObj.attach(aRange); + } + tRes.tested("attach()", true ) ; + } + catch (com.sun.star.lang.IllegalArgumentException ex) { + String noAttach = (String) tEnv.getObjRelation("NoAttach"); + if (noAttach != null) { + log.println("Exception expected for "+noAttach); + log.println("This Component doesn't support attach"); + tRes.tested("attach()",true); + } else { + ex.printStackTrace(log); + tRes.tested("attach()",false); + } + } catch (com.sun.star.uno.RuntimeException re) { + String noAttach = (String) tEnv.getObjRelation("NoAttach"); + if (noAttach != null) { + log.println("Exception expected for "+noAttach); + log.println("This Component doesn't support attach"); + tRes.tested("attach()",true); + } else { + re.printStackTrace(log); + tRes.tested("attach()",false); + } + } + } +} + diff --git a/qadevOOo/tests/java/ifc/text/_XTextCursor.java b/qadevOOo/tests/java/ifc/text/_XTextCursor.java new file mode 100644 index 000000000..87369a7ec --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextCursor.java @@ -0,0 +1,235 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextCursor; + + +/** + * Testing <code>com.sun.star.text.XTextCursor</code> + * interface methods : + * <ul> + * <li><code> collapseToStart()</code></li> + * <li><code> collapseToEnd()</code></li> + * <li><code> isCollapsed()</code></li> + * <li><code> goLeft()</code></li> + * <li><code> goRight()</code></li> + * <li><code> gotoStart()</code></li> + * <li><code> gotoEnd()</code></li> + * <li><code> gotoRange()</code></li> + * </ul> <p> + * + * During this test the component text is changed, + * that's why it must be stored before methods' tests, + * and restored after. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextCursor + */ +public class _XTextCursor extends MultiMethodTest { + + public XTextCursor oObj = null; // oObj filled by MultiMethodTest + String oldText = null ; + + /** + * Stores component's text. + */ + @Override + public void before() { + oObj.gotoStart(false); + oObj.gotoEnd(true); + oldText = oObj.getString() ; + } + + /** + * First some text is set (for component to has at least some + * text), cursor is expanded to the whole text (to be not collapsed), + * the <code>collapseToEnd</code> is called. Then current cursor + * text is examined. <p> + * + * Has <b>OK</b> status if the current cursor text is an + * empty string. + */ + public void _collapseToEnd(){ + boolean bCol = false; + + oObj.setString("XTextCursor"); + oObj.gotoStart(false); + oObj.gotoEnd(true); + oObj.collapseToEnd(); + bCol = oObj.getString().equals(""); + tRes.tested("collapseToEnd()", bCol ); + } + + /** + * First some text is set (for component to has at least some + * text), cursor is expanded to the whole text (to be not collapsed), + * the <code>collapseToStart</code> is called. Then current cursor + * text is examined. <p> + * + * Has <b>OK</b> status if the current cursor text is an + * empty string. + */ + public void _collapseToStart(){ + boolean bCol = false; + oObj.setString("XTextCursor"); + oObj.gotoStart(false); + oObj.gotoEnd(true); + + oObj.collapseToStart(); + bCol = oObj.getString().equals(""); + tRes.tested("collapseToStart()", bCol ); + } + + /** + * First the cursor is moved to the end of text (to have a space + * for left cursor moving, and moves the cursor left by a number + * of characters. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>, + * and the current cursor string has the same length as number + * of characters the cursor was moved by. + */ + public void _goLeft(){ + boolean bLeft = false; + short n = 5; + + oObj.gotoEnd(false); + bLeft = oObj.goLeft(n, true); + String gStr = oObj.getString() ; + log.println("'" + gStr + "'") ; + bLeft &= gStr.length() == n ; + + tRes.tested("goLeft()", bLeft ); + } + + /** + * First the cursor is moved to the start of text (to have a space + * for right cursor moving, and moves the cursor right by a number + * of characters. <p> + * + * Has <b>OK</b> status if the method returns <code>true</code>, + * and the current cursor string has the same length as number + * of characters the cursor was moved by. + */ + public void _goRight(){ + boolean bRight = false; + short n = 5; + + oObj.gotoStart(false); + bRight = oObj.goRight(n, true); + + String gStr = oObj.getString() ; + log.println("'" + gStr + "'") ; + bRight &= gStr.length() == n ; + + tRes.tested("goRight()", bRight ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method <code>goRight()</code> + * returns <code>false</code> (cursor can't move to the right). + */ + public void _gotoEnd(){ + boolean bEnd = false; + short n = 1; + + oObj.gotoEnd(false); + bEnd = !oObj.goRight(n, false) ; + + tRes.tested("gotoEnd()", bEnd ); + } + + /** + * First the whole text is set to a string, and cursor + * is moved to the range situated at the start of the + * text. <p> + * + * Has <b>OK</b> status if some characters to the right + * of the current cursor position are the beginning of + * the text. + */ + public void _gotoRange(){ + boolean bRange = false; + + oObj.gotoStart(false); + oObj.gotoEnd(true); + oObj.setString("XTextCursor,XTextCursor"); + oObj.gotoRange(oObj.getStart(),false); + oObj.goRight((short) 5, true); + bRange = oObj.getString().equals("XText"); + + if (!bRange) log.println("getString() returned '" + + oObj.getString() + "'") ; + + tRes.tested("gotoRange()", bRange ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method <code>goLeft()</code> + * returns <code>false</code> (cursor can't move to the left). + */ + public void _gotoStart(){ + boolean bStart = false; + short n = 1; + + oObj.gotoStart(false); + bStart = !oObj.goLeft(n, false) ; + + tRes.tested("gotoStart()", bStart ); + } + + /** + * First the cursor is moved to start without expanding + * (must be collapsed), and then it's expanded to the + * whole text (must not be collapsed). <p> + * + * Has <b>OK</b> status if in the first case method + * <code>isCollapsed</code> returns <code>true</code>, + * and in the second <code>false</code> + */ + public void _isCollapsed(){ + boolean bCol = false; + + oObj.gotoStart(false); + bCol = oObj.isCollapsed(); + + oObj.gotoEnd(true); + bCol &= !oObj.isCollapsed() ; + + tRes.tested("isCollapsed()", bCol ); + } + + /** + * Restores the text of the component to the + * state it was before this interface test. + */ + @Override + public void after() { + oObj.gotoStart(false); + oObj.gotoEnd(true); + oObj.setString(oldText) ; + } + +} // finish class _XTextCursor + diff --git a/qadevOOo/tests/java/ifc/text/_XTextDocument.java b/qadevOOo/tests/java/ifc/text/_XTextDocument.java new file mode 100644 index 000000000..10eb5360a --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextDocument.java @@ -0,0 +1,62 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; + +/** + * Testing <code>com.sun.star.text.XTextDocument</code> + * interface methods : + * <ul> + * <li><code> getText()</code></li> + * <li><code> reformat()</code></li> + * </ul> <p> + * Test is multithread compliant. <p> + * @see com.sun.star.text.XTextDocument + */ +public class _XTextDocument extends MultiMethodTest { + + public XTextDocument oObj = null; + public XText myText = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getText(){ + myText = oObj.getText(); + tRes.tested("getText()", myText != null ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method successfully returns + * and no exceptions were thrown. <p> + */ + public void _reformat(){ + oObj.reformat(); + tRes.tested("reformat()", true ); + } + +} // finish class _XTextDocument + diff --git a/qadevOOo/tests/java/ifc/text/_XTextEmbeddedObjectsSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextEmbeddedObjectsSupplier.java new file mode 100644 index 000000000..15e5a1482 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextEmbeddedObjectsSupplier.java @@ -0,0 +1,52 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XTextEmbeddedObjectsSupplier; + +/** + * Testing <code>com.sun.star.text.XTextEmbeddedObjectsSupplier</code> + * interface methods : + * <ul> + * <li><code> getEmbeddedObjects()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextEmbeddedObjectsSupplier + */ +public class _XTextEmbeddedObjectsSupplier extends MultiMethodTest { + + public XTextEmbeddedObjectsSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getEmbeddedObjects(){ + boolean bResult = false; + XNameAccess oNA = oObj.getEmbeddedObjects(); + bResult = oNA != null ; + tRes.tested("getEmbeddedObjects()", bResult ); + } + + } // finish class _XTextEmbeddedObjectsSupplier + diff --git a/qadevOOo/tests/java/ifc/text/_XTextField.java b/qadevOOo/tests/java/ifc/text/_XTextField.java new file mode 100644 index 000000000..826718e34 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextField.java @@ -0,0 +1,57 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextField; + +/** + * Testing <code>com.sun.star.text.XTextField</code> + * interface methods : + * <ul> + * <li><code> getPresentation()</code></li> + * </ul> <p> + * Test is multithread compliant. <p> + * @see com.sun.star.text.XTextField + */ +public class _XTextField extends MultiMethodTest{ + public XTextField oObj = null; + + /** + * Calls the method with <code>true</code> and <code>false</code> + * parameter. <p> + * Has <b>OK</b> status if in both cases not <code>null</code> + * value returned. + */ + public void _getPresentation() { + + boolean result = true; + + // begin test here + log.println("getting presentetion with bShowCommand flag..."); + result &= oObj.getPresentation(true) != null; + log.println("getting presentetion without bShowCommand flag..."); + result &= oObj.getPresentation(false) != null; + + tRes.tested( "getPresentation()", result ); + + } // end getPresentation() +} + diff --git a/qadevOOo/tests/java/ifc/text/_XTextFieldsSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextFieldsSupplier.java new file mode 100644 index 000000000..e26fefdd6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextFieldsSupplier.java @@ -0,0 +1,178 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextFieldsSupplier; +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 lib.MultiMethodTest; +import lib.StatusException; + +/** + * + */ +public class _XTextFieldsSupplier extends MultiMethodTest { + + public XTextFieldsSupplier oObj = null; // oObj filled by MultiMethodTest + private boolean mDispose = false; + private boolean mbCreateFieldMaster = true; + + /** + * Insert some text fields into a cell on the sheet, so this interface test + * makes sense. + */ + @Override + protected void before() { + Object o = tEnv.getObjRelation("XTextFieldsSupplier.MAKEENTRY"); + if (o != null && ((Boolean)o).booleanValue()) { + mDispose = true; + mbCreateFieldMaster = false; + XCell xCell = (XCell)tEnv.getObjRelation("MAKEENTRYINCELL"); + + XSpreadsheetDocument xSheetDoc = (XSpreadsheetDocument)tEnv.getObjRelation("SPREADSHEET"); + + XText oText = null; + XTextContent oContent = null; + XInterface aField = null; + + try { + // we want to create an instance of ScCellFieldObj. + // to do this we must get an MultiServiceFactory. + + XMultiServiceFactory _oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xSheetDoc); + + aField = (XInterface) + _oMSF.createInstance("com.sun.star.text.TextField.URL"); + oContent = UnoRuntime.queryInterface(XTextContent.class, aField); + + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + String[] services = _oMSF.getAvailableServiceNames(); + for (int i=0; i<services.length; i++) { + if (services[i].startsWith("com.sun.star.text.FieldMaster")) { + mbCreateFieldMaster = true; + log.println("service " + i + ": " + services[i]); + } + } + + if (mbCreateFieldMaster) { + Object FieldMaster = _oMSF.createInstance("com.sun.star.text.FieldMaster.User"); + XPropertySet PFieldMaster = UnoRuntime.queryInterface + (XPropertySet.class,FieldMaster); + + XDependentTextField xTF = UnoRuntime.queryInterface(XDependentTextField.class,aField); + + PFieldMaster.setPropertyValue("Content","Some content"); + + xTF.attachTextFieldMaster(PFieldMaster); + } + + oText = UnoRuntime.queryInterface(XText.class, xCell); + XTextCursor the_Cursor = oText.createTextCursor(); + + oText.insertTextContent( + the_Cursor, oContent, true); + + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception occurred while creating test Object."); + e.printStackTrace(log); + throw new StatusException("Couldn't insert textField.URL", e); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception occurred while creating test Object."); + e.printStackTrace(log); + throw new StatusException("Couldn't insert textField.URL", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception occurred while creating test Object."); + e.printStackTrace(log); + throw new StatusException("Couldn't insert textField.URL", e); + } catch (com.sun.star.uno.Exception e) { + log.println("Exception occurred while creating test Object."); + e.printStackTrace(log); + throw new StatusException("Couldn't insert textField.URL", e); + } + + } + } + + public void _getTextFields() { + XEnumerationAccess xEnumAccess = oObj.getTextFields(); + XEnumeration xEnum = xEnumAccess.createEnumeration(); + while(xEnum != null && xEnum.hasMoreElements()) { + try { + xEnum.nextElement(); + } + catch(com.sun.star.container.NoSuchElementException e) { + setMethodFalse("getTextFields()", e); + } + catch(com.sun.star.lang.WrappedTargetException e) { + setMethodFalse("getTextFields()", e); + } + } + tRes.tested("getTextFields()", xEnum != null); + } + + public void _getTextFieldMasters() { + if (mbCreateFieldMaster) { + XNameAccess xName = oObj.getTextFieldMasters(); + util.dbg.printInterfaces(xName); + tRes.tested("getTextFieldMasters()", xName != null); + } + else { + log.println("Could not test 'getTextFieldMasters' because no field masters can be created on this object."); + tRes.tested("getTextFieldMasters()", true); + } + } + + /** + * Just for convenience: log the exception and set the method false. + * @param method The name of the method to set to false. + * @param e The Exception that occurred. + */ + private void setMethodFalse(String method, Exception e) { + log.println("Exception while executing '" + method + "'"); + e.printStackTrace(log); + tRes.tested(method, false); + } + + @Override + protected void after() { + if (mDispose) + disposeEnvironment(); + } + +} diff --git a/qadevOOo/tests/java/ifc/text/_XTextFrame.java b/qadevOOo/tests/java/ifc/text/_XTextFrame.java new file mode 100644 index 000000000..50a782f13 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextFrame.java @@ -0,0 +1,59 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextFrame; + + +/** + * Testing <code>com.sun.star.text.XTextFrame</code> + * interface methods : + * <ul> + * <li><code> getText()</code></li> + * </ul> <p> + * + * The frame <b>must contain</b> the text 'The FrameText' + * for proper interface testing. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextFrame + */ +public class _XTextFrame extends MultiMethodTest { + + public XTextFrame oObj = null; + + /** + * Gets the text of the frame. <p> + * + * Has <b>OK</b> status if the text is equal to 'The FrameText'. + */ + public void _getText() { + + log.println("Testing getText ..."); + XText oFrameText = oObj.getText(); + String Content = oFrameText.getString(); + tRes.tested( "getText()",Content.equals("The FrameText") ); + } + +} // finish class _XTextFrame + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextFramesSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextFramesSupplier.java new file mode 100644 index 000000000..63fcfaa7d --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextFramesSupplier.java @@ -0,0 +1,55 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XTextFramesSupplier; +import lib.MultiMethodTest; + + +/** + * Testing <code>com.sun.star.text.XTextFramesSupplier</code> + * interface methods : + * <ul> + * <li><code> getTextFrames()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextFramesSupplier + */ +public class _XTextFramesSupplier extends MultiMethodTest { + + public static XTextFramesSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the collection returned has at least + * one element. + */ + public void _getTextFrames() { + boolean res = false; + + XNameAccess the_frames = oObj.getTextFrames(); + log.println("Found: "); + util.dbg.printArray(the_frames.getElementNames()); + res = the_frames.getElementNames().length>0; + + tRes.tested("getTextFrames()",res); + } + +} // finish class _XTextFramesSupplier diff --git a/qadevOOo/tests/java/ifc/text/_XTextGraphicObjectsSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextGraphicObjectsSupplier.java new file mode 100644 index 000000000..730f4b5eb --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextGraphicObjectsSupplier.java @@ -0,0 +1,58 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XTextGraphicObjectsSupplier; + +/** + * Testing <code>com.sun.star.text.XTextGraphicObjectsSupplier</code> + * interface methods : + * <ul> + * <li><code> getGraphicObjects()</code></li> + * </ul> <p> + * + * The component <b>must have</b> the graphic object with + * name 'SwXTextDocument'. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextGraphicObjectsSupplier + */ +public class _XTextGraphicObjectsSupplier extends MultiMethodTest { + + public static XTextGraphicObjectsSupplier oObj = null; + + /** + * Gets graphic objects collection from the component, and checks + * if the object with name 'SwXTextDocument' exists. <p> + * Has <b>OK</b> status if the object exists. + */ + public void _getGraphicObjects() { + boolean res = false; + + XNameAccess the_graphics = oObj.getGraphicObjects(); + res = the_graphics.hasByName("SwXTextDocument"); + + tRes.tested("getGraphicObjects()",res); + } + +} // finish class _XTextGraphicObjectsSupplier + diff --git a/qadevOOo/tests/java/ifc/text/_XTextRange.java b/qadevOOo/tests/java/ifc/text/_XTextRange.java new file mode 100644 index 000000000..033f87000 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextRange.java @@ -0,0 +1,170 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextRange; + + +/** +* Testing <code>com.sun.star.text.XTextRange</code> +* interface methods : +* <ul> +* <li><code> getText()</code></li> +* <li><code> getStart()</code></li> +* <li><code> getEnd()</code></li> +* <li><code> getString()</code></li> +* <li><code> setString()</code></li> +* </ul> <p> +* First the content is set to 'Middle' string value, then +* start range is retrieved and its content is set to 'Start' +* and end range is set to 'End'. Finally the whole TextRange +* is checked and it must be 'StartMiddleEnd'. <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.text.XTextRange +*/ +public class _XTextRange extends MultiMethodTest { + + public XTextRange oObj = null; // oObj is filled by setField() + // in MultiMethodTest + XTextRange oStartRange = null; // startrange of textrang + XTextRange oEndRange = null; // endrange of textrang + + /** + * Retrieves the start range and sets its context to + * 'Start' string. <p> + * Has <b>OK</b> status if the whole range string starts + * with 'Start' substring. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setString </code> </li> + * </ul> + */ + public void _getStart() { + + XText the_text = (XText) tEnv.getObjRelation("XTEXT"); + + if (the_text != null) { + the_text.setString(""); + } + + String exp=""; + + oObj.setString("MiddleEnd"); + + oStartRange = oObj.getStart(); + oStartRange.setString("Start"); + + if (the_text !=null) { + exp = the_text.getString(); + } else exp = oObj.getText().getString(); + + log.println("Start: "+exp); + + tRes.tested( "getStart()", exp.startsWith("Start")); + + oStartRange.setString(""); + + } + + /** + * Retrieves the end range and sets its context to + * 'End' string. <p> + * Has <b>OK</b> status if the whole range string ends + * with 'End' substring. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setString </code> </li> + * </ul> + */ + public void _getEnd() { + XText the_text = (XText) tEnv.getObjRelation("XTEXT"); + + if (the_text != null) { + the_text.setString(""); + } + + String exp=""; + oObj.setString("StartMiddle"); + + oEndRange = oObj.getEnd(); + oEndRange.setString("End"); + + if (the_text !=null) { + exp = the_text.getString(); + } else exp = oObj.getText().getString(); + + log.println("End: "+exp); + + tRes.tested( "getEnd()", exp.endsWith("End")); + + oEndRange.setString(""); + } + + /** + * Gets the text of the range and retrieves its String content. <p> + * Has <b>OK</b> status if the string returned equals to + * 'StartMiddleEnd' value. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setString </code> to get finally the string expected.</li> + * <li> <code> getStart </code> to get finally the string expected.</li> + * <li> <code> getEnd </code> to get finally the string expected.</li> + * </ul> + */ + public void _getText() { + requiredMethod("setString()"); + requiredMethod("getStart()"); + requiredMethod("getEnd()"); + + XText txt = oObj.getText() ; + + tRes.tested( "getText()", txt != null && + txt.getString().equals("StartMiddle")); + } + + /** + * Gets the String of the range. <p> + * Has <b>OK</b> status if the string returned equals to + * 'StartMiddleEnd' value. <p> + */ + public void _getString() { + + oObj.setString("StartMiddleEnd"); + String gStr = oObj.getString() ; + + tRes.tested( "getString()", gStr != null && + gStr.equals("StartMiddleEnd")); + + } + + /** + * Sets the string content of the range to 'Middle' value. <p> + * Has <b>OK</b> status if <code>getString</code> method returns + * 'Middle' value. + */ + public void _setString() { + oObj.setString("Middle") ; + + tRes.tested("setString()", "Middle".equals(oObj.getString())) ; + } +} + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextRangeCompare.java b/qadevOOo/tests/java/ifc/text/_XTextRangeCompare.java new file mode 100644 index 000000000..47d389c9a --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextRangeCompare.java @@ -0,0 +1,174 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRangeCompare; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Testing <code>com.sun.star.text.XTextRangeCompare</code> + * interface methods : + * <ul> + * <li><code> compareRegionStarts()</code></li> + * <li><code> compareRegionEnds()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'TEXTDOC'</code> <b>optional</b> + * (must implement <code>XTextDocument</code>): + * can be used to obtain <code>Text</code> of the document from + * which cursors can be created. + * If the relation does not exist, the relation <code>TEXT</code> + * must be specified. </li> + * <li> <code>'TEXT'</code> <b>optional</b> + * (of type <code>XText</code>): + * used to create text cursor. + * If the relation does not exist, the relation <code>TEXTDOC</code> + * must be specified. </li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextRangeCompare + */ +public class _XTextRangeCompare extends MultiMethodTest { + + /** + * the test object + */ + public XTextRangeCompare oObj = null; + String nameStr = null; + XTextCursor cursor1 = null; + XTextCursor cursor2 = null; + XText oText = null; + + /** + * Retrieves <code>XText</code> interface from relation 'TEXTDOC' + * or from 'TEXT'. + * @throws StatusException If neither 'TEXTDOC' nor 'TEXT' + * relation exists. + */ + @Override + public void before() { + nameStr = this.getClass().getName(); + + XInterface oIfc = (XInterface)tEnv.getObjRelation("TEXTDOC"); + if (oIfc!=null) { + XTextDocument oTDoc = UnoRuntime.queryInterface( + XTextDocument.class, oIfc); + oText = oTDoc.getText(); + } + XText aText = (XText) tEnv.getObjRelation("TEXT"); + if (aText != null) { + oText = aText; + } + + if (oText == null) { + throw new StatusException(Status.failed + ("Neither 'TEXTDOC' nor 'TEXT' relation not found")) ; + } + } + + /** + * One cursor is created and to its position a paragraph + * inserted, then the first five characters were selected. + * A second cursor was created and the last 7 characters + * were selected.<p> + * + * Has <b>OK</b> status if the compare returns 1, i.e. + * the second cursor end is before the first. + */ + public void _compareRegionEnds() { + boolean bResult = false; + short n = 0; + log.println( "testing compareRegionEnds()" ); + + try{ + cursor1 = oText.createTextCursor(); + oText.insertString(cursor1, nameStr, false); + + cursor1.gotoStart(false); + cursor1.goRight((short)5, true); + cursor2 = oText.createTextCursor(); + cursor2.gotoEnd(false); + cursor2.goLeft((short)7, true); + + log.println("hole text: '" + oText.getString() + "'"); + log.println("cursor1: '"+cursor1.getString() + "'"); + log.println("cursor2: '"+cursor2.getString() + "'"); + log.println("check: oObj.compareRegionStarts(cursor1, cursor2)"); + + n = oObj.compareRegionEnds(cursor1, cursor2); + + log.println( "Result (short) : " + n ); + }catch(com.sun.star.lang.IllegalArgumentException e){ + log.println( "Exception: " + e); + e.printStackTrace(log); + } + + if (n == 1){bResult = true;} + tRes.tested( "compareRegionEnds()", bResult ); + } + + /** + * One cursor is created and to its position a paragraph + * inserted, then the first five characters were selected. + * A second cursor was created and the last 7 characters + * were selected.<p> + * + * Has <b>OK</b> status if the compare returns 1, i.e. + * the second cursor start is before the first. + */ + public void _compareRegionStarts() { + boolean bResult = false; + short n = 0; + + try{ + cursor1 = oText.createTextCursor(); + oText.insertString(cursor1, nameStr, false); + + cursor1.gotoStart(false); + cursor1.goRight((short)5, true); + cursor2 = oText.createTextCursor(); + cursor2.gotoEnd(false); + cursor2.goLeft((short)7, true); + + log.println("hole text: '" + oText.getString() + "'"); + log.println("cursor1: '"+cursor1.getString() + "'"); + log.println("cursor2: '"+cursor2.getString() + "'"); + log.println("check: oObj.compareRegionStarts(cursor1, cursor2)"); + n = oObj.compareRegionStarts(cursor1, cursor2); + + log.println( "Result (short) : " + n ); + }catch(com.sun.star.lang.IllegalArgumentException e){ + log.println( "Exception: " + e); + e.printStackTrace(log); + } + if (n == 1){bResult = true;} + tRes.tested( "compareRegionStarts()", bResult ); + } + +} + diff --git a/qadevOOo/tests/java/ifc/text/_XTextRangeMover.java b/qadevOOo/tests/java/ifc/text/_XTextRangeMover.java new file mode 100644 index 000000000..affdb6ce8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextRangeMover.java @@ -0,0 +1,88 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextRangeMover; + +/** + * Testing <code>com.sun.star.text.XTextRangeMover</code> + * interface methods : + * <ul> + * <li><code> moveTextRange()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'RangeForMove'</code> (of type <code>XTextRange</code>): + * the range to be moved. </li> + * <li> <code>'XTextRange'</code> (of type <code>XTextRange</code>): + * the range that includes moving range. </li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextRangeMover + */ +public class _XTextRangeMover extends MultiMethodTest { + + public XTextRangeMover oObj = null; + + XTextRange xTextRange = null; + XTextRange oMoveRange = null; + + /** + * Moves the range obtained from relation 'RangeForMove' by 1 paragraph + * and compares index of moved string in the whole text obtained + * from relation 'XTextRange'. <p> + * Has <b>OK</b> status if index of moved range is changed after method call. + */ + public void _moveTextRange(){ + oMoveRange = (XTextRange) tEnv.getObjRelation("RangeForMove"); + xTextRange = (XTextRange) tEnv.getObjRelation("XTextRange"); + + if (oMoveRange == null) { + throw new StatusException( + Status.failed("Couldn't get relation 'RangeForMove'")); + } + + if (xTextRange == null) { + throw new StatusException( + Status.failed("Couldn't get relation 'XTextRange'")); + } + + log.println("Content before moving:"); + log.println(xTextRange.getString()); + log.println("Text range for moving:"); + log.println(oMoveRange.getString()); + int indexBefore = xTextRange.getString().indexOf(oMoveRange.getString()); + oObj.moveTextRange(oMoveRange,(short) 1); + log.println("Content after moving:"); + log.println(xTextRange.getString()); + int indexAfter = xTextRange.getString().indexOf(oMoveRange.getString()); + + boolean res = indexBefore != indexAfter; + log.println("Index before moving:" + indexBefore); + log.println("Index after moving:" + indexAfter); + + tRes.tested("moveTextRange()", res); + } +} + diff --git a/qadevOOo/tests/java/ifc/text/_XTextSection.java b/qadevOOo/tests/java/ifc/text/_XTextSection.java new file mode 100644 index 000000000..9aeb70c14 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextSection.java @@ -0,0 +1,68 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextSection; + +/** + * Testing <code>com.sun.star.text.XTextSection</code> + * interface methods : + * <ul> + * <li><code> getParentSection()</code></li> + * <li><code> getChildSections()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextSection + */ +public class _XTextSection extends MultiMethodTest { + + public static XTextSection oObj = null; + public XTextSection child = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns non zero length array. + */ + public void _getChildSections(){ + boolean bResult = false; + XTextSection oSect[] = oObj.getChildSections(); + if (oSect.length > 0){ + bResult = true; + child = oSect[0]; + } + tRes.tested("getChildSections()", bResult); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getParentSection(){ + requiredMethod("getChildSections()"); + boolean bResult = false; + bResult = (child.getParentSection() != null); + tRes.tested("getParentSection()", bResult); + } + + +} // finish class _XTextSection + diff --git a/qadevOOo/tests/java/ifc/text/_XTextSectionsSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextSectionsSupplier.java new file mode 100644 index 000000000..38b31ad12 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextSectionsSupplier.java @@ -0,0 +1,66 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XTextSectionsSupplier; + + +public class _XTextSectionsSupplier extends MultiMethodTest { + public XTextSectionsSupplier oObj; + + public void _getTextSections() { + XNameAccess sections = oObj.getTextSections(); + boolean res = checkSections(sections); + tRes.tested("getTextSections()", res); + } + + protected boolean checkSections(XNameAccess sections) { + String[] sNames = sections.getElementNames(); + boolean res = true; + + for (int k = 0; k < sNames.length; k++) { + try { + res &= sections.hasByName(sNames[k]); + res &= (sections.getByName(sNames[k]) != null); + log.println("Works for ... " + sNames[k]); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("positive test failed " + e.getMessage()); + res = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("positive test failed " + e.getMessage()); + res = false; + } + } + + try { + sections.getByName("unknown"); + log.println("negative test failed ... no Exception thrown"); + res = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("expected Exception for wrong argument ... OK"); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("negative test failed ... wrong Exception thrown"); + res = false; + } + + return res; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/text/_XTextTable.java b/qadevOOo/tests/java/ifc/text/_XTextTable.java new file mode 100644 index 000000000..93ac5a9d9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextTable.java @@ -0,0 +1,173 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.text.XTextTable; + +/** + * Testing <code>com.sun.star.text.XTextTable</code> + * interface methods : + * <ul> + * <li><code> initialize()</code></li> + * <li><code> getRows()</code></li> + * <li><code> getColumns()</code></li> + * <li><code> getCellByName()</code></li> + * <li><code> getCellNames()</code></li> + * <li><code> createCursorByCellName()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'NROW'</code> : the number of rows in table + * </li> + * <li> <code>'NCOL'</code> : the number of columns in table + * </li> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XTextTable + */ +public class _XTextTable extends MultiMethodTest { + + public XTextTable oObj = null; // oObj filled by MultiMethodTest + int nRow; + int nCol; + + String cellNamesList[] = null ; + + @Override + protected void before() { + Integer num_row = (Integer)tEnv.getObjRelation("NROW"); + if (num_row == null) { + throw new StatusException + (Status.failed("Couldn't get relation 'NROW'")); + } + Integer num_col = (Integer)tEnv.getObjRelation("NCOL"); + if (num_col == null) { + throw new StatusException + (Status.failed("Couldn't get relation 'NCOL'")); + } + nRow = num_row.intValue(); + nCol = num_col.intValue(); + } + + /** + * The method is not called directly here, because it must + * be called before being inserted to the document. <p> + * + * Always has <b> OK </b> status. <p> + */ + public void _initialize() { + + // initialize() + log.println( "test for initialize()" ); + tRes.tested( "initialize()", true); + } + + /** + * Test calls the method passing as cell name the first + * element from names returned by <code>getCellNames</code> + * method. <p> + * + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getCellNames() </code> : its result used by test. </li> + * </ul> + */ + public void _createCursorByCellName(){ + requiredMethod("getCellNames()") ; + + // createCursorByCellName() + log.println( "test for createCursorByCellName()" ); + tRes.tested( "createCursorByCellName()", + oObj.createCursorByCellName( cellNamesList[0] ) != null ); + } + + /** + * Test calls the method passing as cell name the first + * element from names returned by <code>getCellNames</code> + * method. <p> + * + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getCellNames() </code> : its result used by test. </li> + * </ul> + */ + public void _getCellByName(){ + requiredMethod("getCellNames()") ; + + // getCellByName() + log.println( "test for getCellByName()" ); + tRes.tested( "getCellByName()", + oObj.getCellByName( cellNamesList[0] ) != null ); + } + + /** + * Obtains cell names of the table. <p> + * + * Has <b>OK</b> status if number of elements in the returned + * array is equal to [row number] * [column number] + * and if the first name is 'A1'. + */ + public void _getCellNames(){ + // getCellNames() + log.println( "test for getCellNames()" ); + cellNamesList = oObj.getCellNames(); + + boolean result = cellNamesList.length == ( nRow * nCol ) ; + result &= cellNamesList[0].equals( "A1" ) ; + + tRes.tested( "getCellNames()", result ) ; + } + + /** + * Obtains columns of the table. <p> + * + * Has <b>OK</b> status if the number of element of returned + * collection is equal to real number of columns in the table. + */ + public void _getColumns(){ + // getColumns() + log.println( "test for getColumns()" ); + tRes.tested( "getColumns()", nCol == oObj.getColumns().getCount() ); + } + + /** + * Obtains rows of the table. <p> + * + * Has <b>OK</b> status if the number of element of returned + * collection is equal to real number of rows in the table. + */ + public void _getRows(){ + // getRows() + log.println( "test for getRows()" ); + tRes.tested( "getRows()", nRow == oObj.getRows().getCount() ); + } + +} + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextTableCursor.java b/qadevOOo/tests/java/ifc/text/_XTextTableCursor.java new file mode 100644 index 000000000..ac95453d0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextTableCursor.java @@ -0,0 +1,283 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextTableCursor; + + +/** + * Testing <code>com.sun.star.text.XTextTableCursor</code> + * interface methods : + * <ul> + * <li><code> getRangeName()</code></li> + * <li><code> gotoCellByName()</code></li> + * <li><code> goLeft()</code></li> + * <li><code> goRight()</code></li> + * <li><code> goUp()</code></li> + * <li><code> goDown()</code></li> + * <li><code> gotoStart()</code></li> + * <li><code> gotoEnd()</code></li> + * <li><code> mergeRange()</code></li> + * <li><code> splitRange()</code></li> + * </ul> <p> + * + * <b>Prerequisites : </b> the table must have a size + * 2x2 and current cursor position must be in the upper + * left cell. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * + * After test completion object environment has to be recreated + * because after merging and splitting cells their names + * differ from initial. + * + * @see com.sun.star.text.XTextTableCursor + */ +public class _XTextTableCursor extends MultiMethodTest { + + public XTextTableCursor oObj = null; // oObj filled by MultiMethodTest + + /** + * Moves the cursor to upper-left cell and checks + * its range name. <p> + * + * Has <b>OK</b> status if the name returned is 'A1'. + */ + public void _getRangeName(){ + log.println( "test for getRangeName()" ); + oObj.gotoStart(false); + String oCellName = oObj.getRangeName(); + log.println( "CellName = " + oCellName ); + + tRes.tested("getRangeName()", oCellName.equals("A1") ); + } + + /** + * Calls the method which moves the cursor down by 1 cell, + * after that returns cursor to the old position. <p> + * + * Has <b>OK</b> status if the method returns + * <code>true</code>. + */ + public void _goDown(){ + boolean bDown = false; + log.println( "test for goDown()" ); + short i = 1; + + bDown = oObj.goDown(i,false); + + tRes.tested("goDown()", bDown ); + oObj.goUp(i,false); + } + + /** + * Calls the method which moves the cursor to the right by 1 cell, + * after that returns cursor to the old position. <p> + * + * Has <b>OK</b> status if the method returns + * <code>true</code>. + */ + public void _goRight(){ + boolean bRight = false; + log.println( "test for goRight()" ); + short i = 1; + + bRight = oObj.goRight(i,false); + + tRes.tested("goRight()", bRight ); + oObj.goLeft(i,false); + } + + /** + * Calls the method which moves the cursor to the left by 1 cell, + * after that returns cursor to the old position. <p> + * + * Has <b>OK</b> status if the method returns + * <code>true</code>. + */ + public void _goLeft(){ + boolean bLeft = false; + log.println( "test for goLeft()" ); + short i = 1; + + oObj.goRight(i,false); + bLeft = oObj.goLeft(i,false); + + tRes.tested("goLeft()", bLeft ); + } + + /** + * Calls the method which moves the cursor up by 1 cell, + * after that returns cursor to the old position. <p> + * + * Has <b>OK</b> status if the method returns + * <code>true</code>. + */ + public void _goUp(){ + boolean bUp = false; + log.println( "test for goUp()" ); + short i = 1; + + oObj.gotoEnd(true); + + bUp = oObj.goUp(i,false); + tRes.tested("goUp()", bUp ); + } + + /** + * Moves the cursor to the cell with name 'B1', then + * checks the current range name. <p> + * Has <b>OK</b> status if the returned range name is + * 'B1'. + */ + public void _gotoCellByName(){ + log.println( "test for gotoCellByName()" ); + + oObj.gotoCellByName("B1",false); + String oCellName = oObj.getRangeName(); + + tRes.tested("gotoCellByName()", oCellName.equals("B1") ); + } + + /** + * Moves cursor to the start (upper-left cell). Then + * checks the current range name. <p> + * + * Has <b>OK</b> status if current range name is 'A1'. + */ + public void _gotoStart(){ + log.println( "test for gotoStart()" ); + + oObj.gotoStart(false); + String oCellName = oObj.getRangeName(); + + tRes.tested("gotoStart()", oCellName.equals("A1") ); + } + + /** + * Moves cursor to the end (lower-right cell). Then + * checks the current range name. <p> + * + * Has <b>OK</b> status if current range name is 'B2' + * (the table is assumed to be of size 2x2). + */ + public void _gotoEnd(){ + log.println( "test for gotoEnd()" ); + + oObj.gotoEnd(false); + String oCellName = oObj.getRangeName(); + + tRes.tested("gotoEnd()", oCellName.equals("B2") ); + } + + /** + * Selects all cells in the table and merges them. + * Finally move the cursor to the end and checks + * current range name.<p> + * + * Has <b>OK</b> status if the end cell has a name + * 'A1'. + * + * The following method tests are to be executed before : + * <ul> + * <li> <code> getRangeName(), gotoStart(), gotoEnd() + * goLeft(), goRight(), goUp(), goDown(), gotoCellByName()</code> + * : these methods must be completed before all cells of the + * table are merged into one cell </li> + * </ul> + */ + public void _mergeRange(){ + executeMethod("getRangeName()") ; + executeMethod("gotoStart()") ; + executeMethod("gotoEnd()") ; + executeMethod("goLeft()") ; + executeMethod("goRight()") ; + executeMethod("goUp()") ; + executeMethod("goDown()") ; + executeMethod("gotoCellByName()") ; + + boolean bMerge = false; + log.println( "test for mergeRange()" ); + + oObj.gotoStart(false); + oObj.gotoEnd(true); + bMerge = oObj.mergeRange(); + + oObj.gotoEnd(false); + + String curName = oObj.getRangeName() ; + bMerge &= "A1".equals(curName) ; + + tRes.tested("mergeRange()", bMerge ); + } + + /** + * First splits the cell horizontally. Then the end cell + * name is checked. Second split all cells vertically and + * again the end cell name is checked<p> + * + * Has <b> OK </b> status if in the first case the end cell name + * is not 'A1', and in the second case the end cell name is not + * equal to the name gotten in the first case. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> mergeRange() </code> : to have one cell in a table + * which this test splits. </li> + * </ul> + */ + public void _splitRange(){ + requiredMethod("mergeRange()") ; + + boolean bSplit = true ; + log.println( "test for splitRange" ) ; + short i = 1 ; + + bSplit &= oObj.splitRange(i, true) ; + + oObj.gotoEnd(false); + String horName = oObj.getRangeName() ; + log.println("The end cell after horiz. split : " + horName) ; + bSplit &= !"A1".equals(horName) ; + + oObj.gotoStart(false); + oObj.gotoEnd(true); + bSplit &= oObj.splitRange(i, false) ; + + oObj.gotoEnd(false); + String vertName = oObj.getRangeName() ; + log.println("The end cell after vert. split : " + vertName) ; + bSplit &= !horName.equals(vertName) ; + + tRes.tested("splitRange()", bSplit ) ; + } + + /** + * Forces object environment recreation. + */ + @Override + public void after() { + disposeEnvironment() ; + } + + } // finish class _XTextTableCursor + + diff --git a/qadevOOo/tests/java/ifc/text/_XTextTablesSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextTablesSupplier.java new file mode 100644 index 000000000..c12072d74 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextTablesSupplier.java @@ -0,0 +1,57 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XTextTablesSupplier; + + +/** + * Testing <code>com.sun.star.text.XTextTablesSupplier</code> + * interface methods : + * <ul> + * <li><code> getTextTables()</code></li> + * </ul> <p> + * The table collection tested <b>must</b> have a table + * with name 'SwXTextDocument'. <p> + * Test is multithread compliant. <p> + * @see com.sun.star.text.XTextTablesSupplier + */ +public class _XTextTablesSupplier extends MultiMethodTest { + + public static XTextTablesSupplier oObj = null; + + /** + * Get the collection of tables. Then check it. <p> + * Has <b>OK</b> status if returned collection contains + * element with name 'SwXTextDocument'. + */ + public void _getTextTables() { + boolean res = false; + + XNameAccess the_tables = oObj.getTextTables(); + res = the_tables.hasByName("SwXTextDocument"); + + tRes.tested("getTextTables()",res); + } + +} // finish class _XTextTablesSupplier + diff --git a/qadevOOo/tests/java/ifc/text/_XTextViewCursorSupplier.java b/qadevOOo/tests/java/ifc/text/_XTextViewCursorSupplier.java new file mode 100644 index 000000000..24a9c9728 --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XTextViewCursorSupplier.java @@ -0,0 +1,53 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XTextViewCursor; +import com.sun.star.text.XTextViewCursorSupplier; + +/** + * Testing <code>com.sun.star.text.XTextViewCursorSupplier</code> + * interface methods : + * <ul> + * <li><code> getViewCursor()</code></li> + * </ul> <p> + * Test is multithread compliant. <p> + * @see com.sun.star.text.XTextViewCursorSupplier + */ +public class _XTextViewCursorSupplier extends MultiMethodTest { + + public XTextViewCursorSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getViewCursor(){ + + XTextViewCursor oTVC = oObj.getViewCursor(); + tRes.tested("getViewCursor()", oTVC != null); + + } // finish _getViewCursor() + +} // finish class _XTextViewCursorSupplier + + diff --git a/qadevOOo/tests/java/ifc/text/_XWordCursor.java b/qadevOOo/tests/java/ifc/text/_XWordCursor.java new file mode 100644 index 000000000..47474472a --- /dev/null +++ b/qadevOOo/tests/java/ifc/text/_XWordCursor.java @@ -0,0 +1,124 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.text; + +import lib.MultiMethodTest; + +import com.sun.star.text.XWordCursor; + +/** + * Testing <code>com.sun.star.text.XWordCursor</code> + * interface methods : + * <ul> + * <li><code> isStartOfWord()</code></li> + * <li><code> isEndOfWord()</code></li> + * <li><code> gotoNextWord()</code></li> + * <li><code> gotoPreviousWord()</code></li> + * <li><code> gotoEndOfWord()</code></li> + * <li><code> gotoStartOfWord()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.text.XWordCursor + */ +public class _XWordCursor extends MultiMethodTest { + + public XWordCursor oObj = null; // oObj filled by MultiMethodTest + + /** + * Moves the cursor to start of the text. + */ + @Override + public void before() { + oObj.gotoStart(false); + } + + /** + * First moves the cursor to the next word to be sure that + * at least one word is situated before. Then moves cursor + * to the previous word and checks the value returned. <p> + * + * Has <b>OK</b> status if method returns <code>true</code>. + */ + public void _gotoPreviousWord(){ + oObj.gotoNextWord(false); + tRes.tested("gotoPreviousWord()", oObj.gotoPreviousWord(false) ); + } + + /** + * First moves the cursor to the previous word to be sure that + * at least one word is situated after. Then moves cursor + * to the next word and checks the value returned. <p> + * + * Has <b>OK</b> status if method returns <code>true</code>. + */ + public void _gotoNextWord(){ + oObj.gotoPreviousWord(false) ; + tRes.tested("gotoNextWord()", oObj.gotoNextWord(false) ); + } + + /** + * First moves the cursor to the start of the current word, + * then to the end and checks the value returned. <p> + * + * Has <b>OK</b> status if method returns <code>true</code>. + */ + public void _gotoEndOfWord(){ + oObj.gotoStart(false); + tRes.tested("gotoEndOfWord()", oObj.gotoEndOfWord(false) ); + } + + /** + * Move cursor to the start, then to the end. After that the + * method is called and returned value is checked. <p> + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _isEndOfWord(){ + log.println("gotoStartOfWord() = " + oObj.gotoStartOfWord(false)) ; + log.println("gotoEndOfWord() = " + oObj.gotoEndOfWord(false)); + + tRes.tested("isEndOfWord()", oObj.isEndOfWord() ); + } + + /** + * Move cursor to the end, then to the start. After that the + * method is called and returned value is checked. <p> + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _isStartOfWord(){ + + oObj.gotoEndOfWord(false); + oObj.gotoStartOfWord(false); + tRes.tested("isStartOfWord()", oObj.isStartOfWord() ); + } + + /** + * First moves the cursor to the start of the current word, + * then shifts it 2 symbols to the right. After that the + * method is called and returned value is checked.<p> + * + * Has <b>OK</b> status if method returns <code>true</code>. + */ + public void _gotoStartOfWord(){ + oObj.gotoStartOfWord(false); + oObj.goRight((short) 2, false) ; + tRes.tested("gotoStartOfWord()", oObj.gotoStartOfWord(false) ); + } + + } // finish class _XWordCursor + |