1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.i18n; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.i18n.CalendarDisplayIndex; 29cdf0e10cSrcweir import com.sun.star.i18n.CalendarFieldIndex; 30cdf0e10cSrcweir import com.sun.star.i18n.CalendarItem; 31cdf0e10cSrcweir import com.sun.star.i18n.XCalendar; 32cdf0e10cSrcweir import com.sun.star.i18n.XLocaleData; 33cdf0e10cSrcweir import com.sun.star.lang.Locale; 34cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 35cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** 38cdf0e10cSrcweir * Testing <code>com.sun.star.i18n.XCalendar</code> 39cdf0e10cSrcweir * interface methods : 40cdf0e10cSrcweir * <ul> 41cdf0e10cSrcweir * <li><code> loadDefaultCalendar()</code></li> 42cdf0e10cSrcweir * <li><code> loadCalendar()</code></li> 43cdf0e10cSrcweir * <li><code> getLoadedCalendar()</code></li> 44cdf0e10cSrcweir * <li><code> getAllCalendars()</code></li> 45cdf0e10cSrcweir * <li><code> getUniqueID()</code></li> 46cdf0e10cSrcweir * <li><code> setDateTime()</code></li> 47cdf0e10cSrcweir * <li><code> getDateTime()</code></li> 48cdf0e10cSrcweir * <li><code> setValue()</code></li> 49cdf0e10cSrcweir * <li><code> getValue()</code></li> 50cdf0e10cSrcweir * <li><code> isValid()</code></li> 51cdf0e10cSrcweir * <li><code> addValue()</code></li> 52cdf0e10cSrcweir * <li><code> getFirstDayOfWeek()</code></li> 53cdf0e10cSrcweir * <li><code> setFirstDayOfWeek()</code></li> 54cdf0e10cSrcweir * <li><code> setMinimumNumberOfDaysForFirstWeek()</code></li> 55cdf0e10cSrcweir * <li><code> getMinimumNumberOfDaysForFirstWeek()</code></li> 56cdf0e10cSrcweir * <li><code> getNumberOfMonthsInYear()</code></li> 57cdf0e10cSrcweir * <li><code> getNumberOfDaysInWeek()</code></li> 58cdf0e10cSrcweir * <li><code> getMonths()</code></li> 59cdf0e10cSrcweir * <li><code> getDays()</code></li> 60cdf0e10cSrcweir * <li><code> getDisplayName()</code></li> 61cdf0e10cSrcweir * </ul> <p> 62cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 63cdf0e10cSrcweir * @see com.sun.star.i18n.XCalendar 64cdf0e10cSrcweir */ 65cdf0e10cSrcweir public class _XCalendar extends MultiMethodTest { 66cdf0e10cSrcweir private boolean debug = false; 67cdf0e10cSrcweir public XCalendar oObj = null; 68cdf0e10cSrcweir public String[][] calendars; 69cdf0e10cSrcweir public int[] count; 70cdf0e10cSrcweir public double newDTime = 1000.75; 71cdf0e10cSrcweir public short newValue = 2; 72cdf0e10cSrcweir public short firstDay = 2; 73cdf0e10cSrcweir public short mdfw = 3; 74cdf0e10cSrcweir double aOriginalDTime = 0; 75cdf0e10cSrcweir Locale[] installed_locales; 76cdf0e10cSrcweir before()77cdf0e10cSrcweir public void before() { 78cdf0e10cSrcweir XLocaleData locData = null; 79cdf0e10cSrcweir try { 80cdf0e10cSrcweir locData = (XLocaleData) UnoRuntime.queryInterface( 81cdf0e10cSrcweir XLocaleData.class, 82cdf0e10cSrcweir ((XMultiServiceFactory)tParam.getMSF()).createInstance( 83cdf0e10cSrcweir "com.sun.star.i18n.LocaleData")); 84cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 85cdf0e10cSrcweir 86cdf0e10cSrcweir } 87cdf0e10cSrcweir installed_locales = locData.getAllInstalledLocaleNames(); 88cdf0e10cSrcweir calendars = new String[installed_locales.length][]; 89cdf0e10cSrcweir count = new int[installed_locales.length]; 90cdf0e10cSrcweir oObj.loadDefaultCalendar(installed_locales[0]); 91cdf0e10cSrcweir aOriginalDTime = oObj.getDateTime(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir debug = tParam.getBool("DebugIsActive"); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir /** 97cdf0e10cSrcweir * Restore the changed time during the test to the original value of the 98cdf0e10cSrcweir * machine: has to be correct for the following interface tests. 99cdf0e10cSrcweir */ after()100cdf0e10cSrcweir public void after() { 101cdf0e10cSrcweir oObj.loadDefaultCalendar(installed_locales[0]); 102cdf0e10cSrcweir oObj.setDateTime(aOriginalDTime); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** 106cdf0e10cSrcweir * Loads default calendar for different locales. <p> 107cdf0e10cSrcweir * Has <b> OK </b> status if method loads calendar, that is 108cdf0e10cSrcweir * default for a given locale. 109cdf0e10cSrcweir */ _loadDefaultCalendar()110cdf0e10cSrcweir public void _loadDefaultCalendar() { 111cdf0e10cSrcweir boolean res = true; 112cdf0e10cSrcweir 113cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 114cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 115cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 116cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 117cdf0e10cSrcweir oObj.loadDefaultCalendar(installed_locales[i]); 118cdf0e10cSrcweir if (oObj.getLoadedCalendar().Default) { 119cdf0e10cSrcweir //log.println(lang + " ... OK"); 120cdf0e10cSrcweir } else { 121cdf0e10cSrcweir log.println(lang + " ... FAILED"); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir res &= oObj.getLoadedCalendar().Default; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir tRes.tested("loadDefaultCalendar()", res); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** 130cdf0e10cSrcweir * Tries to obtain calendars for a number of locales. <p> 131cdf0e10cSrcweir * Has <b> OK </b> status if the method returns more than zero calendars for 132cdf0e10cSrcweir * every locale. 133cdf0e10cSrcweir */ _getAllCalendars()134cdf0e10cSrcweir public void _getAllCalendars() { 135cdf0e10cSrcweir boolean res = true; 136cdf0e10cSrcweir 137cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 138cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 139cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 140cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 141cdf0e10cSrcweir calendars[i] = oObj.getAllCalendars(installed_locales[i]); 142cdf0e10cSrcweir count[i] = calendars[i].length-1; 143cdf0e10cSrcweir if (calendars[i].length > 0) { 144cdf0e10cSrcweir //log.println(lang + " ... OK"); 145cdf0e10cSrcweir } else { 146cdf0e10cSrcweir log.println(lang + " ... FAILED"); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir res &= (calendars[i].length > 0); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir tRes.tested("getAllCalendars()", res); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir /** 154cdf0e10cSrcweir * Loads calendars for a number of locales. <p> 155cdf0e10cSrcweir * Has <b> OK </b> status if loaded calendar names are equal to gotten 156cdf0e10cSrcweir * calendar names after loading.<p> 157cdf0e10cSrcweir * The following method tests are to be completed successfully before : 158cdf0e10cSrcweir * <ul> 159cdf0e10cSrcweir * <li> <code> getAllCalendars() </code> : gets all calendars for a given 160cdf0e10cSrcweir * locale </li> 161cdf0e10cSrcweir * </ul> 162cdf0e10cSrcweir */ _loadCalendar()163cdf0e10cSrcweir public void _loadCalendar() { 164cdf0e10cSrcweir boolean res = true; 165cdf0e10cSrcweir requiredMethod("getAllCalendars()"); 166cdf0e10cSrcweir 167cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 168cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 169cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 170cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 171cdf0e10cSrcweir oObj.loadCalendar(calendars[i][0], installed_locales[i]); 172cdf0e10cSrcweir if (calendars[i][0].equals(oObj.getLoadedCalendar().Name)) { 173cdf0e10cSrcweir //log.println(lang + " ... OK"); 174cdf0e10cSrcweir } else { 175cdf0e10cSrcweir log.println(lang + " ... FAILED"); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir res &= calendars[i][0].equals(oObj.getLoadedCalendar().Name); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir tRes.tested("loadCalendar()", res); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir /** 184cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 185cdf0e10cSrcweir * Has <b> OK </b> status if loaded calendar names are equal to gotten 186cdf0e10cSrcweir * calendar names after loading.<p> 187cdf0e10cSrcweir * The following method tests are to be completed successfully before : 188cdf0e10cSrcweir * <ul> 189cdf0e10cSrcweir * <li> <code> loadCalendar() </code> : loads calendar using a given name 190cdf0e10cSrcweir * and locale </li> 191cdf0e10cSrcweir * </ul> 192cdf0e10cSrcweir */ _getLoadedCalendar()193cdf0e10cSrcweir public void _getLoadedCalendar() { 194cdf0e10cSrcweir boolean res = true; 195cdf0e10cSrcweir 196cdf0e10cSrcweir requiredMethod("loadCalendar()"); 197cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 198cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 199cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 200cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 201cdf0e10cSrcweir oObj.loadCalendar(calendars[i][0], installed_locales[i]); 202cdf0e10cSrcweir if (calendars[i][0].equals(oObj.getLoadedCalendar().Name)) { 203cdf0e10cSrcweir //log.println(lang + " ... OK"); 204cdf0e10cSrcweir } else { 205cdf0e10cSrcweir log.println(lang + " ... FAILED"); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir res &= calendars[i][0].equals(oObj.getLoadedCalendar().Name); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir tRes.tested("getLoadedCalendar()", res); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir /** 213cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 214cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value that's equal to a 215cdf0e10cSrcweir * calendar name. <p> 216cdf0e10cSrcweir * The following method tests are to be completed successfully before : 217cdf0e10cSrcweir * <ul> 218cdf0e10cSrcweir * <li> <code> loadCalendar() </code> : loads calendar using a given name 219cdf0e10cSrcweir * and locale </li> 220cdf0e10cSrcweir * </ul> 221cdf0e10cSrcweir */ _getUniqueID()222cdf0e10cSrcweir public void _getUniqueID() { 223cdf0e10cSrcweir boolean res = true; 224cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 225cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 226cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 227cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 228cdf0e10cSrcweir oObj.loadCalendar(calendars[i][0], installed_locales[i]); 229cdf0e10cSrcweir String uID = oObj.getUniqueID(); 230cdf0e10cSrcweir if (uID.equals(calendars[i][0])) { 231cdf0e10cSrcweir //log.println(lang + " ... OK"); 232cdf0e10cSrcweir } else { 233cdf0e10cSrcweir log.println(lang + " ... FAILED"); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir res &= uID.equals(calendars[i][0]); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir tRes.tested("getUniqueID()",res); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir /** 242cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 243cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value, that's equal to 244cdf0e10cSrcweir * value set before. <p> 245cdf0e10cSrcweir */ 246cdf0e10cSrcweir _setDateTime()247cdf0e10cSrcweir public void _setDateTime() { 248cdf0e10cSrcweir boolean res = true; 249cdf0e10cSrcweir 250cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 251cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 252cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 253cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 254cdf0e10cSrcweir oObj.setDateTime(newDTime); 255cdf0e10cSrcweir double aDTime = oObj.getDateTime(); 256cdf0e10cSrcweir if (aDTime == newDTime) { 257cdf0e10cSrcweir //log.println(lang + " ... OK"); 258cdf0e10cSrcweir } else { 259cdf0e10cSrcweir log.println(lang + " ... FAILED"); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir res &= (aDTime == newDTime); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir tRes.tested("setDateTime()", res); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir /** 268cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 269cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value, that's equal to 270cdf0e10cSrcweir * value set before. <p> 271cdf0e10cSrcweir */ 272cdf0e10cSrcweir _getDateTime()273cdf0e10cSrcweir public void _getDateTime() { 274cdf0e10cSrcweir boolean res = true; 275cdf0e10cSrcweir 276cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 277cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 278cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 279cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Country; 280cdf0e10cSrcweir oObj.setDateTime(newDTime); 281cdf0e10cSrcweir double aDTime = oObj.getDateTime(); 282cdf0e10cSrcweir if (aDTime == newDTime) { 283cdf0e10cSrcweir //log.println(lang + " ... OK"); 284cdf0e10cSrcweir } else { 285cdf0e10cSrcweir log.println(lang + " ... FAILED"); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir res &= (aDTime == newDTime); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir tRes.tested("getDateTime()", res); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir /** 293cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 294cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value, that's equal to 295cdf0e10cSrcweir * value set before. <p> 296cdf0e10cSrcweir */ 297cdf0e10cSrcweir _setValue()298cdf0e10cSrcweir public void _setValue() { 299cdf0e10cSrcweir boolean res = true; 300cdf0e10cSrcweir for (int i=0; i<installed_locales.length; i++) { 301cdf0e10cSrcweir String error = ""; 302cdf0e10cSrcweir String lang = "Language: "+installed_locales[i].Language + 303cdf0e10cSrcweir ", Country: "+ installed_locales[i].Country + 304cdf0e10cSrcweir ", Variant: "+ installed_locales[i].Variant + 305cdf0e10cSrcweir ", Name: "+calendars[i][count[i]]; 306cdf0e10cSrcweir String[] names = new String[]{"DAY_OF_MONTH", 307cdf0e10cSrcweir "HOUR","MINUTE","SECOND","MILLISECOND", 308cdf0e10cSrcweir "YEAR","MONTH"}; 309cdf0e10cSrcweir oObj.loadCalendar(calendars[i][count[i]],installed_locales[i]); 310cdf0e10cSrcweir short[] fields = new short[]{CalendarFieldIndex.DAY_OF_MONTH, 311cdf0e10cSrcweir CalendarFieldIndex.HOUR, 312cdf0e10cSrcweir CalendarFieldIndex.MINUTE, 313cdf0e10cSrcweir CalendarFieldIndex.SECOND, 314cdf0e10cSrcweir CalendarFieldIndex.MILLISECOND, 315cdf0e10cSrcweir CalendarFieldIndex.YEAR, 316cdf0e10cSrcweir CalendarFieldIndex.MONTH 317cdf0e10cSrcweir }; 318cdf0e10cSrcweir for (int k=0; k<fields.length;k++) { 319cdf0e10cSrcweir 320cdf0e10cSrcweir oObj.setDateTime(0.0); 321cdf0e10cSrcweir 322cdf0e10cSrcweir // save the current values for debug purposes 323cdf0e10cSrcweir short[] oldValues = new short[fields.length]; 324cdf0e10cSrcweir for (int n=0; n < oldValues.length; n++){ 325cdf0e10cSrcweir oldValues[n] = oObj.getValue(fields[n]); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir short set = oObj.getValue(fields[k]); 329cdf0e10cSrcweir if (fields[k] == CalendarFieldIndex.MONTH) set = newValue; 330cdf0e10cSrcweir oObj.setValue(fields[k],set); 331cdf0e10cSrcweir short get = oObj.getValue(fields[k]); 332cdf0e10cSrcweir if (get != set) { 333cdf0e10cSrcweir if (debug) 334cdf0e10cSrcweir log.println("ERROR occure: tried to set " + names[k] + " to value " + set); 335cdf0e10cSrcweir log.println("list of values BEFORE set " + names[k] + " to value " + set + ":"); 336cdf0e10cSrcweir for (int n=0; n < oldValues.length; n++){ 337cdf0e10cSrcweir log.println(names[n] + ":" + oldValues[n]); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir log.println("list of values AFTER set " + names[k] + " to value " + set + ":"); 340cdf0e10cSrcweir for (int n=0; n < fields.length;n++){ 341cdf0e10cSrcweir log.println(names[n] + ":" + oObj.getValue(fields[n])); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir error += "failed for "+names[k]+" expected "+ 345cdf0e10cSrcweir set+" gained "+get+" ; \n"; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } 348cdf0e10cSrcweir if (error.equals("")) { 349cdf0e10cSrcweir log.println(lang + " ... OK"); 350cdf0e10cSrcweir } else { 351cdf0e10cSrcweir log.println("*** "+lang + " ... FAILED ***"); 352cdf0e10cSrcweir log.println(error); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir res &= (error.equals("")); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir tRes.tested("setValue()", res); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir /** 361cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 362cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value, that's equal to 363cdf0e10cSrcweir * value set before. <p> 364cdf0e10cSrcweir */ 365cdf0e10cSrcweir _getValue()366cdf0e10cSrcweir public void _getValue() { 367cdf0e10cSrcweir boolean res = true; 368cdf0e10cSrcweir 369cdf0e10cSrcweir requiredMethod("setValue()"); 370cdf0e10cSrcweir short aValue = oObj.getValue(CalendarFieldIndex.MONTH); 371cdf0e10cSrcweir res &= (aValue == newValue); 372cdf0e10cSrcweir if (!res){ 373cdf0e10cSrcweir log.println("the returned value is not the expected value:"); 374cdf0e10cSrcweir log.println("expexted: " + newValue + " returned value: " + aValue); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir tRes.tested("getValue()", res); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir /** 380cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 381cdf0e10cSrcweir * Has <b> OK </b> status if value, added by the method is greater than 382cdf0e10cSrcweir * previously defined "newValue". 383cdf0e10cSrcweir * <p> 384cdf0e10cSrcweir * The following method tests are to be completed successfully before : 385cdf0e10cSrcweir * <ul> 386cdf0e10cSrcweir * <li> <code> getValue() </code> : gets the value of a field </li> 387cdf0e10cSrcweir * </ul> 388cdf0e10cSrcweir */ _addValue()389cdf0e10cSrcweir public void _addValue() { 390cdf0e10cSrcweir boolean res = true; 391cdf0e10cSrcweir 392cdf0e10cSrcweir requiredMethod("getValue()"); 393cdf0e10cSrcweir oObj.addValue(CalendarFieldIndex.MONTH, 1); 394cdf0e10cSrcweir short aValue = oObj.getValue(CalendarFieldIndex.MONTH); 395cdf0e10cSrcweir res &= (aValue > newValue); 396cdf0e10cSrcweir if (!res){ 397cdf0e10cSrcweir log.println("the returned value is not the expected value:"); 398cdf0e10cSrcweir log.println("expexted: " + newValue + " returned value: " + aValue); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir tRes.tested("addValue()", res); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir /** 404cdf0e10cSrcweir * Test calls the method. <p> 405cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 406cdf0e10cSrcweir * and no exceptions were thrown. 407cdf0e10cSrcweir */ _setFirstDayOfWeek()408cdf0e10cSrcweir public void _setFirstDayOfWeek() { 409cdf0e10cSrcweir boolean res = true; 410cdf0e10cSrcweir 411cdf0e10cSrcweir oObj.setFirstDayOfWeek(firstDay); 412cdf0e10cSrcweir res &= true; 413cdf0e10cSrcweir tRes.tested("setFirstDayOfWeek()", res); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir /** 417cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 418cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value that is equal to 419cdf0e10cSrcweir * value set before. <p> 420cdf0e10cSrcweir * The following method tests are to be completed successfully before : 421cdf0e10cSrcweir * <ul> 422cdf0e10cSrcweir * <li> <code> setFirstDayOfWeek() </code> : set the first day of a 423cdf0e10cSrcweir * week</li> 424cdf0e10cSrcweir * </ul> 425cdf0e10cSrcweir */ _getFirstDayOfWeek()426cdf0e10cSrcweir public void _getFirstDayOfWeek() { 427cdf0e10cSrcweir boolean res = true; 428cdf0e10cSrcweir 429cdf0e10cSrcweir requiredMethod("setFirstDayOfWeek()"); 430cdf0e10cSrcweir short aFirstDayOfWeek = oObj.getFirstDayOfWeek(); 431cdf0e10cSrcweir res &= (aFirstDayOfWeek == firstDay); 432cdf0e10cSrcweir tRes.tested("getFirstDayOfWeek()", res); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir /** 436cdf0e10cSrcweir * Test calls the method. <p> 437cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 438cdf0e10cSrcweir * and no exceptions were thrown. 439cdf0e10cSrcweir */ _setMinimumNumberOfDaysForFirstWeek()440cdf0e10cSrcweir public void _setMinimumNumberOfDaysForFirstWeek() { 441cdf0e10cSrcweir boolean res = true; 442cdf0e10cSrcweir 443cdf0e10cSrcweir oObj.setMinimumNumberOfDaysForFirstWeek(mdfw); 444cdf0e10cSrcweir res &= true; 445cdf0e10cSrcweir tRes.tested("setMinimumNumberOfDaysForFirstWeek()", res); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir /** 449cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 450cdf0e10cSrcweir * Has <b> OK </b> status if the method returns value that is equal to 451cdf0e10cSrcweir * value set before. <p> 452cdf0e10cSrcweir * The following method tests are to be completed successfully before : 453cdf0e10cSrcweir * <ul> 454cdf0e10cSrcweir * <li> <code> setMinimumNumberOfDaysForFirstWeek() </code> : sets how 455cdf0e10cSrcweir * many days of a week must reside in the first week of a year</li> 456cdf0e10cSrcweir * </ul> 457cdf0e10cSrcweir */ _getMinimumNumberOfDaysForFirstWeek()458cdf0e10cSrcweir public void _getMinimumNumberOfDaysForFirstWeek() { 459cdf0e10cSrcweir boolean res = true; 460cdf0e10cSrcweir 461cdf0e10cSrcweir requiredMethod("setMinimumNumberOfDaysForFirstWeek()"); 462cdf0e10cSrcweir short aShort = oObj.getMinimumNumberOfDaysForFirstWeek(); 463cdf0e10cSrcweir res &= (aShort == mdfw); 464cdf0e10cSrcweir tRes.tested("getMinimumNumberOfDaysForFirstWeek()", res); 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir /** 468cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 469cdf0e10cSrcweir * Has <b> OK </b> status if the method returns 12. 470cdf0e10cSrcweir */ _getNumberOfMonthsInYear()471cdf0e10cSrcweir public void _getNumberOfMonthsInYear() { 472cdf0e10cSrcweir boolean res = true; 473cdf0e10cSrcweir short aShort = oObj.getNumberOfMonthsInYear(); 474cdf0e10cSrcweir 475cdf0e10cSrcweir res &= (aShort == (short) 12); 476cdf0e10cSrcweir tRes.tested("getNumberOfMonthsInYear()", res); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir /** 480cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 481cdf0e10cSrcweir * Has <b> OK </b> status if the method returns 7. 482cdf0e10cSrcweir */ _getNumberOfDaysInWeek()483cdf0e10cSrcweir public void _getNumberOfDaysInWeek() { 484cdf0e10cSrcweir boolean res = true; 485cdf0e10cSrcweir short aShort = oObj.getNumberOfDaysInWeek(); 486cdf0e10cSrcweir 487cdf0e10cSrcweir res &= (aShort == (short) 7); 488cdf0e10cSrcweir tRes.tested("getNumberOfDaysInWeek()", res); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir /** 492cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 493cdf0e10cSrcweir * Has <b> OK </b> status if length of array, returned by the method is 12. 494cdf0e10cSrcweir */ _getMonths()495cdf0e10cSrcweir public void _getMonths() { 496cdf0e10cSrcweir boolean res = true; 497cdf0e10cSrcweir CalendarItem[] months = oObj.getMonths(); 498cdf0e10cSrcweir 499cdf0e10cSrcweir res &= (months.length == 12); 500cdf0e10cSrcweir tRes.tested("getMonths()", res); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir /** 504cdf0e10cSrcweir * Test calls the method, then result is checked. <p> 505cdf0e10cSrcweir * Has <b> OK </b> status if length of array, returned by the method is 7. 506cdf0e10cSrcweir */ _getDays()507cdf0e10cSrcweir public void _getDays() { 508cdf0e10cSrcweir boolean res = true; 509cdf0e10cSrcweir CalendarItem[] Days = oObj.getDays(); 510cdf0e10cSrcweir 511cdf0e10cSrcweir res &= (Days.length == 7); 512cdf0e10cSrcweir tRes.tested("getDays()", res); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir /** 516cdf0e10cSrcweir * After loading calendar, test calls the method, then result is checked.<p> 517cdf0e10cSrcweir * Has <b> OK </b> status if length of string, returned by the method is 3. 518cdf0e10cSrcweir */ _getDisplayName()519cdf0e10cSrcweir public void _getDisplayName() { 520cdf0e10cSrcweir boolean res = true; 521cdf0e10cSrcweir 522cdf0e10cSrcweir oObj.loadCalendar(calendars[0][0],installed_locales[0]); 523cdf0e10cSrcweir String DisplayName = oObj.getDisplayName(CalendarDisplayIndex.MONTH, 524cdf0e10cSrcweir newValue, (short) 0); 525cdf0e10cSrcweir res &= (DisplayName.length() == 3); 526cdf0e10cSrcweir tRes.tested("getDisplayName()", res); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir 530cdf0e10cSrcweir /** 531cdf0e10cSrcweir * The test sets obviously wrong value, then calls a method. After that the 532cdf0e10cSrcweir * test sets correct value, and again calls a method. <p> 533cdf0e10cSrcweir * Has <b> OK </b> status if the method returns true when valid month is 534cdf0e10cSrcweir * set, and if the method returns false when set month is not valid. 535cdf0e10cSrcweir */ _isValid()536cdf0e10cSrcweir public void _isValid() { 537cdf0e10cSrcweir boolean res = true; 538cdf0e10cSrcweir 539cdf0e10cSrcweir oObj.loadDefaultCalendar(installed_locales[0]); 540cdf0e10cSrcweir oObj.setValue(CalendarFieldIndex.MONTH, (short) 37); 541cdf0e10cSrcweir res &= !oObj.isValid(); 542cdf0e10cSrcweir oObj.setValue(CalendarFieldIndex.MONTH, (short) 10); 543cdf0e10cSrcweir res &= oObj.isValid(); 544cdf0e10cSrcweir 545cdf0e10cSrcweir tRes.tested("isValid()", res); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir /** 549cdf0e10cSrcweir * Method returns locale for a given language and country. 550cdf0e10cSrcweir * @param localeIndex index of needed locale. 551cdf0e10cSrcweir */ 552cdf0e10cSrcweir /* public Locale getLocale(int localeIndex) { 553cdf0e10cSrcweir return new Locale(languages[localeIndex], countries[localeIndex], ""); 554cdf0e10cSrcweir }*/ 555cdf0e10cSrcweir 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558