/**************************************************************
*
* 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
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package ifc.util;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.beans.PropertyValue;
import com.sun.star.table.TableSortField;
import com.sun.star.util.XSortable;
/**
* Testing com.sun.star.util.XSortable
* interface methods :
*
createSortDescriptor() sort()* This test needs the following object relations : *
'SORTCHECKER' :
* _XSortable.XSortChecker interface implementation
* * Test is NOT multithread compilant.
* @see com.sun.star.util.XSortable */ public class _XSortable extends MultiMethodTest { // oObj filled by MultiMethodTest public XSortable oObj = null; XSortChecker checker = null; PropertyValue[] oPV = null; protected void before() { checker = (XSortChecker) tEnv.getObjRelation("SORTCHECKER"); if (checker == null) { throw new StatusException(Status.failed( "Couldn't get relation 'SORTCHECKER'")); } checker.setPrintWriter(log); } /** * Test calls the method.
* Has OK status if the length of the returned array * is greater than zero.
*/ public void _createSortDescriptor() { boolean bResult = false; log.println("test for createSortDescriptor() "); oPV = oObj.createSortDescriptor(); if (oPV.length > 0) { bResult = true; for (int k = 0; k < oPV.length; k++) { log.println("DescriptorProperty " + k + ": Name=" + oPV[k].Name + "; Value=" + oPV[k].Value); if (oPV[k].Name.equals("SortFields")) { TableSortField[] tsf = (TableSortField[]) oPV[k].Value; for (int l = 0; l < tsf.length; l++) { log.println("\t isAscending: " + tsf[l].IsAscending); log.println("\t IsCaseSensitive: " + tsf[l].IsCaseSensitive); log.println("\t CollatorAlgorithm: " + tsf[l].CollatorAlgorithm); } } } } log.println("Found " + oPV.length + " PropertyValues"); tRes.tested("createSortDescriptor()", bResult); } /** * Test calls the method using descriptor created before as * parameter.
* Has OK status if the method successfully returns * and no exceptions were thrown.
* The following method tests are to be completed successfully before : *
createSortDescriptor() : to have a descriptor
* for sort.