xref: /AOO41X/main/qadevOOo/tests/java/ifc/io/_XMarkableStream.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package ifc.io;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import lib.MultiMethodTest;
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir import com.sun.star.io.XMarkableStream;
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /**
35*cdf0e10cSrcweir * Testing <code>com.sun.star.io.XMarkableStream</code>
36*cdf0e10cSrcweir * interface methods:
37*cdf0e10cSrcweir * <ul>
38*cdf0e10cSrcweir *   <li><code>createMark()</code></li>
39*cdf0e10cSrcweir *   <li><code>deleteMark()</code></li>
40*cdf0e10cSrcweir *   <li><code>jumpToFurthest()</code></li>
41*cdf0e10cSrcweir *   <li><code>jumpToMark()</code></li>
42*cdf0e10cSrcweir *   <li><code>offsetToMark()</code></li>
43*cdf0e10cSrcweir * </ul> <p>
44*cdf0e10cSrcweir * @see com.sun.star.io.XMarkableStream
45*cdf0e10cSrcweir */
46*cdf0e10cSrcweir public class _XMarkableStream extends MultiMethodTest {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     public XMarkableStream oObj = null;
49*cdf0e10cSrcweir     private int mark = -1 ;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     /**
52*cdf0e10cSrcweir     * Test creates mark and stores it. <p>
53*cdf0e10cSrcweir     * Has <b> OK </b> status if no exceptions were thrown
54*cdf0e10cSrcweir     * and returned isn't less than zero. <p>
55*cdf0e10cSrcweir     */
56*cdf0e10cSrcweir     public void _createMark() {
57*cdf0e10cSrcweir         boolean res;
58*cdf0e10cSrcweir         try {
59*cdf0e10cSrcweir             mark = oObj.createMark() ;
60*cdf0e10cSrcweir             res = mark >= 0;
61*cdf0e10cSrcweir         } catch (com.sun.star.io.IOException e) {
62*cdf0e10cSrcweir             log.println("Couldn't create mark");
63*cdf0e10cSrcweir             e.printStackTrace(log);
64*cdf0e10cSrcweir             res = false;
65*cdf0e10cSrcweir         }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir         tRes.tested("createMark()", res);
68*cdf0e10cSrcweir     }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     /**
71*cdf0e10cSrcweir     * Test deletes the mark that was created by method <code>createMark()
72*cdf0e10cSrcweir     * </code>.<p>
73*cdf0e10cSrcweir     * Has <b> OK </b> status if the method successfully returns
74*cdf0e10cSrcweir     * and no exceptions were thrown. <p>
75*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
76*cdf0e10cSrcweir     * <ul>
77*cdf0e10cSrcweir     *  <li> <code> createMark() </code> : to have mark </li>
78*cdf0e10cSrcweir     * </ul>
79*cdf0e10cSrcweir     * The following method tests are to be executed before :
80*cdf0e10cSrcweir     * <ul>
81*cdf0e10cSrcweir     *  <li> <code> jumpToFurthest() </code></li>
82*cdf0e10cSrcweir     *  <li> <code> jumpToMark() </code></li>
83*cdf0e10cSrcweir     *  <li> <code> offsetToMark() </code></li>
84*cdf0e10cSrcweir     * </ul>
85*cdf0e10cSrcweir     */
86*cdf0e10cSrcweir     public void _deleteMark() {
87*cdf0e10cSrcweir         requiredMethod("createMark()") ;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir         executeMethod("jumpToFurthest()") ;
90*cdf0e10cSrcweir         executeMethod("jumpToMark()") ;
91*cdf0e10cSrcweir         executeMethod("offsetToMark()") ;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         boolean res;
94*cdf0e10cSrcweir         try {
95*cdf0e10cSrcweir             oObj.deleteMark(mark);
96*cdf0e10cSrcweir             res = true;
97*cdf0e10cSrcweir         } catch(com.sun.star.io.IOException e) {
98*cdf0e10cSrcweir             log.println("Couldn't delete mark");
99*cdf0e10cSrcweir             e.printStackTrace(log);
100*cdf0e10cSrcweir             res = false;
101*cdf0e10cSrcweir         } catch(com.sun.star.lang.IllegalArgumentException e) {
102*cdf0e10cSrcweir             log.println("Couldn't delete mark");
103*cdf0e10cSrcweir             e.printStackTrace(log);
104*cdf0e10cSrcweir             res = false;
105*cdf0e10cSrcweir         }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir         tRes.tested("deleteMark()", res) ;
108*cdf0e10cSrcweir     }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir     /**
111*cdf0e10cSrcweir     * Test calls the method. <p>
112*cdf0e10cSrcweir     * Has <b> OK </b> status if the method successfully returns
113*cdf0e10cSrcweir     * and no exceptions were thrown. <p>
114*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
115*cdf0e10cSrcweir     * <ul>
116*cdf0e10cSrcweir     *  <li> <code> createMark() </code></li>
117*cdf0e10cSrcweir     * </ul>
118*cdf0e10cSrcweir     */
119*cdf0e10cSrcweir     public void _jumpToFurthest() {
120*cdf0e10cSrcweir         requiredMethod("createMark()") ;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         boolean res;
123*cdf0e10cSrcweir         try {
124*cdf0e10cSrcweir             oObj.jumpToFurthest() ;
125*cdf0e10cSrcweir             res = true;
126*cdf0e10cSrcweir         } catch (com.sun.star.io.IOException e) {
127*cdf0e10cSrcweir             log.println("Couldn't jump to furthest");
128*cdf0e10cSrcweir             e.printStackTrace(log);
129*cdf0e10cSrcweir             res = false;
130*cdf0e10cSrcweir         }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         tRes.tested("jumpToFurthest()", res) ;
133*cdf0e10cSrcweir     }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     /**
136*cdf0e10cSrcweir     * Test jumps to mark that was created by method <code>createMark()</code>.
137*cdf0e10cSrcweir     * <p>Has <b> OK </b> status if the method successfully returns
138*cdf0e10cSrcweir     * and no exceptions were thrown. <p>
139*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
140*cdf0e10cSrcweir     * <ul>
141*cdf0e10cSrcweir     *  <li> <code> jumpToFurthest() </code> : for the right order of tests
142*cdf0e10cSrcweir     *  excecution </li>
143*cdf0e10cSrcweir     * </ul>
144*cdf0e10cSrcweir     */
145*cdf0e10cSrcweir     public void _jumpToMark() {
146*cdf0e10cSrcweir         requiredMethod("jumpToFurthest()") ;
147*cdf0e10cSrcweir         boolean res;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         try {
150*cdf0e10cSrcweir             oObj.jumpToMark(mark) ;
151*cdf0e10cSrcweir             res = true;
152*cdf0e10cSrcweir         } catch(com.sun.star.lang.IllegalArgumentException e) {
153*cdf0e10cSrcweir             log.println("Couldn't jump to mark");
154*cdf0e10cSrcweir             e.printStackTrace(log);
155*cdf0e10cSrcweir             res = false;
156*cdf0e10cSrcweir         } catch(com.sun.star.io.IOException e) {
157*cdf0e10cSrcweir             log.println("Couldn't jump to mark");
158*cdf0e10cSrcweir             e.printStackTrace(log);
159*cdf0e10cSrcweir             res = false;
160*cdf0e10cSrcweir         }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         tRes.tested("jumpToMark()", res) ;
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     /**
166*cdf0e10cSrcweir     * Test obtains offset to mark that was created by
167*cdf0e10cSrcweir     * method <code>createMark()</code> and checks returned value.<p>
168*cdf0e10cSrcweir     * Has <b> OK </b> status if returned value is equal to zero
169*cdf0e10cSrcweir     * and no exceptions were thrown. <p>
170*cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
171*cdf0e10cSrcweir     * <ul>
172*cdf0e10cSrcweir     *  <li> <code> jumpToMark() </code> : to have current position at
173*cdf0e10cSrcweir     *  the mark position </li>
174*cdf0e10cSrcweir     * </ul>
175*cdf0e10cSrcweir     */
176*cdf0e10cSrcweir     public void _offsetToMark() {
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         requiredMethod("jumpToMark()") ;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         boolean res;
181*cdf0e10cSrcweir         try {
182*cdf0e10cSrcweir             int offset = oObj.offsetToMark(mark);
183*cdf0e10cSrcweir             res = offset == 0;
184*cdf0e10cSrcweir         } catch(com.sun.star.lang.IllegalArgumentException e) {
185*cdf0e10cSrcweir             log.println("Couldn't get offser to mark");
186*cdf0e10cSrcweir             e.printStackTrace(log);
187*cdf0e10cSrcweir             res = false;
188*cdf0e10cSrcweir         } catch(com.sun.star.io.IOException e) {
189*cdf0e10cSrcweir             log.println("Couldn't get offser to mark");
190*cdf0e10cSrcweir             e.printStackTrace(log);
191*cdf0e10cSrcweir             res = false;
192*cdf0e10cSrcweir         }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir         tRes.tested("offsetToMark()", res);
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198