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