/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package ifc.i18n;
import lib.MultiMethodTest;
import com.sun.star.i18n.Calendar;
import com.sun.star.i18n.Currency;
import com.sun.star.i18n.ForbiddenCharacters;
import com.sun.star.i18n.FormatElement;
import com.sun.star.i18n.Implementation;
import com.sun.star.i18n.LanguageCountryInfo;
import com.sun.star.i18n.LocaleDataItem;
import com.sun.star.i18n.XLocaleData;
import com.sun.star.lang.Locale;
/**
* Testing com.sun.star.i18n.XLocaleData
* interface methods:
*
getLanguageCountryInfo()
getLocaleItem()
getAllCalendars()
getAllCurrencies()
getAllFormats()
getCollatorImplementations()
getSearchOptions()
getCollationOptions()
getTransliterations()
getForbiddenCharacters()
getReservedWord()
getAllInstalledLocaleNames()
* Test is NOT multithread compliant.
* @see com.sun.star.i18n.XLocaleData */ public class _XLocaleData extends MultiMethodTest { public XLocaleData oObj = null; public String[] languages = new String[]{"de","en","es","fr","ja","ko","ko"}; public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","KR"}; /** * Test calls the method, then result is checked.
* Has OK status if structure, returned by the method includes * correct values of fields 'Language' and 'Country' for all given locales. */ public void _getLanguageCountryInfo() { boolean res = true; LanguageCountryInfo lci = null; for (int i=0;i<7;i++) { lci = oObj.getLanguageCountryInfo(getLocale(i)); /* For debug purposes log.println("Using: language="+languages[i]+" ; country="+countries[i]); log.println("Getting: "); log.println("\t Language="+lci.Language); log.println("\t LanguageDefaultName="+lci.LanguageDefaultName); log.println("\t Country="+lci.Country); log.println("\t CountryDefaultName="+lci.CountryDefaultName); boolean lang = ( lci.Language.equals(languages[i]) ); if (!lang) log.println("getting false for language: "+lci.LanguageDefaultName); lang = ( lci.Country.equals(countries[i]) ); if (!lang) log.println("getting false for country: "+lci.CountryDefaultName); */ res &= ( ( lci.Language.equals(languages[i]) ) && ( lci.Country.equals(countries[i]) ) ); } tRes.tested("getLanguageCountryInfo()",res); } /** * Test calls the method, then result is checked.
* Has OK status if structure, returned by the method consists of * non empty strings for all given locales. */ public void _getLocaleItem() { boolean res = true; LocaleDataItem ldi = null; for (int i=0;i<7;i++) { ldi = oObj.getLocaleItem(getLocale(i)); boolean locRes = true ; locRes &= (! ldi.dateSeparator.equals("")); locRes &= (! ldi.decimalSeparator.equals("")); locRes &= (! ldi.doubleQuotationEnd.equals("")); locRes &= (! ldi.doubleQuotationStart.equals("")); locRes &= (! ldi.listSeparator.equals("")); locRes &= (! ldi.LongDateDayOfWeekSeparator.equals("")); locRes &= (! ldi.LongDateDaySeparator.equals("")); locRes &= (! ldi.LongDateMonthSeparator.equals("")); locRes &= (! ldi.LongDateYearSeparator.equals("")); locRes &= (! ldi.measurementSystem.equals("")); locRes &= (! ldi.quotationEnd.equals("")); locRes &= (! ldi.quotationStart.equals("")); locRes &= (! ldi.thousandSeparator.equals("")); locRes &= (! ldi.time100SecSeparator.equals("")); locRes &= (! ldi.timeAM.equals("")); locRes &= (! ldi.timePM.equals("")); locRes &= (! ldi.timeSeparator.equals("")); locRes &= (! ldi.unoID.equals("")); if (!locRes) { /* for debugging purposes log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]); log.println("Getting: "); log.println("\t DateSeparator="+ldi.dateSeparator); log.println("\t decimalSeparator="+ldi.decimalSeparator); log.println("\t doubleQuotationEnd="+ldi.doubleQuotationEnd); log.println("\t doubleQuotationStart="+ldi.doubleQuotationStart); log.println("\t listSeparator="+ldi.listSeparator); log.println("\t LongDateDayOfWeekSeparator="+ldi.LongDateDayOfWeekSeparator+"end"); log.println("\t LongDateDaySeparator="+ldi.LongDateDaySeparator+"end"); log.println("\t LongDateMonthSeparator="+ldi.LongDateMonthSeparator+"end"); log.println("\t LongDateYearSeparator="+ldi.LongDateYearSeparator+"end"); log.println("\t measurementSystem="+ldi.measurementSystem); log.println("\t quotationEnd="+ldi.quotationEnd); log.println("\t quotationStart="+ldi.quotationStart); log.println("\t thousandSeparator="+ldi.thousandSeparator); log.println("\t time100SecSeparator="+ldi.time100SecSeparator); log.println("\t timeAM="+ldi.timeAM); log.println("\t timePM="+ldi.timePM); log.println("\t timeSeparator="+ldi.timeSeparator); log.println("\t unoID="+ldi.unoID); */ } } tRes.tested("getLocaleItem()",res); } /** * Test calls the method for several locales; result is checked * after each call.
* Has OK status if all elements of the returned sequence are
* correct for all given locales. (boolean method goodCalendar() with a
* calendar as an argument returns true)
*/
public void _getAllCalendars() {
boolean res = true;
boolean printit = false;
for (int i=0;i<7;i++) {
Calendar[] calendar = oObj.getAllCalendars(getLocale(i));
for (int j=0;j
* Has OK status if all strings, returned by the method are not
* empty for all given locales.
*/
public void _getReservedWord() {
boolean res = true;
boolean printit = false;
for (int i=0;i<7;i++) {
String[] str = oObj.getReservedWord(getLocale(i));
for (int j=0;j