Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _TextGraphicObject.java
bloba9edbaa6a2eff01e438129e846edb6433dbb3987
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 com.sun.star.awt.Point;
21 import com.sun.star.container.XIndexContainer;
22 import com.sun.star.uno.UnoRuntime;
24 import java.util.Random;
26 import lib.MultiPropertyTest;
28 import util.utils;
31 /**
32 * Testing <code>com.sun.star.text.TextGraphicObject</code>
33 * service properties :
34 * <ul>
35 * <li><code> ImageMap</code></li>
36 * <li><code> ContentProtected</code></li>
37 * <li><code> SurroundContour</code></li>
38 * <li><code> ContourOutside</code></li>
39 * <li><code> ContourPolyPolygon</code></li>
40 * <li><code> GraphicCrop</code></li>
41 * <li><code> HoriMirroredOnEvenPages</code></li>
42 * <li><code> HoriMirroredOnOddPages</code></li>
43 * <li><code> VertMirrored</code></li>
44 * <li><code> GraphicURL</code></li>
45 * <li><code> GraphicFilter</code></li>
46 * <li><code> ActualSize</code></li>
47 * <li><code> AdjustLuminance</code></li>
48 * <li><code> AdjustContrast</code></li>
49 * <li><code> AdjustRed</code></li>
50 * <li><code> AdjustGreen</code></li>
51 * <li><code> AdjustBlue</code></li>
52 * <li><code> Gamma</code></li>
53 * <li><code> GraphicIsInverted</code></li>
54 * <li><code> Transparency</code></li>
55 * <li><code> GraphicColorMode</code></li>
56 * </ul> <p>
57 * This test needs the following object relations :
58 * <ul>
59 * <li> <code>'ImageMap'</code> (an inmplementation of
60 * <code>com.sun.star.image.ImageMapObject</code>):
61 * is used to insert a new Map into collection
62 * from 'ImageMap' property. </li>
63 * <ul> <p>
64 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
65 * @see com.sun.star.text.TextGraphicObject
67 public class _TextGraphicObject extends MultiPropertyTest {
68 public Random rdm = new Random();
70 /**
71 * The tester which can change a sequence of <code>Point</code>'s
72 * or create a new one if necessary.
74 protected PropertyTester PointTester = new PropertyTester() {
75 @Override
76 protected Object getNewValue(String propName, Object oldValue)
77 throws java.lang.IllegalArgumentException {
78 if (utils.isVoid(oldValue)) {
79 return newPoint();
80 } else {
81 return changePoint((Point[][]) oldValue);
86 /**
87 * Tested with custom <code>PointTester</code>.
89 public void _ContourPolyPolygon() {
90 log.println("Testing with custom Property tester");
91 testProperty("ContourPolyPolygon", PointTester);
94 /**
95 * Retrieves an ImageMap from relation and inserts it to the collection
96 * obtained as property value. Then this collection is set back.
97 * After that property value is get again. The number of elements
98 * in the old collection and in just gotten collection is checked.
100 * Has <b>OK</b> status if the number of elements in the new obtained
101 * collection is greater than in old one.
103 public void _ImageMap() {
104 boolean result = true;
106 try {
107 XIndexContainer imgMap = UnoRuntime.queryInterface(
108 XIndexContainer.class,
109 oObj.getPropertyValue("ImageMap"));
110 int previous = imgMap.getCount();
111 log.println("Count (previous) " + previous);
113 Object im = tEnv.getObjRelation("IMGMAP");
114 imgMap.insertByIndex(0, im);
115 oObj.setPropertyValue("ImageMap", imgMap);
116 imgMap = UnoRuntime.queryInterface(
117 XIndexContainer.class,
118 oObj.getPropertyValue("ImageMap"));
120 int after = imgMap.getCount();
121 log.println("Count (after) " + after);
122 result = previous < after;
123 } catch (Exception ex) {
124 result = false;
127 tRes.tested("ImageMap", result);
131 * Creates a new random points sequence.
133 public Point[][] newPoint() {
134 Point[][] res = new Point[1][185];
136 for (int i = 0; i < res[0].length; i++) {
137 res[0][i] = new Point();
138 res[0][i].X = rd() * rd() * rd();
139 res[0][i].Y = rd() * rd() * rd();
142 return res;
145 public int rd() {
146 return rdm.nextInt(6);
150 * Changes the existing point sequence.
152 public Point[][] changePoint(Point[][] oldPoint) {
153 Point[][] res = oldPoint;
155 for (int i = 0; i < res[0].length; i++) {
156 res[0][i].X += 1;
157 res[0][i].Y += 1;
160 return res;
162 } // finish class _TextGraphicObject