merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / io / _XMarkableStream.java
blobef343a7b313fe34738da90a29507781fcd455573
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XMarkableStream.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.io;
33 import lib.MultiMethodTest;
35 import com.sun.star.io.XMarkableStream;
37 /**
38 * Testing <code>com.sun.star.io.XMarkableStream</code>
39 * interface methods:
40 * <ul>
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>
46 * </ul> <p>
47 * @see com.sun.star.io.XMarkableStream
49 public class _XMarkableStream extends MultiMethodTest {
51 public XMarkableStream oObj = null;
52 private int mark = -1 ;
54 /**
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() {
60 boolean res;
61 try {
62 mark = oObj.createMark() ;
63 res = mark >= 0;
64 } catch (com.sun.star.io.IOException e) {
65 log.println("Couldn't create mark");
66 e.printStackTrace(log);
67 res = false;
70 tRes.tested("createMark()", res);
73 /**
74 * Test deletes the mark that was created by method <code>createMark()
75 * </code>.<p>
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 :
79 * <ul>
80 * <li> <code> createMark() </code> : to have mark </li>
81 * </ul>
82 * The following method tests are to be executed before :
83 * <ul>
84 * <li> <code> jumpToFurthest() </code></li>
85 * <li> <code> jumpToMark() </code></li>
86 * <li> <code> offsetToMark() </code></li>
87 * </ul>
89 public void _deleteMark() {
90 requiredMethod("createMark()") ;
92 executeMethod("jumpToFurthest()") ;
93 executeMethod("jumpToMark()") ;
94 executeMethod("offsetToMark()") ;
96 boolean res;
97 try {
98 oObj.deleteMark(mark);
99 res = true;
100 } catch(com.sun.star.io.IOException e) {
101 log.println("Couldn't delete mark");
102 e.printStackTrace(log);
103 res = false;
104 } catch(com.sun.star.lang.IllegalArgumentException e) {
105 log.println("Couldn't delete mark");
106 e.printStackTrace(log);
107 res = false;
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 :
118 * <ul>
119 * <li> <code> createMark() </code></li>
120 * </ul>
122 public void _jumpToFurthest() {
123 requiredMethod("createMark()") ;
125 boolean res;
126 try {
127 oObj.jumpToFurthest() ;
128 res = true;
129 } catch (com.sun.star.io.IOException e) {
130 log.println("Couldn't jump to furthest");
131 e.printStackTrace(log);
132 res = false;
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 :
143 * <ul>
144 * <li> <code> jumpToFurthest() </code> : for the right order of tests
145 * excecution </li>
146 * </ul>
148 public void _jumpToMark() {
149 requiredMethod("jumpToFurthest()") ;
150 boolean res;
152 try {
153 oObj.jumpToMark(mark) ;
154 res = true;
155 } catch(com.sun.star.lang.IllegalArgumentException e) {
156 log.println("Couldn't jump to mark");
157 e.printStackTrace(log);
158 res = false;
159 } catch(com.sun.star.io.IOException e) {
160 log.println("Couldn't jump to mark");
161 e.printStackTrace(log);
162 res = false;
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 :
174 * <ul>
175 * <li> <code> jumpToMark() </code> : to have current position at
176 * the mark position </li>
177 * </ul>
179 public void _offsetToMark() {
181 requiredMethod("jumpToMark()") ;
183 boolean res;
184 try {
185 int offset = oObj.offsetToMark(mark);
186 res = offset == 0;
187 } catch(com.sun.star.lang.IllegalArgumentException e) {
188 log.println("Couldn't get offser to mark");
189 e.printStackTrace(log);
190 res = false;
191 } catch(com.sun.star.io.IOException e) {
192 log.println("Couldn't get offser to mark");
193 e.printStackTrace(log);
194 res = false;
197 tRes.tested("offsetToMark()", res);