1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc
.linguistic2
;
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.lang
.EventObject
;
33 import com
.sun
.star
.lang
.Locale
;
34 import com
.sun
.star
.linguistic2
.LinguServiceEvent
;
35 import com
.sun
.star
.linguistic2
.XHyphenator
;
36 import com
.sun
.star
.linguistic2
.XLinguServiceEventListener
;
37 import com
.sun
.star
.linguistic2
.XLinguServiceManager
;
38 import com
.sun
.star
.linguistic2
.XSpellChecker
;
39 import com
.sun
.star
.linguistic2
.XThesaurus
;
42 *Testing <code>com.sun.star.linguistic2.XLinguServiceManager</code>
45 * <li><code>getSpellChecker()</code></li>
46 * <li><code>getHyphenator()</code></li>
47 * <li><code>getThesaurus()</code></li>
48 * <li><code>addLinguServiceManagerListener()</code></li>
49 * <li><code>removeLinguServiceManagerListener()</code></li>
50 * <li><code>getAvailableServices()</code></li>
51 * <li><code>setConfiguredServices()</code></li>
52 * <li><code>getConfiguredServices()</code></li>
54 *@see com.sun.star.linguistic2.XLinguServiceManager
56 public class _XLinguServiceManager
extends MultiMethodTest
{
58 public XLinguServiceManager oObj
= null;
59 boolean listenerCalled
= false;
62 * Class implements interface <code>XLinguServiceEventListener</code>
63 * for test method <code>addLinguServiceManagerListener</code>.
64 * @see com.sun.star.linguistic2.XLinguServiceEventListener
66 public class MyLinguServiceEventListener
implements
67 XLinguServiceEventListener
{
68 public void disposing ( EventObject oEvent
) {
69 log
.println("Listener has been disposed");
71 public void processLinguServiceEvent(LinguServiceEvent aServiceEvent
) {
72 listenerCalled
= true;
73 log
.println("Listener called");
77 XLinguServiceEventListener listener
= new MyLinguServiceEventListener();
80 * Test calls the method and checks returned value. <p>
81 * Has <b> OK </b> status if returned value isn't null. <p>
83 public void _getSpellChecker() {
84 XSpellChecker SC
= oObj
.getSpellChecker();
85 tRes
.tested("getSpellChecker()", SC
!= null);
89 * Test calls the method and checks returned value. <p>
90 * Has <b> OK </b> status if returned value isn't null. <p>
92 public void _getHyphenator() {
93 XHyphenator HN
= oObj
.getHyphenator();
94 tRes
.tested("getHyphenator()", HN
!= null);
98 * Test calls the method and checks returned value. <p>
99 * Has <b> OK </b> status if returned value isn't null. <p>
101 public void _getThesaurus() {
102 XThesaurus TS
= oObj
.getThesaurus();
103 tRes
.tested("getThesaurus()", TS
!= null);
107 * Test calls the method and checks returned value. <p>
108 * Has <b> OK </b> status if returned value is equal to true. <p>
110 public void _addLinguServiceManagerListener() {
111 boolean res
= oObj
.addLinguServiceManagerListener(listener
);
112 tRes
.tested("addLinguServiceManagerListener()", res
);
116 * Test calls the method and checks returned value. <p>
117 * Has <b> OK </b> status if returned value is equal to true. <p>
119 public void _removeLinguServiceManagerListener() {
120 boolean res
= oObj
.removeLinguServiceManagerListener(listener
);
121 tRes
.tested("removeLinguServiceManagerListener()",res
);
125 * Test calls the method and checks returned value. <p>
126 * Has <b> OK </b> status if length of returned array is
127 * greater than zero.<p>
129 public void _getAvailableServices() {
130 String
[] services
= oObj
.getAvailableServices(
131 "com.sun.star.linguistic2.Hyphenator",
132 new Locale("en", "US", "") );
133 tRes
.tested("getAvailableServices()", services
.length
> 0);
137 * Test calls the method and checks returned value. <p>
138 * Has <b> OK </b> status if length of returned array is
139 * greater than zero.<p>
141 public void _getConfiguredServices() {
142 String
[] services
= oObj
.getConfiguredServices(
143 "com.sun.star.linguistic2.Hyphenator",
144 new Locale("en", "US", "") );
145 tRes
.tested("getConfiguredServices()", services
.length
> 0);
149 * Test sets empty list of service, checks value returned
150 * by method <code>getConfiguredServices()</code> and all services
151 * restored finally. <p>
152 * Has <b> OK </b> status if length of obtained service list equal to zero.
153 * <p>The following method tests are to be completed successfully before :
155 * <li> <code> getConfiguredServices() </code></li>
158 public void _setConfiguredServices() {
159 requiredMethod("getConfiguredServices()");
161 String
[] services
= oObj
.getConfiguredServices(
162 "com.sun.star.linguistic2.Hyphenator",new Locale("en","US",""));
164 String
[] empty
= new String
[0];
165 oObj
.setConfiguredServices(
166 "com.sun.star.linguistic2.Hyphenator",
167 new Locale("en", "US", ""),
170 String
[] get
= oObj
.getConfiguredServices(
171 "com.sun.star.linguistic2.Hyphenator", new Locale("en","US",""));
173 boolean res
= (get
.length
== 0);
175 oObj
.setConfiguredServices(
176 "com.sun.star.linguistic2.Hyphenator",
177 new Locale("en", "US", ""),
180 tRes
.tested("setConfiguredServices()", res
);
183 } // finish class _XLinguServiceManager