tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XTextRange.java
blob033f870007af931f325465eb2d65ec63a46dffbc
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 .
18 package ifc.text;
20 import lib.MultiMethodTest;
22 import com.sun.star.text.XText;
23 import com.sun.star.text.XTextRange;
26 /**
27 * Testing <code>com.sun.star.text.XTextRange</code>
28 * interface methods :
29 * <ul>
30 * <li><code> getText()</code></li>
31 * <li><code> getStart()</code></li>
32 * <li><code> getEnd()</code></li>
33 * <li><code> getString()</code></li>
34 * <li><code> setString()</code></li>
35 * </ul> <p>
36 * First the content is set to 'Middle' string value, then
37 * start range is retrieved and its content is set to 'Start'
38 * and end range is set to 'End'. Finally the whole TextRange
39 * is checked and it must be 'StartMiddleEnd'. <p>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 * @see com.sun.star.text.XTextRange
43 public class _XTextRange extends MultiMethodTest {
45 public XTextRange oObj = null; // oObj is filled by setField()
46 // in MultiMethodTest
47 XTextRange oStartRange = null; // startrange of textrang
48 XTextRange oEndRange = null; // endrange of textrang
50 /**
51 * Retrieves the start range and sets its context to
52 * 'Start' string. <p>
53 * Has <b>OK</b> status if the whole range string starts
54 * with 'Start' substring. <p>
55 * The following method tests are to be completed successfully before :
56 * <ul>
57 * <li> <code> setString </code> </li>
58 * </ul>
60 public void _getStart() {
62 XText the_text = (XText) tEnv.getObjRelation("XTEXT");
64 if (the_text != null) {
65 the_text.setString("");
68 String exp="";
70 oObj.setString("MiddleEnd");
72 oStartRange = oObj.getStart();
73 oStartRange.setString("Start");
75 if (the_text !=null) {
76 exp = the_text.getString();
77 } else exp = oObj.getText().getString();
79 log.println("Start: "+exp);
81 tRes.tested( "getStart()", exp.startsWith("Start"));
83 oStartRange.setString("");
87 /**
88 * Retrieves the end range and sets its context to
89 * 'End' string. <p>
90 * Has <b>OK</b> status if the whole range string ends
91 * with 'End' substring. <p>
92 * The following method tests are to be completed successfully before :
93 * <ul>
94 * <li> <code> setString </code> </li>
95 * </ul>
97 public void _getEnd() {
98 XText the_text = (XText) tEnv.getObjRelation("XTEXT");
100 if (the_text != null) {
101 the_text.setString("");
104 String exp="";
105 oObj.setString("StartMiddle");
107 oEndRange = oObj.getEnd();
108 oEndRange.setString("End");
110 if (the_text !=null) {
111 exp = the_text.getString();
112 } else exp = oObj.getText().getString();
114 log.println("End: "+exp);
116 tRes.tested( "getEnd()", exp.endsWith("End"));
118 oEndRange.setString("");
122 * Gets the text of the range and retrieves its String content. <p>
123 * Has <b>OK</b> status if the string returned equals to
124 * 'StartMiddleEnd' value. <p>
125 * The following method tests are to be completed successfully before :
126 * <ul>
127 * <li> <code> setString </code> to get finally the string expected.</li>
128 * <li> <code> getStart </code> to get finally the string expected.</li>
129 * <li> <code> getEnd </code> to get finally the string expected.</li>
130 * </ul>
132 public void _getText() {
133 requiredMethod("setString()");
134 requiredMethod("getStart()");
135 requiredMethod("getEnd()");
137 XText txt = oObj.getText() ;
139 tRes.tested( "getText()", txt != null &&
140 txt.getString().equals("StartMiddle"));
144 * Gets the String of the range. <p>
145 * Has <b>OK</b> status if the string returned equals to
146 * 'StartMiddleEnd' value. <p>
148 public void _getString() {
150 oObj.setString("StartMiddleEnd");
151 String gStr = oObj.getString() ;
153 tRes.tested( "getString()", gStr != null &&
154 gStr.equals("StartMiddleEnd"));
159 * Sets the string content of the range to 'Middle' value. <p>
160 * Has <b>OK</b> status if <code>getString</code> method returns
161 * 'Middle' value.
163 public void _setString() {
164 oObj.setString("Middle") ;
166 tRes.tested("setString()", "Middle".equals(oObj.getString())) ;