1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.io; 25 26 import lib.MultiMethodTest; 27 28 import com.sun.star.io.XMarkableStream; 29 30 /** 31 * Testing <code>com.sun.star.io.XMarkableStream</code> 32 * interface methods: 33 * <ul> 34 * <li><code>createMark()</code></li> 35 * <li><code>deleteMark()</code></li> 36 * <li><code>jumpToFurthest()</code></li> 37 * <li><code>jumpToMark()</code></li> 38 * <li><code>offsetToMark()</code></li> 39 * </ul> <p> 40 * @see com.sun.star.io.XMarkableStream 41 */ 42 public class _XMarkableStream extends MultiMethodTest { 43 44 public XMarkableStream oObj = null; 45 private int mark = -1 ; 46 47 /** 48 * Test creates mark and stores it. <p> 49 * Has <b> OK </b> status if no exceptions were thrown 50 * and returned isn't less than zero. <p> 51 */ _createMark()52 public void _createMark() { 53 boolean res; 54 try { 55 mark = oObj.createMark() ; 56 res = mark >= 0; 57 } catch (com.sun.star.io.IOException e) { 58 log.println("Couldn't create mark"); 59 e.printStackTrace(log); 60 res = false; 61 } 62 63 tRes.tested("createMark()", res); 64 } 65 66 /** 67 * Test deletes the mark that was created by method <code>createMark() 68 * </code>.<p> 69 * Has <b> OK </b> status if the method successfully returns 70 * and no exceptions were thrown. <p> 71 * The following method tests are to be completed successfully before : 72 * <ul> 73 * <li> <code> createMark() </code> : to have mark </li> 74 * </ul> 75 * The following method tests are to be executed before : 76 * <ul> 77 * <li> <code> jumpToFurthest() </code></li> 78 * <li> <code> jumpToMark() </code></li> 79 * <li> <code> offsetToMark() </code></li> 80 * </ul> 81 */ _deleteMark()82 public void _deleteMark() { 83 requiredMethod("createMark()") ; 84 85 executeMethod("jumpToFurthest()") ; 86 executeMethod("jumpToMark()") ; 87 executeMethod("offsetToMark()") ; 88 89 boolean res; 90 try { 91 oObj.deleteMark(mark); 92 res = true; 93 } catch(com.sun.star.io.IOException e) { 94 log.println("Couldn't delete mark"); 95 e.printStackTrace(log); 96 res = false; 97 } catch(com.sun.star.lang.IllegalArgumentException e) { 98 log.println("Couldn't delete mark"); 99 e.printStackTrace(log); 100 res = false; 101 } 102 103 tRes.tested("deleteMark()", res) ; 104 } 105 106 /** 107 * Test calls the method. <p> 108 * Has <b> OK </b> status if the method successfully returns 109 * and no exceptions were thrown. <p> 110 * The following method tests are to be completed successfully before : 111 * <ul> 112 * <li> <code> createMark() </code></li> 113 * </ul> 114 */ _jumpToFurthest()115 public void _jumpToFurthest() { 116 requiredMethod("createMark()") ; 117 118 boolean res; 119 try { 120 oObj.jumpToFurthest() ; 121 res = true; 122 } catch (com.sun.star.io.IOException e) { 123 log.println("Couldn't jump to furthest"); 124 e.printStackTrace(log); 125 res = false; 126 } 127 128 tRes.tested("jumpToFurthest()", res) ; 129 } 130 131 /** 132 * Test jumps to mark that was created by method <code>createMark()</code>. 133 * <p>Has <b> OK </b> status if the method successfully returns 134 * and no exceptions were thrown. <p> 135 * The following method tests are to be completed successfully before : 136 * <ul> 137 * <li> <code> jumpToFurthest() </code> : for the right order of tests 138 * excecution </li> 139 * </ul> 140 */ _jumpToMark()141 public void _jumpToMark() { 142 requiredMethod("jumpToFurthest()") ; 143 boolean res; 144 145 try { 146 oObj.jumpToMark(mark) ; 147 res = true; 148 } catch(com.sun.star.lang.IllegalArgumentException e) { 149 log.println("Couldn't jump to mark"); 150 e.printStackTrace(log); 151 res = false; 152 } catch(com.sun.star.io.IOException e) { 153 log.println("Couldn't jump to mark"); 154 e.printStackTrace(log); 155 res = false; 156 } 157 158 tRes.tested("jumpToMark()", res) ; 159 } 160 161 /** 162 * Test obtains offset to mark that was created by 163 * method <code>createMark()</code> and checks returned value.<p> 164 * Has <b> OK </b> status if returned value is equal to zero 165 * and no exceptions were thrown. <p> 166 * The following method tests are to be completed successfully before : 167 * <ul> 168 * <li> <code> jumpToMark() </code> : to have current position at 169 * the mark position </li> 170 * </ul> 171 */ _offsetToMark()172 public void _offsetToMark() { 173 174 requiredMethod("jumpToMark()") ; 175 176 boolean res; 177 try { 178 int offset = oObj.offsetToMark(mark); 179 res = offset == 0; 180 } catch(com.sun.star.lang.IllegalArgumentException e) { 181 log.println("Couldn't get offser to mark"); 182 e.printStackTrace(log); 183 res = false; 184 } catch(com.sun.star.io.IOException e) { 185 log.println("Couldn't get offser to mark"); 186 e.printStackTrace(log); 187 res = false; 188 } 189 190 tRes.tested("offsetToMark()", res); 191 } 192 } 193 194