1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.chart; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 import lib.StatusException; 33 34 import com.sun.star.beans.XPropertySet; 35 import com.sun.star.chart.XDiagram; 36 37 /** 38 * Testing <code>com.sun.star.chart.XDiagram</code> 39 * interface methods : 40 * <ul> 41 * <li><code> getDiagramType()</code></li> 42 * <li><code> getDataRowProperties()</code></li> 43 * <li><code> getDataPointProperties()</code></li> 44 * </ul> <p> 45 * This test needs the following object relations : 46 * <ul> 47 * <li> <code>'ROWAMOUNT'</code> (of type <code>Integer</code>): 48 * to have amount of rows </li> 49 * <li> <code>'COLAMOUNT'</code> (of type <code>Integer</code>): 50 * to have amount of columns </li> 51 * <ul> <p> 52 * @see com.sun.star.chart.XDiagram 53 */ 54 public class _XDiagram extends MultiMethodTest { 55 56 public XDiagram oObj = null; 57 boolean result = true; 58 Integer rowamount = null; 59 Integer colamount = null; 60 61 /** 62 * Retrieves object relations. 63 * @throws StatusException If one of relations not found. 64 */ 65 public void before() { 66 rowamount = (Integer)tEnv.getObjRelation("ROWAMOUNT"); 67 if (rowamount == null) throw new StatusException(Status.failed 68 ("Relation 'ROWAMOUNT' not found")); 69 70 colamount = (Integer)tEnv.getObjRelation("COLAMOUNT"); 71 if (colamount == null) throw new StatusException(Status.failed 72 ("Relation 'COLAMOUNT' not found")); 73 } 74 75 /** 76 * Test calls the method and checks returned value. <p> 77 * Has <b> OK </b> status if returned value start from 'com.sun.star.chart.' <p> 78 */ 79 public void _getDiagramType() { 80 result = true; 81 82 String stype = oObj.getDiagramType(); 83 log.println("Current Diagram Type is " + stype); 84 result = (stype.startsWith("com.sun.star.chart.")); 85 86 tRes.tested("getDiagramType()", result); 87 } 88 89 /** 90 * Test calls the method for every row and checks returned value. <p> 91 * Has <b> OK </b> status if returned value for every row isn't null and 92 * no exceptions were thrown. <p> 93 */ 94 public void _getDataRowProperties() { 95 result = true; 96 97 int rows = rowamount.intValue(); 98 rows -= 1; 99 XPropertySet props = null; 100 101 log.println("There are " + rows + " rows."); 102 try { 103 for (int i = 0; i < rows; i++) { 104 props = oObj.getDataRowProperties(i); 105 if (props != null) { 106 log.println("Row " + i + " - OK"); 107 } else { 108 log.println("Row " + i + " - FAILED"); 109 result = false; 110 } 111 } 112 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 113 log.println("Exception while get data row properties"); 114 e.printStackTrace(log); 115 result = false; 116 } 117 118 tRes.tested("getDataRowProperties()", result); 119 } 120 121 /** 122 * Test calls the method for every point and checks returned value. <p> 123 * Has <b> OK </b> status if returned value for every point isn't null and 124 * no exceptions were thrown. <p> 125 */ 126 public void _getDataPointProperties() { 127 result = true; 128 129 int rows = rowamount.intValue(); 130 int cols = colamount.intValue(); 131 XPropertySet props = null; 132 133 log.println("There are " + rows + " rows and " + cols + " cols."); 134 135 try { 136 for (int i = 0; i < rows; i++) 137 for (int j = 0; j < cols; j++) { 138 props = oObj.getDataPointProperties(i, j); 139 if (props != null) { 140 log.println("Row " + i + " Col " + j + " - OK"); 141 } else { 142 log.println("Row " + i + " Col " + j + " - FAILED"); 143 result = false; 144 } 145 } 146 } catch(com.sun.star.lang.IndexOutOfBoundsException e) { 147 log.println("Exception while get data point properties"); 148 e.printStackTrace(log); 149 result = false; 150 } 151 152 tRes.tested("getDataPointProperties()", result); 153 } 154 } 155 156 157