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: _XIndexEntrySupplier.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 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.i18n
.XIndexEntrySupplier
;
36 import com
.sun
.star
.lang
.Locale
;
39 * Testing <code>com.sun.star.i18n.XIndexEntrySupplier</code>
42 * <li><code> getIndexCharacter() </code></li>
43 * <li><code> getIndexFollowPageWord() </code></li>
45 * Test is <b> NOT </b> multithread compilant. <p>
46 * @see com.sun.star.i18n.XIndexEntrySupplier
48 public class _XIndexEntrySupplier
extends MultiMethodTest
{
49 public XIndexEntrySupplier oObj
= null;
50 public String
[] languages
= new String
[]{"de","en","es","fr","ja","ko","zh"};
51 public String
[] countries
= new String
[]{"DE","US","ES","FR","JP","KR","CN"};
52 public String
[] onePage
= new String
[]{"f.","p."," s."," sv","p.","",""};
53 public String
[] morePages
= new String
[]{"ff.","pp."," ss."," sv","pp.","",""};
56 * Test calls the method, then result is checked. <p>
57 * Has <b> OK </b> status if the method returns right index for several
60 public void _getIndexCharacter() {
62 log
.println("getIndexCharacter('chapter', getLocale(i), '')");
63 for (int i
=0; i
<7; i
++) {
64 log
.print("getIndexCharacter('chapter', " + countries
[i
] + ") :");
65 String get
= oObj
.getIndexCharacter("chapter", getLocale(i
), "");
67 res
&= get
.equals("C");
69 tRes
.tested("getIndexCharacter()", res
);
73 * Test calls the method with two different parameters: for one page and
74 * for several pages, after every call result is checked. <p>
75 * Has <b> OK </b> status if method returns right index for several locales.
77 public void _getIndexFollowPageWord() {
80 for (int i
=0; i
<7; i
++) {
81 String get
= oObj
.getIndexFollowPageWord(true, getLocale(i
));
82 if (! get
.equals(morePages
[i
]) ) {
83 log
.println("Language: " + languages
[i
]);
84 log
.println("Getting: #" + get
+ "#");
85 log
.println("Expected: #" + morePages
[i
] + "#");
87 res
&= get
.equals(morePages
[i
]);
88 get
= oObj
.getIndexFollowPageWord(false,getLocale(i
));
89 if (! get
.equals(onePage
[i
]) ) {
90 log
.println("Language: " + languages
[i
]);
91 log
.println("Getting: #" + get
+ "#");
92 log
.println("Expected: #" + onePage
[i
] + "#");
94 res
&= get
.equals(onePage
[i
]);
96 tRes
.tested("getIndexFollowPageWord()", res
);
100 * Method returns locale for a given language and country.
101 * @param localeIndex index of needed locale.
102 * @return Locale by the index from arrays defined above
104 public Locale
getLocale(int k
) {
105 return new Locale(languages
[k
], countries
[k
], "");
109 } // end XIndexEntrySupplier