Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _TextSection.java
blob3c756a60f7f06b6c513c5aa6bfd2f52bf0bb5c48
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.MultiPropertyTest;
23 import com.sun.star.text.XTextColumns;
24 import com.sun.star.uno.AnyConverter;
25 import com.sun.star.uno.Type;
27 /**
28 * Testing <code>com.sun.star.text.TextSection</code>
29 * service properties :
30 * <ul>
31 * <li><code> Condition</code></li>
32 * <li><code> IsVisible</code></li>
33 * <li><code> IsProtected</code></li>
34 * <li><code> FileLink</code></li>
35 * <li><code> LinkRegion</code></li>
36 * <li><code> DDECommandType</code></li>
37 * <li><code> DDECommandFile</code></li>
38 * <li><code> DDECommandElement</code></li>
39 * <li><code> BackGraphicURL</code></li>
40 * <li><code> BackGraphicFilter</code></li>
41 * <li><code> BackGraphicLocation</code></li>
42 * <li><code> FootnoteIsCollectAtTextEnd</code></li>
43 * <li><code> FootnoteIsRestartNumbering</code></li>
44 * <li><code> FootnoteRestartNumberingAt</code></li>
45 * <li><code> FootnoteIsOwnNumbering</code></li>
46 * <li><code> FootnoteNumberingType</code></li>
47 * <li><code> FootnoteNumberingPrefix</code></li>
48 * <li><code> FootnoteNumberingSuffix</code></li>
49 * <li><code> EndnoteIsCollectAtTextEnd</code></li>
50 * <li><code> EndnoteIsRestartNumbering</code></li>
51 * <li><code> EndnoteRestartNumberingAt</code></li>
52 * <li><code> EndnoteIsOwnNumbering</code></li>
53 * <li><code> EndnoteNumberingType</code></li>
54 * <li><code> EndnoteNumberingPrefix</code></li>
55 * <li><code> EndnoteNumberingSuffix</code></li>
56 * <li><code> IsAutomaticUpdate</code></li>
57 * </ul> <p>
58 * The following predefined files needed to complete the test:
59 * <ul>
60 * <li> <code>crazy-blue.jpg, space-metal.jpg</code> : are used for
61 * setting 'BackGraphicURL' property. </li>
62 * <ul> <p>
63 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
64 * @see com.sun.star.text.TextSection
66 public class _TextSection extends MultiPropertyTest {
68 /**
69 * Only image file URL can be used as a value.
71 public void _BackGraphicURL() {
72 log.println("Testing with custom Property tester") ;
73 testProperty("BackGraphicURL",
74 util.utils.getFullTestURL("crazy-blue.jpg"),
75 util.utils.getFullTestURL("space-metal.jpg")) ;
78 /**
79 * This property can be void, so if old value is <code> null </code>
80 * new value must be specified.
82 public void _FootnoteNumberingType() {
83 log.println("Testing with custom Property tester") ;
84 testProperty("FootnoteNumberingType",
85 Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT),
86 Short.valueOf(com.sun.star.text.FootnoteNumbering.PER_PAGE)) ;
90 /**
91 * Custom property tester for property <code>TextColumns</code>
93 protected PropertyTester TextColumnsTester = new PropertyTester() {
95 @Override
96 protected Object getNewValue(String propName, Object oldValue) {
97 XTextColumns TC = null;
98 short val2set = 25;
100 TC = (XTextColumns) tEnv.getObjRelation("TC");
101 try {
102 val2set += ((XTextColumns) AnyConverter.toObject(
103 new Type(XTextColumns.class),oldValue)).getColumnCount();
104 } catch (com.sun.star.lang.IllegalArgumentException iae) {
105 log.println("Couldn't change Column count");
107 TC.setColumnCount(val2set);
109 return TC;
112 @Override
113 protected boolean compare(Object obj1, Object obj2) {
114 short val1 = 0;
115 short val2 = 1;
116 try {
117 val1 = ((XTextColumns) AnyConverter.toObject(
118 new Type(XTextColumns.class),obj1)).getColumnCount();
119 val2 = ((XTextColumns) AnyConverter.toObject(
120 new Type(XTextColumns.class),obj2)).getColumnCount();
121 } catch (com.sun.star.lang.IllegalArgumentException iae) {
122 log.println("comparing values failed");
124 return val1 == val2;
127 @Override
128 protected String toString(Object obj) {
129 return "XTextColumns: ColumnCount = "+
130 ((XTextColumns) obj).getColumnCount();
135 public void _TextColumns() {
136 log.println("Testing with custom Property tester");
137 testProperty("TextColumns", TextColumnsTester);
141 } //finish class _TextContent