1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.drawing;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.drawing.XDrawPage;
29 import com.sun.star.drawing.XShape;
30 import com.sun.star.drawing.XShapeCombiner;
31 import com.sun.star.drawing.XShapes;
32 import com.sun.star.uno.UnoRuntime;
33 
34 /**
35 * Testing <code>com.sun.star.drawing.XShapeCombiner</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> combine()</code></li>
39 *  <li><code> split()</code></li>
40 * </ul> <p>
41 * This test needs the following object relations :
42 * <ul>
43 *  <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
44 *   the collection of shapes in a document which used to create a group.</li>
45 * <ul> <p>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.drawing.XShapeCombiner
48 */
49 public class _XShapeCombiner extends MultiMethodTest {
50 
51     public XShapeCombiner oObj = null;           //filled by MultiMethodTest
52     protected XShape oGroup = null;
53     int countBeforeComb = 0;
54     XShapes oShapes = null;
55 
56     /**
57     * Retrieves draw page collection from relation and combines them. <p>
58     * Has <b> OK </b> status if the shape group returned is not null nd
59     * number of shapes in collection is 1 (shapes are combined into a single
60     * shape). <p>
61     */
_combine()62     public void _combine () {
63         XDrawPage dp = (XDrawPage) tEnv.getObjRelation("DrawPage");
64         oShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, dp );
65 
66         boolean result = false;
67 
68         log.println("testing combine() ... ");
69         countBeforeComb = oShapes.getCount();
70         log.println("Count before combining:" + countBeforeComb);
71         oGroup = oObj.combine(oShapes);
72         int countAfterComb = oShapes.getCount();
73         log.println("Count after combining:" + countAfterComb);
74         result = oGroup != null && countAfterComb == 1;
75 
76         tRes.tested("combine()", result);
77     }
78 
79     /**
80     * Splits the group created before. <p>
81     *
82     * Has <b> OK </b> status if number of shapes in collection after
83     * <code>split</code> is the same as before <code>combine</code>. <p>
84     *
85     * The following method tests are to be completed successfully before :
86     * <ul>
87     *  <li> <code> combine() </code> : to create a shape group </li>
88     * </ul>
89     */
_split()90     public void _split() {
91         requiredMethod("combine()");
92 
93         boolean result = false;
94 
95         log.println("spiltting the shape...");
96 
97         oObj.split(oGroup);
98         int countAfterSplit = oShapes.getCount();
99         log.println("Count after split:" + countAfterSplit);
100         result = countAfterSplit == countBeforeComb;
101 
102         tRes.tested("split()", result);
103     } // end of split
104 
105 } // end of XShapeCombiner
106 
107