Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / i18n / _XNumberFormatCode.java
blob4c342310a4b669184fa8e2337f14f9eddec1d1bb
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.KNumberFormatType;
24 import com.sun.star.i18n.KNumberFormatUsage;
25 import com.sun.star.i18n.NumberFormatCode;
26 import com.sun.star.i18n.NumberFormatIndex;
27 import com.sun.star.i18n.XNumberFormatCode;
28 import com.sun.star.lang.Locale;
30 /**
31 * Testing <code>com.sun.star.i18n.XNumberFormatCode</code>
32 * interface methods:
33 * <ul>
34 * <li><code> getDefault() </code></li>
35 * <li><code> getFormatCode() </code></li>
36 * <li><code> getAllFormatCode() </code></li>
37 * <li><code> getAllFormatCodes() </code></li>
38 * </ul><p>
39 * Test is <b> NOT </b> multithread compliant. <p>
40 * @see com.sun.star.i18n.XNumberFormatCode
42 public class _XNumberFormatCode extends MultiMethodTest {
43 public XNumberFormatCode oObj = null;
44 public String[] languages = new String[]
45 {"de","en","es","fr","ko","ko","zh"};
46 public String[] countries = new String[]
47 {"DE","US","ES","FR","KR","KR","CN"};
49 /**
50 * Test calls the method twice with two different format types as
51 * parameters for each locale. Result is checked after every call.<p>
52 * Has <b> OK </b> status if both times returned structure's field 'Code'
53 * does not equal to empty string.
55 public void _getDefault() {
56 boolean res = true;
57 NumberFormatCode nfc = null;
59 for (int i=0;i<7;i++) {
60 nfc = oObj.getDefault(KNumberFormatType.SHORT,
61 KNumberFormatUsage.DATE, getLocale(i));
62 String str = nfc.Code;
63 if (str.equals("")) {
64 log.println("'NumberFormat.code.equals(\"\") = true' for"
65 + " language: " + languages[i]);
66 log.println("Usage: oObj.getDefault(KNumberFormatType.SHORT,"
67 + " KNumberFormatUsage.DATE,new Locale(" + languages[i]
68 + "," + countries[i] + ",\"\");");
70 res &= !str.equals("");
72 nfc = oObj.getDefault(KNumberFormatType.LONG,
73 KNumberFormatUsage.DATE,getLocale(i));
74 str = nfc.Code;
75 if (str.equals("")) {
76 log.println("'NumberFormat.code.equals(\"\") = true' for "
77 + "language: " + languages[i]);
78 log.println("Usage: oObj.getDefault(KNumberFormatType.LONG,"
79 + " KNumberFormatUsage.DATE,new Locale(" + languages[i]
80 + "," + countries[i] + ",\"\");");
82 res &= ( ! str.equals("") );
84 tRes.tested("getDefault()", res);
87 /**
88 * Test calls the method twice for each locale with two different arguments.
89 * After every call result is checked.<p>
90 * Has <b> OK </b> status if both times returned structure's field 'Code'
91 * does not equal to a empty string.
93 public void _getFormatCode() {
94 boolean res = true;
95 NumberFormatCode nfc = null;
97 for (int i=0;i<7;i++) {
98 nfc = oObj.getFormatCode
99 (NumberFormatIndex.DATE_SYSTEM_SHORT,getLocale(i));
100 res &= ( ! nfc.Code.equals("") );
101 nfc = oObj.getFormatCode
102 (NumberFormatIndex.DATE_SYSTEM_LONG,getLocale(i));
103 res &= ( ! nfc.Code.equals("") );
105 tRes.tested("getFormatCode()", res);
109 * Test calls the method twice with two different arguments for each locale.
110 * After every call result is checked.<p>
111 * Has <b> OK </b> status if both times returned array's length does not
112 * equal to zero.
114 public void _getAllFormatCode() {
115 boolean res = true;
116 NumberFormatCode[] nfc = null;
118 for (int i=0;i<7;i++) {
119 nfc = oObj.getAllFormatCode(KNumberFormatUsage.DATE, getLocale(i));
120 res &= ( nfc.length != 0 );
121 nfc = oObj.getAllFormatCode(KNumberFormatUsage.TIME, getLocale(i));
122 res &= ( nfc.length != 0 );
124 tRes.tested("getAllFormatCode()", res);
128 * Test calls the method for each locale. <p>
129 * Has <b> OK </b> status if returned array's length does not equal to zero.
131 public void _getAllFormatCodes() {
132 boolean res = true;
133 NumberFormatCode[] nfc = null;
135 for (int i=0;i<7;i++) {
136 nfc = oObj.getAllFormatCodes(getLocale(i));
137 res &= ( nfc.length != 0 );
139 tRes.tested("getAllFormatCodes()", res);
143 * Method returns locale for a given language and country.
144 * @param k index of needed locale.
145 * @return Locale by the index from arrays defined above
147 public Locale getLocale(int k) {
148 return new Locale(languages[k], countries[k], "");
153 } // end XNumberFormatCode