diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /qadevOOo/tests/java/ifc/linguistic2 | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
10 files changed, 1062 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/linguistic2/_LinguProperties.java b/qadevOOo/tests/java/ifc/linguistic2/_LinguProperties.java new file mode 100644 index 000000000..930986d56 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_LinguProperties.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.linguistic2; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.linguistic2.LinguProperties</code> +* service properties: +* <ul> +* <li><code>'IsGermanPreReform'</code></li> +* <li><code>'IsUseDictionaryList'</code></li> +* <li><code>'IsIgnoreControlCharacters'</code></li> +* <li><code>'IsSpellUpperCase'</code></li> +* <li><code>'IsSpellWithDigits'</code></li> +* <li><code>'IsSpellCapitalization'</code></li> +* <li><code>'HyphMinLeading'</code></li> +* <li><code>'HyphMinTrailing'</code></li> +* <li><code>'HyphMinWordLength'</code></li> +* <li><code>'DefaultLocale'</code></li> +* <li><code>'IsHyphAuto'</code></li> +* <li><code>'IsHyphSpecial'</code></li> +* <li><code>'IsSpellAuto'</code></li> +* <li><code>'IsSpellHide'</code></li> +* <li><code>'IsSpellInAllLanguages'</code></li> +* <li><code>'IsSpellSpecial'</code></li> +* <li><code>'IsWrapReverse'</code></li> +* <li><code>'DefaultLocale_CJK'</code></li> +* <li><code>'DefaultLocale_CTL'</code></li> +* </ul> +* @see com.sun.star.linguistic2.LinguProperties +*/ +public class _LinguProperties extends MultiPropertyTest { +} // finish class _LinguProperties + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XAvailableLocales.java b/qadevOOo/tests/java/ifc/linguistic2/_XAvailableLocales.java new file mode 100644 index 000000000..0fb7e4f88 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XAvailableLocales.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.linguistic2; + +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XAvailableLocales; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.linguistic2.XAvailableLocales</code> +* interface methods: +* <ul> +* <li><code>getAvailableLocales()</code></li> +* </ul> <p> +* @see com.sun.star.linguistic2.XAvailableLocales +*/ +public class _XAvailableLocales extends MultiMethodTest { + + public XAvailableLocales oObj = null; + + /** + * Test calls the method, stores returned value and checks it. <p> + * Has <b> OK </b> status if length of returned array isn't zero. <p> + */ + public void _getAvailableLocales() { + Locale[] locales = oObj.getAvailableLocales("com.sun.star.linguistic2.Hyphenator"); + tRes.tested("getAvailableLocales()", locales.length > 0); + } + +} // finish class XAvailableLocales + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XDictionaryList.java b/qadevOOo/tests/java/ifc/linguistic2/_XDictionaryList.java new file mode 100644 index 000000000..edbdc1a86 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XDictionaryList.java @@ -0,0 +1,286 @@ +/* + * 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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.lang.EventObject; +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.DictionaryListEvent; +import com.sun.star.linguistic2.XDictionary; +import com.sun.star.linguistic2.XDictionaryList; +import com.sun.star.linguistic2.XDictionaryListEventListener; + +/** +* Testing <code>com.sun.star.linguistic2.XDictionaryList</code> +* interface methods: +* <ul> +* <li><code>getCount()</code></li> +* <li><code>getDictionaries()</code></li> +* <li><code>getDictionaryByName()</code></li> +* <li><code>addDictionary()</code></li> +* <li><code>removeDictionary()</code></li> +* <li><code>addDictionaryListEventListener()</code></li> +* <li><code>removeDictionaryListEventListener()</code></li> +* <li><code>beginCollectEvents()</code></li> +* <li><code>endCollectEvents()</code></li> +* <li><code>flushEvents()</code></li> +* <li><code>createDictionary()</code></li> +* </ul> <p> +* @see com.sun.star.linguistic2.XDictionaryList +*/ +public class _XDictionaryList extends MultiMethodTest { + + public XDictionaryList oObj = null; + public XDictionary addedDic = null; + + /** + * Flag for testing of listeners. + */ + public boolean listenerCalled = false; + + /** + * Class implements interface <code>XDictionaryListEventListener</code> + * for test method <code>addDictionaryListEventListener</code>. + * @see com.sun.star.linguistic2.XDictionaryListEventListener + */ + public class MyDictionaryListEventListener implements + XDictionaryListEventListener { + + public void disposing ( EventObject oEvent ) { + log.println("Listener has been disposed"); + } + public void processDictionaryListEvent( DictionaryListEvent aDicEvent) { + listenerCalled = true; + } + } + + XDictionaryListEventListener listener = new MyDictionaryListEventListener(); + + short count = 0; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is greater than zero. <p> + */ + public void _getCount() { + count = oObj.getCount(); + tRes.tested("getCount()",(count > 0) ); + } + + /** + * Test calls the method and checks number of obtained dictionaries + * with value that was returned by method <code>getCount</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getCount() </code> : to have number of dictionaries </li> + * </ul> + */ + public void _getDictionaries() { + requiredMethod("getCount()"); + + XDictionary[] dics = oObj.getDictionaries(); + boolean res = (dics.length == count); + if (!res) { + log.println("Expected: " + oObj.getCount()); + log.println("Gained: " + dics.length); + } + tRes.tested("getDictionaries()", res); + } + + /** + * Test calls the method, makes some actions that leads to event + * <code>processDictionaryListEvent</code>, removes listener, checks flag + * <code>listenerCalled</code> and checks returned value. <p> + * Has <b> OK </b> status if returned value is true and value of flag + * <code>listenerCalled</code> is true. <p> + */ + public void _addDictionaryListEventListener() { + listenerCalled = false; + + XDictionary xDic = oObj.createDictionary("ListenDic", + new Locale("en","US","WIN"), + com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + + boolean res = oObj.addDictionaryListEventListener(listener, false); + + oObj.flushEvents(); + oObj.addDictionary(xDic); + xDic.add("Positive", false, ""); + xDic.setActive(true); + oObj.flushEvents(); + oObj.removeDictionary(xDic); + + oObj.removeDictionaryListEventListener(listener); + + tRes.tested("addDictionaryListEventListener()",listenerCalled && res); + } + + /** + * Test calls the method, makes some actions that leads to event + * <code>processDictionaryListEvent</code>, checks flag + * <code>listenerCalled</code> and checks returned value. <p> + * Has <b> OK </b> status if returned value is false and value of flag + * <code>listenerCalled</code> is false. <p> + */ + public void _removeDictionaryListEventListener() { + listenerCalled = false; + + XDictionary xDic = oObj.createDictionary("ListenDic", + new Locale("en","US","WIN"), + com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + + oObj.addDictionaryListEventListener(listener,false); + + oObj.flushEvents(); + oObj.addDictionary(xDic); + xDic.add("Positive", false,""); + xDic.setActive(true); + + listenerCalled = false; + boolean res = oObj.removeDictionaryListEventListener(listener); + + oObj.flushEvents(); + oObj.removeDictionary(xDic); + + tRes.tested( + "removeDictionaryListEventListener()", + !listenerCalled && res ); + } + + /** + * Test creates new dictionary, adds the dictionary to list and compares + * number of dictionaries after adding with number of dictionaries before.<p> + * Has <b> OK </b> status if number of dictionaries after method call is + * greater than number of dictionaries before method call. <p> + */ + public void _addDictionary() { + short previous = oObj.getCount(); + addedDic = oObj.createDictionary("AddedDic",new Locale("en","US","WIN"), + com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + addedDic.add("Positive",false,""); + + oObj.addDictionary(addedDic); + + short after = oObj.getCount(); + + tRes.tested( "addDictionary()", (after > previous) ); + } + + /** + * Test calls the method and compares number of dictionaries + * before method call and after. <p> + * Has <b> OK </b> status if number of dictionaries before method call is + * less than number of dictionaries after method call. <p> + */ + public void _removeDictionary() { + short previous = oObj.getCount(); + oObj.removeDictionary(addedDic); + short after = oObj.getCount(); + tRes.tested("removeDictionary()",(after < previous) ); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getDictionaryByName() { + XDictionary getting = oObj.getDictionaryByName("NegativDic"); + tRes.tested("getDictionaryByName()", getting != null ); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _createDictionary() { + XDictionary tmpDic = oObj.createDictionary("AddedDic", + new Locale("en","US","WIN"), + com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + tRes.tested("createDictionary()", tmpDic != null ); + } + + /** + * Test creates dictionary, adds dictionary list event listener, + * begins collect events, makes some actions that leads to event + * <code>processDictionaryListEvent</code>, ends collect events, + * removes the listener and checks the flag <code>listenerCalled</code> . <p> + * Has <b> OK </b> status if value of the flag is true. <p> + */ + public void _beginCollectEvents() { + listenerCalled = false; + + XDictionary xDic = oObj.createDictionary("ListenDic", + new Locale("en","US","WIN"), + com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + + oObj.addDictionaryListEventListener(listener,false); + oObj.beginCollectEvents(); + + oObj.addDictionary(xDic); + xDic.add("Positive",false,""); + xDic.setActive(true); + + oObj.removeDictionary(xDic); + oObj.endCollectEvents(); + + oObj.removeDictionaryListEventListener(listener); + + tRes.tested("beginCollectEvents()", listenerCalled ); + } + + /** + * Test does nothing. <p> + * Has <b> OK </b> status if method + * <code>addDictionaryListEventListener()</code> was completed + * successfully. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addDictionaryListEventListener() </code> : + * if listener adding worked, flushEvents was already used and worked </li> + * </ul> + */ + public void _flushEvents() { + requiredMethod("addDictionaryListEventListener()"); + // if listener adding worked, flushEvents was already used and worked + tRes.tested("flushEvents()",true); + } + + /** + * Test does nothing. <p> + * Has <b> OK </b> status if method + * <code>beginCollectEvents()</code> was completed successfully. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> beginCollectEvents() </code> : + * if beginCollectEvents() worked then endCollectEvents was already + * used and worked </li> + * </ul> + */ + public void _endCollectEvents() { + requiredMethod("beginCollectEvents()"); + // if beginCollectEvents() worked, endCollectEvents + // was already used and worked + tRes.tested("endCollectEvents()",true); + } + +} // finish class _XDictionaryList + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XHyphenator.java b/qadevOOo/tests/java/ifc/linguistic2/_XHyphenator.java new file mode 100644 index 000000000..907cd5aeb --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XHyphenator.java @@ -0,0 +1,102 @@ +/* + * 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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XHyphenatedWord; +import com.sun.star.linguistic2.XHyphenator; +import com.sun.star.linguistic2.XPossibleHyphens; + +/** +* Testing <code>com.sun.star.linguistic2.XHyphenator</code> +* interface methods: +* <ul> +* <li><code>hyphenate()</code></li> +* <li><code>queryAlternativeSpelling()</code></li> +* <li><code>createPossibleHyphens()</code></li> +* </ul><p> +* @see com.sun.star.linguistic2.XHyphenator +*/ +public class _XHyphenator extends MultiMethodTest { + + public XHyphenator oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _hyphenate() { + boolean res = true; + PropertyValue[] Props = null; + try { + XHyphenatedWord result = oObj.hyphenate( + "wacker",new Locale("de","DE",""),(short)3,Props); + res &= (result != null); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'hyphenate'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("hyphenate()",res); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _queryAlternativeSpelling() { + boolean res = true; + PropertyValue[] Props = null; + try { + XHyphenatedWord result = oObj.queryAlternativeSpelling( + "wacker",new Locale("de","DE",""),(short)2,Props); + res &= (result != null); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'queryAlternativeSpelling'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("queryAlternativeSpelling()",res); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _createPossibleHyphens() { + boolean res = true; + PropertyValue[] Props = null; + try { + XPossibleHyphens result = oObj.createPossibleHyphens( + "wacker",new Locale("de","DE",""),Props); + res &= (result != null); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'createPossibleHyphens'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("createPossibleHyphens()",res); + } + +} // \u0422\u044B finish class XHyphenator + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceEventBroadcaster.java b/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceEventBroadcaster.java new file mode 100644 index 000000000..9396ebf28 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceEventBroadcaster.java @@ -0,0 +1,85 @@ +/* + * 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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.lang.EventObject; +import com.sun.star.linguistic2.LinguServiceEvent; +import com.sun.star.linguistic2.XLinguServiceEventBroadcaster; +import com.sun.star.linguistic2.XLinguServiceEventListener; + +/** +* Testing <code>com.sun.star.linguistic2.XLinguServiceEventBroadcaster</code> +* interface methods: +* <ul> +* <li><code>addLinguServiceEventListener()</code></li> +* <li><code>removeLinguServiceEventListener()</code></li> +* </ul><p> +* @see com.sun.star.linguistic2.XLinguServiceEventBroadcaster +*/ +public class _XLinguServiceEventBroadcaster extends MultiMethodTest { + + public XLinguServiceEventBroadcaster oObj = null; + + /** + * Class implements interface <code>XLinguServiceEventListener</code> + * for test method <code>addLinguServiceEventListener</code>. + * @see com.sun.star.linguistic2.XLinguServiceEventListener + */ + public class MyLinguServiceEventListener implements + XLinguServiceEventListener { + public void disposing ( EventObject oEvent ) { + log.println("Listener has been disposed"); + } + public void processLinguServiceEvent(LinguServiceEvent aServiceEvent) { + log.println("Listener called"); + } + + } + + XLinguServiceEventListener listener = new MyLinguServiceEventListener(); + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is true. <p> + */ + public void _addLinguServiceEventListener() { + boolean res = true; + + res = oObj.addLinguServiceEventListener(listener); + + tRes.tested("addLinguServiceEventListener()",res); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is true. <p> + */ + public void _removeLinguServiceEventListener() { + boolean res = true; + + res = oObj.removeLinguServiceEventListener(listener); + + tRes.tested("removeLinguServiceEventListener()",res); + } + +} // finish class XLinguServiceEventBroadcaster + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceManager.java b/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceManager.java new file mode 100644 index 000000000..2f71ea372 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceManager.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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.lang.EventObject; +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.LinguServiceEvent; +import com.sun.star.linguistic2.XHyphenator; +import com.sun.star.linguistic2.XLinguServiceEventListener; +import com.sun.star.linguistic2.XLinguServiceManager; +import com.sun.star.linguistic2.XSpellChecker; +import com.sun.star.linguistic2.XThesaurus; + +/** +*Testing <code>com.sun.star.linguistic2.XLinguServiceManager</code> +* interface methods: +* <ul> +* <li><code>getSpellChecker()</code></li> +* <li><code>getHyphenator()</code></li> +* <li><code>getThesaurus()</code></li> +* <li><code>addLinguServiceManagerListener()</code></li> +* <li><code>removeLinguServiceManagerListener()</code></li> +* <li><code>getAvailableServices()</code></li> +* <li><code>setConfiguredServices()</code></li> +* <li><code>getConfiguredServices()</code></li> +* </ul> <p> +*@see com.sun.star.linguistic2.XLinguServiceManager +*/ +public class _XLinguServiceManager extends MultiMethodTest { + + public XLinguServiceManager oObj = null; + + /** + * Class implements interface <code>XLinguServiceEventListener</code> + * for test method <code>addLinguServiceManagerListener</code>. + * @see com.sun.star.linguistic2.XLinguServiceEventListener + */ + public class MyLinguServiceEventListener implements + XLinguServiceEventListener { + public void disposing ( EventObject oEvent ) { + log.println("Listener has been disposed"); + } + public void processLinguServiceEvent(LinguServiceEvent aServiceEvent) { + log.println("Listener called"); + } + } + + XLinguServiceEventListener listener = new MyLinguServiceEventListener(); + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSpellChecker() { + XSpellChecker SC = oObj.getSpellChecker(); + tRes.tested("getSpellChecker()", SC != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getHyphenator() { + XHyphenator HN = oObj.getHyphenator(); + tRes.tested("getHyphenator()", HN != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getThesaurus() { + XThesaurus TS = oObj.getThesaurus(); + tRes.tested("getThesaurus()", TS != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to true. <p> + */ + public void _addLinguServiceManagerListener() { + boolean res = oObj.addLinguServiceManagerListener(listener); + tRes.tested("addLinguServiceManagerListener()", res); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to true. <p> + */ + public void _removeLinguServiceManagerListener() { + boolean res = oObj.removeLinguServiceManagerListener(listener); + tRes.tested("removeLinguServiceManagerListener()",res); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if length of returned array is + * greater than zero.<p> + */ + public void _getAvailableServices() { + String[] services = oObj.getAvailableServices( + "com.sun.star.linguistic2.Hyphenator", + new Locale("en", "US", "") ); + tRes.tested("getAvailableServices()", services.length > 0); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if length of returned array is + * greater than zero.<p> + */ + public void _getConfiguredServices() { + String[] services = oObj.getConfiguredServices( + "com.sun.star.linguistic2.Hyphenator", + new Locale("en", "US", "") ); + tRes.tested("getConfiguredServices()", services.length > 0); + } + + /** + * Test sets empty list of service, checks value returned + * by method <code>getConfiguredServices()</code> and all services + * restored finally. <p> + * Has <b> OK </b> status if length of obtained service list equal to zero. + * <p>The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getConfiguredServices() </code></li> + * </ul> + */ + public void _setConfiguredServices() { + requiredMethod("getConfiguredServices()"); + + String[] services = oObj.getConfiguredServices( + "com.sun.star.linguistic2.Hyphenator",new Locale("en","US","")); + + String[] empty = new String[0]; + oObj.setConfiguredServices( + "com.sun.star.linguistic2.Hyphenator", + new Locale("en", "US", ""), + empty ); + + String[] get = oObj.getConfiguredServices( + "com.sun.star.linguistic2.Hyphenator", new Locale("en","US","")); + + boolean res = (get.length == 0); + + oObj.setConfiguredServices( + "com.sun.star.linguistic2.Hyphenator", + new Locale("en", "US", ""), + services ); + + tRes.tested("setConfiguredServices()", res); + } + +} // finish class _XLinguServiceManager + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XSearchableDictionaryList.java b/qadevOOo/tests/java/ifc/linguistic2/_XSearchableDictionaryList.java new file mode 100644 index 000000000..a22ecf2c8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XSearchableDictionaryList.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.linguistic2; + +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XDictionaryEntry; +import com.sun.star.linguistic2.XSearchableDictionaryList; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.linguistic2.XSearchableDictionaryList</code> +* interface methods: +* <ul> +* <li><code>queryDictionaryEntry()</code></li> +* </ul> <p> +* @see com.sun.star.linguistic2.XSearchableDictionaryList +*/ +public class _XSearchableDictionaryList extends MultiMethodTest { + + public XSearchableDictionaryList oObj = null; + + /** + * Test calls the method for negative dictionary and for positive dictionary + * and checks returned values. <p> + * Has <b> OK </b> status if returned values are not null. <p> + */ + public void _queryDictionaryEntry() { + XDictionaryEntry aNegativEntry = oObj.queryDictionaryEntry("Negative", + new Locale("en","US","WIN"),false,true); + if (aNegativEntry == null) { + log.println("'queryDictionary' didn't work for negative dictionaries"); + } else { + log.println("'queryDictionary' works for negative dictionaries"); + } + XDictionaryEntry aPositivEntry = oObj.queryDictionaryEntry("Positive", + new Locale("en","US","WIN"),true,true); + if (aPositivEntry == null) { + log.println("'queryDictionary' didn't work for positive dictionaries"); + } else { + log.println("'queryDictionary' works for positive dictionaries"); + } + tRes.tested("queryDictionaryEntry()",(aNegativEntry != null) && + (aPositivEntry != null) ); + } + +} // finish class _XSearchableDictionaryList + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XSpellChecker.java b/qadevOOo/tests/java/ifc/linguistic2/_XSpellChecker.java new file mode 100644 index 000000000..75eaf8626 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XSpellChecker.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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XSpellAlternatives; +import com.sun.star.linguistic2.XSpellChecker; +import lib.Status; +import lib.StatusException; + +/** +* Testing <code>com.sun.star.linguistic2.XSpellChecker</code> +* interface methods: +* <ul> +* <li><code>isValid()</code></li> +* <li><code>spell()</code></li> +* </ul><p> +* @see com.sun.star.linguistic2.XSpellChecker +*/ +public class _XSpellChecker extends MultiMethodTest { + + public XSpellChecker oObj = null; + XSpellChecker alternative = null; + + @Override + public void before() { + alternative = (XSpellChecker) tEnv.getObjRelation("AlternativeChecker"); + if (alternative == null) throw new StatusException(Status.failed + ("Relation AlternativeChecker not found")) ; + } + + /** + * Test calls the method for a correctly spelled word and + * for an incorrectly spelled word and checks returned values. <p> + * Has <b> OK </b> status if returned value is equal to true in first case, + * if returned value is equal to false in second case and no exceptions + * were thrown. <p> + */ + public void _isValid() { + boolean res = true; + try { + log.println("Checking 'original' Spellchecker"); + PropertyValue[] empty = new PropertyValue[0] ; + res &= oObj.isValid("Sun", new Locale("en","US",""), empty); + res &= !oObj.isValid("Summersun", new Locale("en","US","") ,empty); + log.println("Result so far is - "+ (res ? "OK" : "failed")); + log.println("Checking alternative Spellchecker"); + res &= alternative.isValid("Sun", new Locale("en","US",""), empty); + res &= !alternative.isValid("Summersun", new Locale("en","US","") ,empty); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'isValid'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("isValid()",res); + } + + /** + * Test calls the method for an incorrectly spelled word + * and checks returned values. <p> + * Has <b> OK </b> status if at least one spell alternative exists + * and no exceptions were thrown. <p> + */ + public void _spell() { + boolean res = true; + try { + log.println("Checking 'original' Spellchecker"); + PropertyValue[] empty = new PropertyValue[0] ; + XSpellAlternatives alt = oObj.spell( + "Summersun",new Locale("en","US",""),empty); + String alternatives = alt.getAlternatives()[0]; + res = (alternatives != null); + log.println("Result so far is - "+ (res ? "OK" : "failed")); + log.println("Checking alternative Spellchecker"); + alt =alternative.spell( + "Summersun",new Locale("en","US",""),empty); + alternatives = alt.getAlternatives()[0]; + res &= (alternatives != null); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'spell'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("spell()",res); + } + +} // finish class MTest + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XSupportedLocales.java b/qadevOOo/tests/java/ifc/linguistic2/_XSupportedLocales.java new file mode 100644 index 000000000..a9536b8d2 --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XSupportedLocales.java @@ -0,0 +1,80 @@ +/* + * 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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XSupportedLocales; + +/** +* Testing <code>com.sun.star.linguistic2.XSupportedLocales</code> +* interface methods: +* <ul> +* <li><code>getLocales()</code></li> +* <li><code>hasLocale()</code></li> +* </ul> <p> +* @see com.sun.star.linguistic2.XSupportedLocales +*/ +public class _XSupportedLocales extends MultiMethodTest { + + public XSupportedLocales oObj = null; + public Locale[] locales = new Locale[0]; + + /** + * Test calls the method, stores returned value and checks it. <p> + * Has <b> OK </b> status if length of returned array isn't zero. <p> + */ + public void _getLocales() { + locales = oObj.getLocales(); + tRes.tested("getLocales()", locales.length > 0); + } + + /** + * Test calls the method for every language from list of supported languages, + * calls the method for one unsupported language and checks + * all returned values. <p> + * Has <b> OK </b> status if all returned values for supported languages + * are equal to true and if returned value for unsupported language is equal + * to false. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getLocales() </code> : to have list of + * all supported languages </li> + * </ul> + */ + public void _hasLocale() { + requiredMethod("getLocales()"); + boolean res = true; + + // first check all available locales + for (int i=0; i< locales.length; i++) { + res &= oObj.hasLocale(locales[i]); + } + + // now create an invalid locale + Locale invalid = new Locale("myLanguage","myCountry",""); + res &= !oObj.hasLocale(invalid); + + tRes.tested("hasLocale()", res); + } + +} // finish class XSupportedLocales + + diff --git a/qadevOOo/tests/java/ifc/linguistic2/_XThesaurus.java b/qadevOOo/tests/java/ifc/linguistic2/_XThesaurus.java new file mode 100644 index 000000000..8bfcccf6e --- /dev/null +++ b/qadevOOo/tests/java/ifc/linguistic2/_XThesaurus.java @@ -0,0 +1,63 @@ +/* + * 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.linguistic2; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.Locale; +import com.sun.star.linguistic2.XMeaning; +import com.sun.star.linguistic2.XThesaurus; + +/** +* Testing <code>com.sun.star.linguistic2.XThesaurus</code> +* interface methods: +* <ul> +* <li><code>queryMeanings()</code></li> +* </ul> <p> +* @see com.sun.star.linguistic2.XThesaurus +*/ +public class _XThesaurus extends MultiMethodTest { + + public XThesaurus oObj = null; + + /** + * Test calls the method for one of supported language and checks + * returned value. <p> + * Has <b> OK </b> status if returned array is not empty + * and no exceptions were thrown. <p> + */ + public void _queryMeanings() { + boolean res = true; + try { + XMeaning[] mean = oObj.queryMeanings( + "survive",new Locale("en","US",""), new PropertyValue[0]); + res = (mean.length > 0); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception while checking 'queryMeanings'"); + res = false; + ex.printStackTrace(log); + } + tRes.tested("queryMeanings()",res); + } + + +} // finish class + + |