1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XMarkableStream.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.io
.XMarkableStream
;
38 * Testing <code>com.sun.star.io.XMarkableStream</code>
41 * <li><code>createMark()</code></li>
42 * <li><code>deleteMark()</code></li>
43 * <li><code>jumpToFurthest()</code></li>
44 * <li><code>jumpToMark()</code></li>
45 * <li><code>offsetToMark()</code></li>
47 * @see com.sun.star.io.XMarkableStream
49 public class _XMarkableStream
extends MultiMethodTest
{
51 public XMarkableStream oObj
= null;
52 private int mark
= -1 ;
55 * Test creates mark and stores it. <p>
56 * Has <b> OK </b> status if no exceptions were thrown
57 * and returned isn't less than zero. <p>
59 public void _createMark() {
62 mark
= oObj
.createMark() ;
64 } catch (com
.sun
.star
.io
.IOException e
) {
65 log
.println("Couldn't create mark");
66 e
.printStackTrace(log
);
70 tRes
.tested("createMark()", res
);
74 * Test deletes the mark that was created by method <code>createMark()
76 * Has <b> OK </b> status if the method successfully returns
77 * and no exceptions were thrown. <p>
78 * The following method tests are to be completed successfully before :
80 * <li> <code> createMark() </code> : to have mark </li>
82 * The following method tests are to be executed before :
84 * <li> <code> jumpToFurthest() </code></li>
85 * <li> <code> jumpToMark() </code></li>
86 * <li> <code> offsetToMark() </code></li>
89 public void _deleteMark() {
90 requiredMethod("createMark()") ;
92 executeMethod("jumpToFurthest()") ;
93 executeMethod("jumpToMark()") ;
94 executeMethod("offsetToMark()") ;
98 oObj
.deleteMark(mark
);
100 } catch(com
.sun
.star
.io
.IOException e
) {
101 log
.println("Couldn't delete mark");
102 e
.printStackTrace(log
);
104 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
105 log
.println("Couldn't delete mark");
106 e
.printStackTrace(log
);
110 tRes
.tested("deleteMark()", res
) ;
114 * Test calls the method. <p>
115 * Has <b> OK </b> status if the method successfully returns
116 * and no exceptions were thrown. <p>
117 * The following method tests are to be completed successfully before :
119 * <li> <code> createMark() </code></li>
122 public void _jumpToFurthest() {
123 requiredMethod("createMark()") ;
127 oObj
.jumpToFurthest() ;
129 } catch (com
.sun
.star
.io
.IOException e
) {
130 log
.println("Couldn't jump to furthest");
131 e
.printStackTrace(log
);
135 tRes
.tested("jumpToFurthest()", res
) ;
139 * Test jumps to mark that was created by method <code>createMark()</code>.
140 * <p>Has <b> OK </b> status if the method successfully returns
141 * and no exceptions were thrown. <p>
142 * The following method tests are to be completed successfully before :
144 * <li> <code> jumpToFurthest() </code> : for the right order of tests
148 public void _jumpToMark() {
149 requiredMethod("jumpToFurthest()") ;
153 oObj
.jumpToMark(mark
) ;
155 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
156 log
.println("Couldn't jump to mark");
157 e
.printStackTrace(log
);
159 } catch(com
.sun
.star
.io
.IOException e
) {
160 log
.println("Couldn't jump to mark");
161 e
.printStackTrace(log
);
165 tRes
.tested("jumpToMark()", res
) ;
169 * Test obtains offset to mark that was created by
170 * method <code>createMark()</code> and checks returned value.<p>
171 * Has <b> OK </b> status if returned value is equal to zero
172 * and no exceptions were thrown. <p>
173 * The following method tests are to be completed successfully before :
175 * <li> <code> jumpToMark() </code> : to have current position at
176 * the mark position </li>
179 public void _offsetToMark() {
181 requiredMethod("jumpToMark()") ;
185 int offset
= oObj
.offsetToMark(mark
);
187 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
188 log
.println("Couldn't get offser to mark");
189 e
.printStackTrace(log
);
191 } catch(com
.sun
.star
.io
.IOException e
) {
192 log
.println("Couldn't get offser to mark");
193 e
.printStackTrace(log
);
197 tRes
.tested("offsetToMark()", res
);