summaryrefslogtreecommitdiffstats
path: root/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba')
-rw-r--r--qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba306
1 files changed, 0 insertions, 306 deletions
diff --git a/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba b/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba
deleted file mode 100644
index c3d7befd4987..000000000000
--- a/qadevOOo/tests/basic/ifc/i18n/XCalendar/i18n_XCalendar.xba
+++ /dev/null
@@ -1,306 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
-<script:module xmlns:script="http://openoffice.org/2000/script" script:name="i18n_XCalendar" script:language="StarBasic">
-
-
-'*************************************************************************
-'
-' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-'
-' Copyright 2000, 2010 Oracle and/or its affiliates.
-'
-' OpenOffice.org - a multi-platform office productivity suite
-'
-' This file is part of OpenOffice.org.
-'
-' OpenOffice.org is free software: you can redistribute it and/or modify
-' it under the terms of the GNU Lesser General Public License version 3
-' only, as published by the Free Software Foundation.
-'
-' OpenOffice.org is distributed in the hope that it will be useful,
-' but WITHOUT ANY WARRANTY; without even the implied warranty of
-' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-' GNU Lesser General Public License version 3 for more details
-' (a copy is included in the LICENSE file that accompanied this code).
-'
-' You should have received a copy of the GNU Lesser General Public License
-' version 3 along with OpenOffice.org. If not, see
-' <http://www.openoffice.org/license.html>
-' for a copy of the LGPLv3 License.
-'
-'*************************************************************************
-'*************************************************************************
-
-
-
-' Be sure that all variables are dimensioned:
-option explicit
-
-
-
-Sub RunTest()
-
-'*************************************************************************
-' INTERFACE:
-' com.sun.star.i18n.XCalendar
-'*************************************************************************
-On Error Goto ErrHndl
- Dim bOK As Boolean
- Dim oLocaleData As Object
- Dim oLocale As Object
- Dim allLocales As Variant
- Dim allCalendars As Variant
- Dim uniqueID As String
- Dim oCalendar As Object
- Dim dDateTime As Double
- Dim aValue As Variant
- Dim oldValue As Variant
- Dim newValue As Variant
- Dim i As Integer
-
- oLocaleData = createUnoService("com.sun.star.i18n.LocaleData")
- allLocales = oLocaleData.getAllInstalledLocaleNames()
- Out.Log("Found " + ubound(allLocales) + " Loacales registered in the system")
- Randomize
- oLocale = allLocales(rnd * ubound(allLocales))
- Out.Log("Choose for testing : " + oLocale.Country)
-
- Test.StartMethod("getAllCalendars()")
- bOK = true
- allCalendars = oObj.getAllCalendars(oLocale)
- Out.Log("There are " + ubound(allCalendars) + 1 + " calendars for this locale.")
- bOK = bOK AND NOT isNULL(allCalendars)
- Test.MethodTested("getAllCalendars()", bOK)
-
- Test.StartMethod("loadDefaultCalendar()")
- bOK = true
- oObj.loadDefaultCalendar(oLocale)
- bOK = bOK AND oObj.getLoadedCalendar().Default
- Test.MethodTested("loadDefaultCalendar()", bOK)
-
- Test.StartMethod("getUniqueID()")
- bOK = true
- uniqueID = oObj.getUniqueID()
- Out.Log("UniqueID for loaded calendar is " + uniqueID)
- bOK = bOK AND (uniqueID = allCalendars(0))
- Test.MethodTested("getUniqueID()", bOK)
-
- Test.StartMethod("loadCalendar()")
- bOK = true
- oObj.loadCalendar(allCalendars(0), oLocale)
- bOK = bOK AND NOT isNULL(oObj.getLoadedCalendar())
- Test.MethodTested("loadCalendar()", bOK)
-
- Test.StartMethod("getLoadedCalendar()")
- bOK = true
- oCalendar = oObj.getLoadedCalendar()
- Out.Log("Loaded calendar's name is '" + oCalendar.Name + "'")
- bOK = bOK AND NOT isNULL(oCalendar)
- Test.MethodTested("getLoadedCalendar()", bOK)
-
- Test.StartMethod("setDateTime()")
- Test.StartMethod("getDateTime()")
- bOK = true
- oObj.setDateTime(12345.25)
- dDateTime = oObj.getDateTime()
- bOK = bOK AND dDateTime = 12345.25
- Out.Log("Expected: 12345,25; Actual: " + dDateTime)
- Test.MethodTested("setDateTime()", bOK)
- Test.MethodTested("getDateTime()", bOK)
-
- Test.StartMethod("getFirstDayOfWeek()")
- Test.StartMethod("setFirstDayOfWeek()")
- bOK = true
- oObj.setFirstDayOfWeek(com.sun.star.i18n.Weekdays.SATURDAY)
- Out.Log("Expected: " + com.sun.star.i18n.Weekdays.SATURDAY + ", Actual: " + oObj.getFirstDayOfWeek())
- bOK = bOK AND oObj.getFirstDayOfWeek() = com.sun.star.i18n.Weekdays.SATURDAY
- oObj.setFirstDayOfWeek(com.sun.star.i18n.Weekdays.SUNDAY)
- Out.Log("Expected: " + com.sun.star.i18n.Weekdays.SUNDAY + ", Actual: " + oObj.getFirstDayOfWeek())
- bOK = bOK AND oObj.getFirstDayOfWeek() = com.sun.star.i18n.Weekdays.SUNDAY
-
- Test.MethodTested("getFirstDayOfWeek()", bOK)
- Test.MethodTested("setFirstDayOfWeek()", bOK)
-
- Test.StartMethod("setValue()")
- Test.StartMethod("getValue()")
- bOK = true
- bOK = bOK AND TestValue(1, com.sun.star.i18n.Months.JANUARY, 2001, com.sun.star.i18n.WeekDays.MONDAY, 1, 1)
- '1.01.2001 - Monday, 1-st week of month, 1-st week of year
- bOK = bOK AND TestValue(12, com.sun.star.i18n.Months.JULY, 2001, com.sun.star.i18n.WeekDays.THURSDAY, 2, 28)
- '12.07.2001 - Thursday, 2-nd week of month, 28-st week of year
-
- Test.MethodTested("setValue()", bOK)
- Test.MethodTested("getValue()", bOK)
-
- Test.StartMethod("addValue()")
- bOK = true
-
- bOK = bOK AND TestAddValue("DST_OFFSET", com.sun.star.i18n.CalendarFieldIndex.DST_OFFSET, 1, 0)
- bOK = bOK AND TestAddValue("DAY_OF_MONTH", com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 1, 0)
- bOK = bOK AND TestAddValue("MONTH", com.sun.star.i18n.CalendarFieldIndex.MONTH, 3, 12)
- bOK = bOK AND TestAddValue("YEAR", com.sun.star.i18n.CalendarFieldIndex.YEAR, -1, 0)
- bOK = bOK AND TestAddValue("HOUR", com.sun.star.i18n.CalendarFieldIndex.HOUR, 7, 24)
- bOK = bOK AND TestAddValue("MINUTE", com.sun.star.i18n.CalendarFieldIndex.MINUTE, 31, 60)
- bOK = bOK AND TestAddValue("SECOND", com.sun.star.i18n.CalendarFieldIndex.SECOND, 13, 60)
- bOK = bOK AND TestAddValue("MILLISECOND", com.sun.star.i18n.CalendarFieldIndex.MILLISECOND, 67, 1000)
- bOK = bOK AND TestAddValue("ERA", com.sun.star.i18n.CalendarFieldIndex.ERA, -1, 0)
-
- Test.MethodTested("addValue()", bOK)
-
- Test.StartMethod("getNumberOfMonthsInYear()")
- bOK = true
- aValue = oObj.getNumberOfMonthsInYear()
- Out.Log("There are " + aValue + " months in year")
- bOK = bOK AND aValue = 12
- Test.MethodTested("getNumberOfMonthsInYear()", bOK)
-
- Test.StartMethod("getNumberOfDaysInWeek()")
- bOK = true
- aValue = oObj.getNumberOfDaysInWeek()
- Out.Log("There are " + aValue + " days in week")
- bOK = bOK AND aValue = 7
- Test.MethodTested("getNumberOfDaysInWeek()", bOK)
-
- Test.StartMethod("getMinimumNumberOfDaysForFirstWeek()")
- bOK = true
- aValue = oObj.getMinimumNumberOfDaysForFirstWeek()
- Out.Log("MinimumNumberOfDaysForFirstWeek = " + aValue)
- bOK = bOK AND aValue &gt; 0 AND aValue &lt; 8
- Test.MethodTested("getMinimumNumberOfDaysForFirstWeek()", bOK)
-
- Test.StartMethod("setMinimumNumberOfDaysForFirstWeek()")
- bOK = true
- oObj.setMinimumNumberOfDaysForFirstWeek(211)
- aValue = oObj.getMinimumNumberOfDaysForFirstWeek()
- Out.Log("MinimumNumberOfDaysForFirstWeek = " + aValue)
- bOK = bOK AND aValue &gt; 0 AND aValue &lt; 8
- Test.MethodTested("setMinimumNumberOfDaysForFirstWeek()", bOK)
-
- Test.StartMethod("getMonths()")
- bOK = true
- Dim allMonths As Variant
- Dim cAllMonths As String
- allMonths = oObj.getMonths()
- Out.Log("Returned " + ubound(allMonths) + 1 + " months.")
- bOK = bOK AND ubound(allMonths) + 1= oObj.getNumberOfMonthsInYear()
- if (bOK) then
- cAllMonths = ""
- for i = 0 to ubound(allMonths)
- cAllMonths = cAllMonths + allMonths(i).FullName + ", "
- next i
- Out.Log("Months: " + cAllMonths)
- end if
-
- Test.MethodTested("getMonths()", bOK)
-
- Test.StartMethod("getDays()")
- bOK = true
- Dim allDays As Variant
- Dim cAllDays As String
- allDays = oObj.getDays()
- Out.Log("Returned " + ubound(allMonths) + 1 + " days.")
- bOK = bOK AND ubound(allDays) + 1= oObj.getNumberOfDaysInWeek()
- if (bOK) then
- cAllDays = ""
- for i = 0 to ubound(allDays)
- cAllDays = cAllDays + allDays(i).FullName + ", "
- next i
- Out.Log("Days: " + cAllDays)
- end if
- Test.MethodTested("getDays()", bOK)
-
- Test.StartMethod("getDisplayName()")
- bOK = true
- Dim cDisplayName As String
- cDisplayName = oObj.getDisplayName(com.sun.star.i18n.CalendarDisplayIndex.MONTH, com.sun.star.i18n.Months.JANUARY, 1)
- Out.Log("Full name for JANUARY is: " + cDisplayName)
- bOK = bOK AND cDisplayName &lt;&gt; ""
- Test.MethodTested("getDisplayName()", bOK)
-
- Test.StartMethod("isValid()")
- bOK = true
-
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 30)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, com.sun.star.i18n.Months.FEBURARY)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, 2001)
- Out.Log("isValid() = " + oObj.isValid())
- bOK = bOK AND NOT oObj.isValid()
-
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, 27)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, com.sun.star.i18n.Months.FEBURARY)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, 2001)
- Out.Log("isValid() = " + oObj.isValid())
- bOK = bOK AND oObj.isValid()
-
- Test.MethodTested("isValid()", bOK)
-
-Exit Sub
-ErrHndl:
- Test.Exception()
- bOK = false
- resume next
-End Sub
-
-Function TestValue(_Day As Integer, _Month As Integer, _Year As Integer, _
- _Day_of_week As Integer, _Week_of_month As Integer, _Week_of_year As Integer) As Boolean
-
- Dim bOK As Boolean
- Dim aDay As Integer, aMonth As Integer, aYear As Integer
- Dim aDay_of_week As Integer, aWeek_of_Month As Integer, aWeek_of_year As Integer
-
- bOK = true
-
- Out.Log("Set date to " + _Day + "." + _Month + "." + _Year + ";")
-
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH, _Day)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.MONTH, _Month)
- oObj.setValue(com.sun.star.i18n.CalendarFieldIndex.YEAR, _Year)
-
- aDay = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_MONTH)
- aMonth = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.MONTH)
- aYear = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.YEAR)
-
- Out.Log("Now date is " + aDay + "." + aMonth + "." + aYear + ";")
-
- bOK = (aDay = _Day) AND (aMonth = _Month) AND (aYear = _Year)
-
- if (bOK) then
- aDay_of_week = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.DAY_OF_WEEK)
- aWeek_of_month = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.WEEK_OF_MONTH)
- aWeek_of_year = oObj.getValue(com.sun.star.i18n.CalendarFieldIndex.WEEK_OF_YEAR)
- Out.Log("aDay_of_week: Expected: " + _Day_of_week + ", Actual: " + aDay_of_week)
- Out.Log("aWeek_of_month: Expected: " + _Week_of_month + ", Actual: " + aWeek_of_month)
- Out.Log("aWeek_of_year: Expected: " + _Week_of_year + ", Actual: " + aWeek_of_year)
- bOK = (aDay_of_week = _Day_of_week) AND (aWeek_of_month = _Week_of_month) AND (aWeek_of_year = _Week_of_year)
- end if
-
- TestValue() = bOK
-
-Exit Function
-ErrHndl:
- Test.Exception()
- TestValue() = false
-End Function
-
-Function TestAddValue(valname As String, Idx As Integer, incValue As Integer, valModule As Integer) As Boolean
- Dim aValue As Integer
- Dim newValue As Integer
- Dim bOK As Boolean
-
- aValue = oObj.getValue(idx)
- oObj.addValue(idx, incValue)
- newValue = oObj.getValue(idx)
- if (valModule = 0) then
- bOK = (newValue = (aValue + incValue))
- Out.Log(valname + ": Expected: " + (aValue + incValue) + ", Actual: " + newValue)
- else
- bOK = (newValue = (aValue + incValue) mod valModule)
- Out.Log(valname + ": Expected: " + (aValue + incValue) mod valModule + ", Actual: " + newValue)
- end if
- TestAddValue() = bOK
-Exit Function
-ErrHndl:
- Test.Exception()
- TestAddValue() = false
-End Function
-</script:module>