merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / i18n / _XIndexEntrySupplier.java
blobb5e7879d0947c0b55be250e9216397ec6ce43711
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XIndexEntrySupplier.java,v $
10 * $Revision: 1.5 $
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.i18n;
33 import lib.MultiMethodTest;
35 import com.sun.star.i18n.XIndexEntrySupplier;
36 import com.sun.star.lang.Locale;
38 /**
39 * Testing <code>com.sun.star.i18n.XIndexEntrySupplier</code>
40 * interface methods:
41 * <ul>
42 * <li><code> getIndexCharacter() </code></li>
43 * <li><code> getIndexFollowPageWord() </code></li>
44 * </ul><p>
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.","",""};
55 /**
56 * Test calls the method, then result is checked. <p>
57 * Has <b> OK </b> status if the method returns right index for several
58 * locales and word.
60 public void _getIndexCharacter() {
61 boolean res = true;
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), "");
66 log.println(get);
67 res &= get.equals("C");
69 tRes.tested("getIndexCharacter()", res);
72 /**
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() {
78 boolean res = true;
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);
99 /**
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