tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XTextRangeMover.java
blobaffdb6ce889208facc6a206ccb97616321430488
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.text;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.text.XTextRange;
26 import com.sun.star.text.XTextRangeMover;
28 /**
29 * Testing <code>com.sun.star.text.XTextRangeMover</code>
30 * interface methods :
31 * <ul>
32 * <li><code> moveTextRange()</code></li>
33 * </ul> <p>
34 * This test needs the following object relations :
35 * <ul>
36 * <li> <code>'RangeForMove'</code> (of type <code>XTextRange</code>):
37 * the range to be moved. </li>
38 * <li> <code>'XTextRange'</code> (of type <code>XTextRange</code>):
39 * the range that includes moving range. </li>
40 * <ul> <p>
41 * Test is <b> NOT </b> multithread compliant. <p>
42 * @see com.sun.star.text.XTextRangeMover
44 public class _XTextRangeMover extends MultiMethodTest {
46 public XTextRangeMover oObj = null;
48 XTextRange xTextRange = null;
49 XTextRange oMoveRange = null;
51 /**
52 * Moves the range obtained from relation 'RangeForMove' by 1 paragraph
53 * and compares index of moved string in the whole text obtained
54 * from relation 'XTextRange'. <p>
55 * Has <b>OK</b> status if index of moved range is changed after method call.
57 public void _moveTextRange(){
58 oMoveRange = (XTextRange) tEnv.getObjRelation("RangeForMove");
59 xTextRange = (XTextRange) tEnv.getObjRelation("XTextRange");
61 if (oMoveRange == null) {
62 throw new StatusException(
63 Status.failed("Couldn't get relation 'RangeForMove'"));
66 if (xTextRange == null) {
67 throw new StatusException(
68 Status.failed("Couldn't get relation 'XTextRange'"));
71 log.println("Content before moving:");
72 log.println(xTextRange.getString());
73 log.println("Text range for moving:");
74 log.println(oMoveRange.getString());
75 int indexBefore = xTextRange.getString().indexOf(oMoveRange.getString());
76 oObj.moveTextRange(oMoveRange,(short) 1);
77 log.println("Content after moving:");
78 log.println(xTextRange.getString());
79 int indexAfter = xTextRange.getString().indexOf(oMoveRange.getString());
81 boolean res = indexBefore != indexAfter;
82 log.println("Index before moving:" + indexBefore);
83 log.println("Index after moving:" + indexAfter);
85 tRes.tested("moveTextRange()", res);