1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.i18n; 25 26 import lib.MultiMethodTest; 27 28 import com.sun.star.i18n.XIndexEntrySupplier; 29 import com.sun.star.lang.Locale; 30 31 /** 32 * Testing <code>com.sun.star.i18n.XIndexEntrySupplier</code> 33 * interface methods: 34 * <ul> 35 * <li><code> getIndexCharacter() </code></li> 36 * <li><code> getIndexFollowPageWord() </code></li> 37 * </ul><p> 38 * Test is <b> NOT </b> multithread compilant. <p> 39 * @see com.sun.star.i18n.XIndexEntrySupplier 40 */ 41 public class _XIndexEntrySupplier extends MultiMethodTest { 42 public XIndexEntrySupplier oObj = null; 43 public String[] languages = new String[]{"de","en","es","fr","ja","ko","zh"}; 44 public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","CN"}; 45 public String[] onePage = new String[]{"f.","p."," s."," sv","p.","",""}; 46 public String[] morePages = new String[]{"ff.","pp."," ss."," sv","pp.","",""}; 47 48 /** 49 * Test calls the method, then result is checked. <p> 50 * Has <b> OK </b> status if the method returns right index for several 51 * locales and word. 52 */ _getIndexCharacter()53 public void _getIndexCharacter() { 54 boolean res = true; 55 log.println("getIndexCharacter('chapter', getLocale(i), '')"); 56 for (int i=0; i<7; i++) { 57 log.print("getIndexCharacter('chapter', " + countries[i] + ") :"); 58 String get = oObj.getIndexCharacter("chapter", getLocale(i), ""); 59 log.println(get); 60 res &= get.equals("C"); 61 } 62 tRes.tested("getIndexCharacter()", res); 63 } 64 65 /** 66 * Test calls the method with two different parameters: for one page and 67 * for several pages, after every call result is checked. <p> 68 * Has <b> OK </b> status if method returns right index for several locales. 69 */ _getIndexFollowPageWord()70 public void _getIndexFollowPageWord() { 71 boolean res = true; 72 73 for (int i=0; i<7; i++) { 74 String get = oObj.getIndexFollowPageWord(true, getLocale(i)); 75 if (! get.equals(morePages[i]) ) { 76 log.println("Language: " + languages[i]); 77 log.println("Getting: #" + get + "#"); 78 log.println("Expected: #" + morePages[i] + "#"); 79 } 80 res &= get.equals(morePages[i]); 81 get = oObj.getIndexFollowPageWord(false,getLocale(i)); 82 if (! get.equals(onePage[i]) ) { 83 log.println("Language: " + languages[i]); 84 log.println("Getting: #" + get + "#"); 85 log.println("Expected: #" + onePage[i] + "#"); 86 } 87 res &= get.equals(onePage[i]); 88 } 89 tRes.tested("getIndexFollowPageWord()", res); 90 } 91 92 /** 93 * Method returns locale for a given language and country. 94 * @param k index of needed locale. 95 * @return Locale by the index from arrays defined above 96 */ getLocale(int k)97 public Locale getLocale(int k) { 98 return new Locale(languages[k], countries[k], ""); 99 } 100 101 102 } // end XIndexEntrySupplier 103 104