From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../java/ifc/linguistic2/_LinguProperties.java | 52 ++++ .../java/ifc/linguistic2/_XAvailableLocales.java | 48 ++++ .../java/ifc/linguistic2/_XDictionaryList.java | 286 +++++++++++++++++++++ .../tests/java/ifc/linguistic2/_XHyphenator.java | 102 ++++++++ .../_XLinguServiceEventBroadcaster.java | 85 ++++++ .../ifc/linguistic2/_XLinguServiceManager.java | 174 +++++++++++++ .../linguistic2/_XSearchableDictionaryList.java | 64 +++++ .../tests/java/ifc/linguistic2/_XSpellChecker.java | 108 ++++++++ .../java/ifc/linguistic2/_XSupportedLocales.java | 80 ++++++ .../tests/java/ifc/linguistic2/_XThesaurus.java | 63 +++++ 10 files changed, 1062 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_LinguProperties.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XAvailableLocales.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XDictionaryList.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XHyphenator.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceEventBroadcaster.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XLinguServiceManager.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XSearchableDictionaryList.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XSpellChecker.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XSupportedLocales.java create mode 100644 qadevOOo/tests/java/ifc/linguistic2/_XThesaurus.java (limited to 'qadevOOo/tests/java/ifc/linguistic2') 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 com.sun.star.linguistic2.LinguProperties +* service properties: +* +* @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 com.sun.star.linguistic2.XAvailableLocales +* interface methods: +*

+* @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.

+ * Has OK status if length of returned array isn't zero.

+ */ + 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 com.sun.star.linguistic2.XDictionaryList +* interface methods: +*

+* @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 XDictionaryListEventListener + * for test method addDictionaryListEventListener. + * @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.

+ * Has OK status if returned value is greater than zero.

+ */ + 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 getCount.

+ * Has OK status if values are equal.

+ * The following method tests are to be completed successfully before : + *

+ */ + 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 + * processDictionaryListEvent, removes listener, checks flag + * listenerCalled and checks returned value.

+ * Has OK status if returned value is true and value of flag + * listenerCalled is true.

+ */ + 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 + * processDictionaryListEvent, checks flag + * listenerCalled and checks returned value.

+ * Has OK status if returned value is false and value of flag + * listenerCalled is false.

+ */ + 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.

+ * Has OK status if number of dictionaries after method call is + * greater than number of dictionaries before method call.

+ */ + 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.

+ * Has OK status if number of dictionaries before method call is + * less than number of dictionaries after method call.

+ */ + 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.

+ * Has OK status if returned value isn't null.

+ */ + public void _getDictionaryByName() { + XDictionary getting = oObj.getDictionaryByName("NegativDic"); + tRes.tested("getDictionaryByName()", getting != null ); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value isn't null.

+ */ + 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 + * processDictionaryListEvent, ends collect events, + * removes the listener and checks the flag listenerCalled .

+ * Has OK status if value of the flag is true.

+ */ + 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.

+ * Has OK status if method + * addDictionaryListEventListener() was completed + * successfully.

+ * The following method tests are to be completed successfully before : + *

+ */ + public void _flushEvents() { + requiredMethod("addDictionaryListEventListener()"); + // if listener adding worked, flushEvents was already used and worked + tRes.tested("flushEvents()",true); + } + + /** + * Test does nothing.

+ * Has OK status if method + * beginCollectEvents() was completed successfully.

+ * The following method tests are to be completed successfully before : + *

+ */ + 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 com.sun.star.linguistic2.XHyphenator +* interface methods: +*

+* @see com.sun.star.linguistic2.XHyphenator +*/ +public class _XHyphenator extends MultiMethodTest { + + public XHyphenator oObj = null; + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value isn't null.

+ */ + 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.

+ * Has OK status if returned value isn't null.

+ */ + 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.

+ * Has OK status if returned value isn't null.

+ */ + 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 com.sun.star.linguistic2.XLinguServiceEventBroadcaster +* interface methods: +*

+* @see com.sun.star.linguistic2.XLinguServiceEventBroadcaster +*/ +public class _XLinguServiceEventBroadcaster extends MultiMethodTest { + + public XLinguServiceEventBroadcaster oObj = null; + + /** + * Class implements interface XLinguServiceEventListener + * for test method addLinguServiceEventListener. + * @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.

+ * Has OK status if returned value is true.

+ */ + public void _addLinguServiceEventListener() { + boolean res = true; + + res = oObj.addLinguServiceEventListener(listener); + + tRes.tested("addLinguServiceEventListener()",res); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value is true.

+ */ + 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 com.sun.star.linguistic2.XLinguServiceManager +* interface methods: +*

+*@see com.sun.star.linguistic2.XLinguServiceManager +*/ +public class _XLinguServiceManager extends MultiMethodTest { + + public XLinguServiceManager oObj = null; + + /** + * Class implements interface XLinguServiceEventListener + * for test method addLinguServiceManagerListener. + * @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.

+ * Has OK status if returned value isn't null.

+ */ + public void _getSpellChecker() { + XSpellChecker SC = oObj.getSpellChecker(); + tRes.tested("getSpellChecker()", SC != null); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value isn't null.

+ */ + public void _getHyphenator() { + XHyphenator HN = oObj.getHyphenator(); + tRes.tested("getHyphenator()", HN != null); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value isn't null.

+ */ + public void _getThesaurus() { + XThesaurus TS = oObj.getThesaurus(); + tRes.tested("getThesaurus()", TS != null); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value is equal to true.

+ */ + public void _addLinguServiceManagerListener() { + boolean res = oObj.addLinguServiceManagerListener(listener); + tRes.tested("addLinguServiceManagerListener()", res); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if returned value is equal to true.

+ */ + public void _removeLinguServiceManagerListener() { + boolean res = oObj.removeLinguServiceManagerListener(listener); + tRes.tested("removeLinguServiceManagerListener()",res); + } + + /** + * Test calls the method and checks returned value.

+ * Has OK status if length of returned array is + * greater than zero.

+ */ + 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.

+ * Has OK status if length of returned array is + * greater than zero.

+ */ + 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 getConfiguredServices() and all services + * restored finally.

+ * Has OK status if length of obtained service list equal to zero. + *

The following method tests are to be completed successfully before : + *

+ */ + 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 com.sun.star.linguistic2.XSearchableDictionaryList +* interface methods: +*

+* @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.

+ * Has OK status if returned values are not null.

+ */ + 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 com.sun.star.linguistic2.XSpellChecker +* interface methods: +*

+* @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.

+ * Has OK 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.

+ */ + 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.

+ * Has OK status if at least one spell alternative exists + * and no exceptions were thrown.

+ */ + 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 com.sun.star.linguistic2.XSupportedLocales +* interface methods: +*

+* @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.

+ * Has OK status if length of returned array isn't zero.

+ */ + 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.

+ * Has OK status if all returned values for supported languages + * are equal to true and if returned value for unsupported language is equal + * to false.

+ * The following method tests are to be completed successfully before : + *

+ */ + 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 com.sun.star.linguistic2.XThesaurus +* interface methods: +*

+* @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.

+ * Has OK status if returned array is not empty + * and no exceptions were thrown.

+ */ + 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 + + -- cgit v1.2.3