Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _SheetSortDescriptor.java
blobf540d77db610c17b4fe0cacab57d16e578839070
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.sheet;
21 import lib.MultiMethodTest;
22 import util.ValueChanger;
24 import com.sun.star.beans.PropertyValue;
25 import com.sun.star.beans.XPropertySet;
26 import com.sun.star.table.CellAddress;
27 import com.sun.star.util.XSortable;
29 /**
30 * Testing <code>com.sun.star.sheet.SheetSortDescriptor</code>
31 * service properties: <p>
32 * <ul>
33 * <li><code>BindFormatsToContent</code></li>
34 * <li><code>CopyOutputData</code></li>
35 * <li><code>IsCaseSensitive</code></li>
36 * <li><code>IsUserListEnabled</code></li>
37 * <li><code>OutputPosition</code></li>
38 * <li><code>SortAscending</code></li>
39 * <li><code>UserListIndex</code></li>
40 * </ul> <p>
41 * @see com.sun.star.sheet.SheetSortDescriptor
43 public class _SheetSortDescriptor extends MultiMethodTest {
45 public XPropertySet oObj = null;
46 public XSortable xSORT = null;
47 public PropertyValue[] props = null;
49 public void _BindFormatsToContent() {
50 xSORT = (XSortable) tEnv.getObjRelation("xSORT");
51 props = xSORT.createSortDescriptor();
52 changeProp("BindFormatsToContent",5);
55 public void _CopyOutputData() {
56 changeProp("CopyOutputData",6);
59 public void _IsCaseSensitive() {
60 changeProp("IsCaseSensitive",4);
63 public void _IsUserListEnabled() {
64 changeProp("IsUserListEnabled",8);
67 public void _OutputPosition() {
68 changeProp("OutputPosition",7);
71 public void _SortAscending() {
72 log.println("Property 'SortAscending' is not part of the "+
73 "property array");
74 log.println("Available properties:");
75 for (int i=0; i<props.length;i++) {
76 log.println("\t"+props[i].Name);
78 tRes.tested("SortAscending",false);
81 public void _UserListIndex() {
82 changeProp("UserListIndex",9);
85 public void changeProp(String name, int nr) {
87 Object gValue = null;
88 Object sValue = null;
89 Object ValueToSet = null;
90 int gInt = 0;
91 int sInt = 0;
93 if ( ! name.equals(props[nr].Name) ) {
94 log.println("Property '"+props[nr].Name+"' is tested");
95 log.println("But the status is for '"+name+"'");
99 try {
100 gValue = props[nr].Value;
101 if ( name.equals("OutputPosition")) {
102 gInt = ((CellAddress) gValue).Row;
104 ValueToSet = ValueChanger.changePValue(gValue);
105 props[nr].Value=ValueToSet;
106 sValue = props[nr].Value;
107 if ( name.equals("OutputPosition")) {
108 sInt = ((CellAddress) sValue).Row;
109 gValue = Integer.valueOf(gInt);
110 sValue = Integer.valueOf(sInt);
113 //check get-set methods
114 if ( (gValue.equals(sValue)) || (sValue == null) ) {
115 log.println("Value for '"+name+"' hasn't changed");
116 tRes.tested(name, false);
118 else {
119 log.println("Property '"+name+"' OK");
120 tRes.tested(name, true);
122 } catch (Exception e) {
123 log.println("Exception occurred while testing property '" +
124 name + "'");
125 e.printStackTrace(log);
126 tRes.tested(name, false);
130 }// end of changeProp
133 } // finish class _SheetSortDescriptor