1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XLinguServiceManager.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc
.linguistic2
;
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.lang
.EventObject
;
36 import com
.sun
.star
.lang
.Locale
;
37 import com
.sun
.star
.linguistic2
.LinguServiceEvent
;
38 import com
.sun
.star
.linguistic2
.XHyphenator
;
39 import com
.sun
.star
.linguistic2
.XLinguServiceEventListener
;
40 import com
.sun
.star
.linguistic2
.XLinguServiceManager
;
41 import com
.sun
.star
.linguistic2
.XSpellChecker
;
42 import com
.sun
.star
.linguistic2
.XThesaurus
;
45 *Testing <code>com.sun.star.linguistic2.XLinguServiceManager</code>
48 * <li><code>getSpellChecker()</code></li>
49 * <li><code>getHyphenator()</code></li>
50 * <li><code>getThesaurus()</code></li>
51 * <li><code>addLinguServiceManagerListener()</code></li>
52 * <li><code>removeLinguServiceManagerListener()</code></li>
53 * <li><code>getAvailableServices()</code></li>
54 * <li><code>setConfiguredServices()</code></li>
55 * <li><code>getConfiguredServices()</code></li>
57 *@see com.sun.star.linguistic2.XLinguServiceManager
59 public class _XLinguServiceManager
extends MultiMethodTest
{
61 public XLinguServiceManager oObj
= null;
62 boolean listenerCalled
= false;
65 * Class implements interface <code>XLinguServiceEventListener</code>
66 * for test method <code>addLinguServiceManagerListener</code>.
67 * @see com.sun.star.linguistic2.XLinguServiceEventListener
69 public class MyLinguServiceEventListener
implements
70 XLinguServiceEventListener
{
71 public void disposing ( EventObject oEvent
) {
72 log
.println("Listener has been disposed");
74 public void processLinguServiceEvent(LinguServiceEvent aServiceEvent
) {
75 listenerCalled
= true;
76 log
.println("Listener called");
80 XLinguServiceEventListener listener
= new MyLinguServiceEventListener();
83 * Test calls the method and checks returned value. <p>
84 * Has <b> OK </b> status if returned value isn't null. <p>
86 public void _getSpellChecker() {
87 XSpellChecker SC
= oObj
.getSpellChecker();
88 tRes
.tested("getSpellChecker()", SC
!= null);
92 * Test calls the method and checks returned value. <p>
93 * Has <b> OK </b> status if returned value isn't null. <p>
95 public void _getHyphenator() {
96 XHyphenator HN
= oObj
.getHyphenator();
97 tRes
.tested("getHyphenator()", HN
!= null);
101 * Test calls the method and checks returned value. <p>
102 * Has <b> OK </b> status if returned value isn't null. <p>
104 public void _getThesaurus() {
105 XThesaurus TS
= oObj
.getThesaurus();
106 tRes
.tested("getThesaurus()", TS
!= null);
110 * Test calls the method and checks returned value. <p>
111 * Has <b> OK </b> status if returned value is equal to true. <p>
113 public void _addLinguServiceManagerListener() {
114 boolean res
= oObj
.addLinguServiceManagerListener(listener
);
115 tRes
.tested("addLinguServiceManagerListener()", res
);
119 * Test calls the method and checks returned value. <p>
120 * Has <b> OK </b> status if returned value is equal to true. <p>
122 public void _removeLinguServiceManagerListener() {
123 boolean res
= oObj
.removeLinguServiceManagerListener(listener
);
124 tRes
.tested("removeLinguServiceManagerListener()",res
);
128 * Test calls the method and checks returned value. <p>
129 * Has <b> OK </b> status if length of returned array is
130 * greater than zero.<p>
132 public void _getAvailableServices() {
133 String
[] services
= oObj
.getAvailableServices(
134 "com.sun.star.linguistic2.Hyphenator",
135 new Locale("en", "US", "") );
136 tRes
.tested("getAvailableServices()", services
.length
> 0);
140 * Test calls the method and checks returned value. <p>
141 * Has <b> OK </b> status if length of returned array is
142 * greater than zero.<p>
144 public void _getConfiguredServices() {
145 String
[] services
= oObj
.getConfiguredServices(
146 "com.sun.star.linguistic2.Hyphenator",
147 new Locale("en", "US", "") );
148 tRes
.tested("getConfiguredServices()", services
.length
> 0);
152 * Test sets empty list of service, checks value returned
153 * by method <code>getConfiguredServices()</code> and all services
154 * restored finally. <p>
155 * Has <b> OK </b> status if length of obtained service list equal to zero.
156 * <p>The following method tests are to be completed successfully before :
158 * <li> <code> getConfiguredServices() </code></li>
161 public void _setConfiguredServices() {
162 requiredMethod("getConfiguredServices()");
164 String
[] services
= oObj
.getConfiguredServices(
165 "com.sun.star.linguistic2.Hyphenator",new Locale("en","US",""));
167 String
[] empty
= new String
[0];
168 oObj
.setConfiguredServices(
169 "com.sun.star.linguistic2.Hyphenator",
170 new Locale("en", "US", ""),
173 String
[] get
= oObj
.getConfiguredServices(
174 "com.sun.star.linguistic2.Hyphenator", new Locale("en","US",""));
176 boolean res
= (get
.length
== 0);
178 oObj
.setConfiguredServices(
179 "com.sun.star.linguistic2.Hyphenator",
180 new Locale("en", "US", ""),
183 tRes
.tested("setConfiguredServices()", res
);
186 } // finish class _XLinguServiceManager