Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / i18n / _XIndexEntrySupplier.java
blob31eac7bf64e96ee9d18a303b22a1e67a92fdc0c6
1 /*
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.i18n;
21 import lib.MultiMethodTest;
23 import com.sun.star.i18n.XIndexEntrySupplier;
24 import com.sun.star.lang.Locale;
26 /**
27 * Testing <code>com.sun.star.i18n.XIndexEntrySupplier</code>
28 * interface methods:
29 * <ul>
30 * <li><code> getIndexCharacter() </code></li>
31 * <li><code> getIndexFollowPageWord() </code></li>
32 * </ul><p>
33 * Test is <b> NOT </b> multithread compliant. <p>
34 * @see com.sun.star.i18n.XIndexEntrySupplier
36 public class _XIndexEntrySupplier extends MultiMethodTest {
37 public XIndexEntrySupplier oObj = null;
38 public String[] languages = new String[]{"de","en","es","fr","ja","ko","zh"};
39 public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","CN"};
40 public String[] onePage = new String[]{"f.","p."," s."," sv","p.","",""};
41 public String[] morePages = new String[]{"ff.","pp."," ss."," sv","pp.","",""};
43 /**
44 * Test calls the method, then result is checked. <p>
45 * Has <b> OK </b> status if the method returns right index for several
46 * locales and word.
48 public void _getIndexCharacter() {
49 boolean res = true;
50 log.println("getIndexCharacter('chapter', getLocale(i), '')");
51 for (int i=0; i<7; i++) {
52 log.print("getIndexCharacter('chapter', " + countries[i] + ") :");
53 String get = oObj.getIndexCharacter("chapter", getLocale(i), "");
54 log.println(get);
55 res &= get.equals("C");
57 tRes.tested("getIndexCharacter()", res);
60 /**
61 * Test calls the method with two different parameters: for one page and
62 * for several pages, after every call result is checked. <p>
63 * Has <b> OK </b> status if method returns right index for several locales.
65 public void _getIndexFollowPageWord() {
66 boolean res = true;
68 for (int i=0; i<7; i++) {
69 String get = oObj.getIndexFollowPageWord(true, getLocale(i));
70 if (! get.equals(morePages[i]) ) {
71 log.println("Language: " + languages[i]);
72 log.println("Getting: #" + get + "#");
73 log.println("Expected: #" + morePages[i] + "#");
75 res &= get.equals(morePages[i]);
76 get = oObj.getIndexFollowPageWord(false,getLocale(i));
77 if (! get.equals(onePage[i]) ) {
78 log.println("Language: " + languages[i]);
79 log.println("Getting: #" + get + "#");
80 log.println("Expected: #" + onePage[i] + "#");
82 res &= get.equals(onePage[i]);
84 tRes.tested("getIndexFollowPageWord()", res);
87 /**
88 * Method returns locale for a given language and country.
89 * @param k index of needed locale.
90 * @return Locale by the index from arrays defined above
92 public Locale getLocale(int k) {
93 return new Locale(languages[k], countries[k], "");
97 } // end XIndexEntrySupplier