2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc
.linguistic2
;
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.lang
.EventObject
;
24 import com
.sun
.star
.lang
.Locale
;
25 import com
.sun
.star
.linguistic2
.LinguServiceEvent
;
26 import com
.sun
.star
.linguistic2
.XHyphenator
;
27 import com
.sun
.star
.linguistic2
.XLinguServiceEventListener
;
28 import com
.sun
.star
.linguistic2
.XLinguServiceManager
;
29 import com
.sun
.star
.linguistic2
.XSpellChecker
;
30 import com
.sun
.star
.linguistic2
.XThesaurus
;
33 *Testing <code>com.sun.star.linguistic2.XLinguServiceManager</code>
36 * <li><code>getSpellChecker()</code></li>
37 * <li><code>getHyphenator()</code></li>
38 * <li><code>getThesaurus()</code></li>
39 * <li><code>addLinguServiceManagerListener()</code></li>
40 * <li><code>removeLinguServiceManagerListener()</code></li>
41 * <li><code>getAvailableServices()</code></li>
42 * <li><code>setConfiguredServices()</code></li>
43 * <li><code>getConfiguredServices()</code></li>
45 *@see com.sun.star.linguistic2.XLinguServiceManager
47 public class _XLinguServiceManager
extends MultiMethodTest
{
49 public XLinguServiceManager oObj
= null;
50 boolean listenerCalled
= false;
53 * Class implements interface <code>XLinguServiceEventListener</code>
54 * for test method <code>addLinguServiceManagerListener</code>.
55 * @see com.sun.star.linguistic2.XLinguServiceEventListener
57 public class MyLinguServiceEventListener
implements
58 XLinguServiceEventListener
{
59 public void disposing ( EventObject oEvent
) {
60 log
.println("Listener has been disposed");
62 public void processLinguServiceEvent(LinguServiceEvent aServiceEvent
) {
63 listenerCalled
= true;
64 log
.println("Listener called");
68 XLinguServiceEventListener listener
= new MyLinguServiceEventListener();
71 * Test calls the method and checks returned value. <p>
72 * Has <b> OK </b> status if returned value isn't null. <p>
74 public void _getSpellChecker() {
75 XSpellChecker SC
= oObj
.getSpellChecker();
76 tRes
.tested("getSpellChecker()", SC
!= null);
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 _getHyphenator() {
84 XHyphenator HN
= oObj
.getHyphenator();
85 tRes
.tested("getHyphenator()", HN
!= 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 _getThesaurus() {
93 XThesaurus TS
= oObj
.getThesaurus();
94 tRes
.tested("getThesaurus()", TS
!= null);
98 * Test calls the method and checks returned value. <p>
99 * Has <b> OK </b> status if returned value is equal to true. <p>
101 public void _addLinguServiceManagerListener() {
102 boolean res
= oObj
.addLinguServiceManagerListener(listener
);
103 tRes
.tested("addLinguServiceManagerListener()", res
);
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 _removeLinguServiceManagerListener() {
111 boolean res
= oObj
.removeLinguServiceManagerListener(listener
);
112 tRes
.tested("removeLinguServiceManagerListener()",res
);
116 * Test calls the method and checks returned value. <p>
117 * Has <b> OK </b> status if length of returned array is
118 * greater than zero.<p>
120 public void _getAvailableServices() {
121 String
[] services
= oObj
.getAvailableServices(
122 "com.sun.star.linguistic2.Hyphenator",
123 new Locale("en", "US", "") );
124 tRes
.tested("getAvailableServices()", services
.length
> 0);
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 _getConfiguredServices() {
133 String
[] services
= oObj
.getConfiguredServices(
134 "com.sun.star.linguistic2.Hyphenator",
135 new Locale("en", "US", "") );
136 tRes
.tested("getConfiguredServices()", services
.length
> 0);
140 * Test sets empty list of service, checks value returned
141 * by method <code>getConfiguredServices()</code> and all services
142 * restored finally. <p>
143 * Has <b> OK </b> status if length of obtained service list equal to zero.
144 * <p>The following method tests are to be completed successfully before :
146 * <li> <code> getConfiguredServices() </code></li>
149 public void _setConfiguredServices() {
150 requiredMethod("getConfiguredServices()");
152 String
[] services
= oObj
.getConfiguredServices(
153 "com.sun.star.linguistic2.Hyphenator",new Locale("en","US",""));
155 String
[] empty
= new String
[0];
156 oObj
.setConfiguredServices(
157 "com.sun.star.linguistic2.Hyphenator",
158 new Locale("en", "US", ""),
161 String
[] get
= oObj
.getConfiguredServices(
162 "com.sun.star.linguistic2.Hyphenator", new Locale("en","US",""));
164 boolean res
= (get
.length
== 0);
166 oObj
.setConfiguredServices(
167 "com.sun.star.linguistic2.Hyphenator",
168 new Locale("en", "US", ""),
171 tRes
.tested("setConfiguredServices()", res
);
174 } // finish class _XLinguServiceManager