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