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.frame;
25 
26 import com.sun.star.awt.Point;
27 import com.sun.star.frame.XFrame;
28 import com.sun.star.frame.XLayoutManager;
29 import com.sun.star.awt.Rectangle;
30 import com.sun.star.awt.Size;
31 import com.sun.star.ui.DockingArea;
32 import com.sun.star.ui.XUIElement;
33 import lib.MultiMethodTest;
34 import util.utils;
35 
36 public class _XLayoutManager extends MultiMethodTest {
37     public XLayoutManager oObj = null;
38 
39     private XFrame xFrame = null;
40     private String sElementName = "private:resource/menubar/myMenu";
41 
before()42     public void before() {
43         xFrame = (XFrame)tEnv.getObjRelation("XLayoutManager.Frame");
44     }
45 
_attachFrame()46     public void _attachFrame() {
47         oObj.attachFrame(xFrame);
48         tRes.tested("attachFrame()", true);
49     }
50 
_createElement()51     public void _createElement() {
52         requiredMethod("attachFrame()");
53         oObj.createElement(sElementName);
54         tRes.tested("createElement()", true);
55     }
56 
_destroyElement()57     public void _destroyElement() {
58         requiredMethod("getElement()");
59         requiredMethod("getElements()");
60         oObj.destroyElement(sElementName);
61         tRes.tested("destroyElement()", true);
62     }
63 
_doLayout()64     public void _doLayout() {
65         oObj.doLayout();
66         tRes.tested("doLayout()", true);
67     }
68 
_dockWindow()69     public void _dockWindow() {
70         requiredMethod("createElement()");
71         Point p = new Point();
72         p.X = 0;
73         p.Y = 0;
74         oObj.dockWindow(sElementName, DockingArea.DOCKINGAREA_TOP, p);
75         tRes.tested("dockWindow()", true);
76     }
77 
_floatWindow()78     public void _floatWindow() {
79         requiredMethod("createElement()");
80         oObj.floatWindow(sElementName);
81         tRes.tested("floatWindow()", true);
82     }
83 
_getCurrentDockingArea()84     public void _getCurrentDockingArea() {
85         requiredMethod("attachFrame()");
86         Rectangle rect = oObj.getCurrentDockingArea();
87         tRes.tested("getCurrentDockingArea()", rect != null);
88     }
89 
_getElement()90     public void _getElement() {
91         requiredMethod("createElement()");
92         XUIElement xElement = oObj.getElement(sElementName);
93         tRes.tested("getElement()", true);
94     }
95 
_getElementPos()96     public void _getElementPos() {
97         Point p = oObj.getElementPos(sElementName);
98         tRes.tested("getElementPos()", p != null);
99     }
100 
_getElementSize()101     public void _getElementSize() {
102         Size s = oObj.getElementSize(sElementName);
103         tRes.tested("getElementSize()", s != null);
104     }
105 
_getElements()106     public void _getElements() {
107         requiredMethod("createElement()");
108         XUIElement[] xElements = oObj.getElements();
109         for (int i=0; i<xElements.length; i++) {
110             Object o = xElements[i].getRealInterface();
111             log.println("Element " + i + ": " + o.toString() + "         " + utils.getImplName(o));
112         }
113         tRes.tested("getElements()", xElements != null);
114     }
115 
_hideElement()116     public void _hideElement() {
117         boolean hidden = oObj.hideElement(sElementName);
118         tRes.tested("hideElement()", true);
119     }
120 
_isElementDocked()121     public void _isElementDocked() {
122         boolean docked = oObj.isElementDocked(sElementName);
123         tRes.tested("isElementDocked()", true);
124     }
125 
_isElementFloating()126     public void _isElementFloating() {
127         boolean docked = oObj.isElementFloating(sElementName);
128         tRes.tested("isElementFloating()", true);
129     }
130 
_isElementVisible()131     public void _isElementVisible() {
132         boolean docked = oObj.isElementVisible(sElementName);
133         tRes.tested("isElementVisible()", true);
134     }
135 
_lock()136     public void _lock() {
137         oObj.lock();
138         tRes.tested("lock()", true);
139     }
140 
_reset()141     public void _reset() {
142         oObj.reset();
143         tRes.tested("reset()", true);
144     }
145 
_setDockingAreaAcceptor()146     public void _setDockingAreaAcceptor() {
147         oObj.setDockingAreaAcceptor(null);
148         tRes.tested("setDockingAreaAcceptor()", true);
149     }
150 
_setElementPos()151     public void _setElementPos() {
152         requiredMethod("createElement()");
153         Point p = new Point();
154         p.X = 0;
155         p.Y = 150;
156         oObj.setElementPos(sElementName, p);
157         tRes.tested("setElementPos()", true);
158     }
159 
_setElementPosSize()160     public void _setElementPosSize() {
161         requiredMethod("createElement()");
162         Point p = new Point();
163         p.X = 150;
164         p.Y = 0;
165         Size size = new Size();
166         size.Height = 50;
167         size.Width = 80;
168         oObj.setElementPosSize(sElementName, p, size);
169         tRes.tested("setElementPosSize()", true);
170     }
171 
_setElementSize()172     public void _setElementSize() {
173         requiredMethod("createElement()");
174         Size size = new Size();
175         size.Height = 80;
176         size.Width = 50;
177         oObj.setElementSize(sElementName, size);
178         tRes.tested("setElementSize()", true);
179     }
180 
_showElement()181     public void _showElement() {
182         requiredMethod("createElement()");
183         boolean shown = oObj.showElement(sElementName);
184         tRes.tested("showElement()", true);
185 
186     }
187 
_unlock()188     public void _unlock() {
189         requiredMethod("lock()");
190         oObj.unlock();
191         tRes.tested("unlock()", true);
192     }
193 
194 }
195