Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / io / _XMarkableStream.java
blobd4cb74ecc7b4fe5c57576c4b770f7d2fedda7a42
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.io;
21 import lib.MultiMethodTest;
23 import com.sun.star.io.XMarkableStream;
25 /**
26 * Testing <code>com.sun.star.io.XMarkableStream</code>
27 * interface methods:
28 * <ul>
29 * <li><code>createMark()</code></li>
30 * <li><code>deleteMark()</code></li>
31 * <li><code>jumpToFurthest()</code></li>
32 * <li><code>jumpToMark()</code></li>
33 * <li><code>offsetToMark()</code></li>
34 * </ul> <p>
35 * @see com.sun.star.io.XMarkableStream
37 public class _XMarkableStream extends MultiMethodTest {
39 public XMarkableStream oObj = null;
40 private int mark = -1 ;
42 /**
43 * Test creates mark and stores it. <p>
44 * Has <b> OK </b> status if no exceptions were thrown
45 * and returned isn't less than zero. <p>
47 public void _createMark() {
48 boolean res;
49 try {
50 mark = oObj.createMark() ;
51 res = mark >= 0;
52 } catch (com.sun.star.io.IOException e) {
53 log.println("Couldn't create mark");
54 e.printStackTrace(log);
55 res = false;
58 tRes.tested("createMark()", res);
61 /**
62 * Test deletes the mark that was created by method <code>createMark()
63 * </code>.<p>
64 * Has <b> OK </b> status if the method successfully returns
65 * and no exceptions were thrown. <p>
66 * The following method tests are to be completed successfully before :
67 * <ul>
68 * <li> <code> createMark() </code> : to have mark </li>
69 * </ul>
70 * The following method tests are to be executed before :
71 * <ul>
72 * <li> <code> jumpToFurthest() </code></li>
73 * <li> <code> jumpToMark() </code></li>
74 * <li> <code> offsetToMark() </code></li>
75 * </ul>
77 public void _deleteMark() {
78 requiredMethod("createMark()") ;
80 executeMethod("jumpToFurthest()") ;
81 executeMethod("jumpToMark()") ;
82 executeMethod("offsetToMark()") ;
84 boolean res;
85 try {
86 oObj.deleteMark(mark);
87 res = true;
88 } catch(com.sun.star.io.IOException e) {
89 log.println("Couldn't delete mark");
90 e.printStackTrace(log);
91 res = false;
92 } catch(com.sun.star.lang.IllegalArgumentException e) {
93 log.println("Couldn't delete mark");
94 e.printStackTrace(log);
95 res = false;
98 tRes.tested("deleteMark()", res) ;
102 * Test calls the method. <p>
103 * Has <b> OK </b> status if the method successfully returns
104 * and no exceptions were thrown. <p>
105 * The following method tests are to be completed successfully before :
106 * <ul>
107 * <li> <code> createMark() </code></li>
108 * </ul>
110 public void _jumpToFurthest() {
111 requiredMethod("createMark()") ;
113 boolean res;
114 try {
115 oObj.jumpToFurthest() ;
116 res = true;
117 } catch (com.sun.star.io.IOException e) {
118 log.println("Couldn't jump to furthest");
119 e.printStackTrace(log);
120 res = false;
123 tRes.tested("jumpToFurthest()", res) ;
127 * Test jumps to mark that was created by method <code>createMark()</code>.
128 * <p>Has <b> OK </b> status if the method successfully returns
129 * and no exceptions were thrown. <p>
130 * The following method tests are to be completed successfully before :
131 * <ul>
132 * <li> <code> jumpToFurthest() </code> : for the right order of tests
133 * execution </li>
134 * </ul>
136 public void _jumpToMark() {
137 requiredMethod("jumpToFurthest()") ;
138 boolean res;
140 try {
141 oObj.jumpToMark(mark) ;
142 res = true;
143 } catch(com.sun.star.lang.IllegalArgumentException e) {
144 log.println("Couldn't jump to mark");
145 e.printStackTrace(log);
146 res = false;
147 } catch(com.sun.star.io.IOException e) {
148 log.println("Couldn't jump to mark");
149 e.printStackTrace(log);
150 res = false;
153 tRes.tested("jumpToMark()", res) ;
157 * Test obtains offset to mark that was created by
158 * method <code>createMark()</code> and checks returned value.<p>
159 * Has <b> OK </b> status if returned value is equal to zero
160 * and no exceptions were thrown. <p>
161 * The following method tests are to be completed successfully before :
162 * <ul>
163 * <li> <code> jumpToMark() </code> : to have current position at
164 * the mark position </li>
165 * </ul>
167 public void _offsetToMark() {
169 requiredMethod("jumpToMark()") ;
171 boolean res;
172 try {
173 int offset = oObj.offsetToMark(mark);
174 res = offset == 0;
175 } catch(com.sun.star.lang.IllegalArgumentException e) {
176 log.println("Couldn't get offser to mark");
177 e.printStackTrace(log);
178 res = false;
179 } catch(com.sun.star.io.IOException e) {
180 log.println("Couldn't get offser to mark");
181 e.printStackTrace(log);
182 res = false;
185 tRes.tested("offsetToMark()", res);