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 .
21 import com
.sun
.star
.form
.XForm
;
22 import com
.sun
.star
.form
.runtime
.XFormController
;
23 import lib
.MultiMethodTest
;
25 import com
.sun
.star
.view
.XFormLayerAccess
;
27 import lib
.StatusException
;
31 * Testing <code>com.sun.star.view.XFormLayerAccess</code>
34 * <li><code> getFromController()</code></li>
35 * <li><code> isFormDesignMode()</code></li>
36 * <li><code> setFormDesignMode()</code></li>
39 * Test is <b> NOT </b> multithread compilant. <p>
40 * @see com.sun.star.view.XFormLayerAccess
42 public class _XFormLayerAccess
extends MultiMethodTest
{
44 // oObj filled by MultiMethodTest
46 public XFormLayerAccess oObj
= null;
48 private XForm xForm
= null;
51 * checks if the object relation <CODE>XFormLayerAccess.XForm</CODE>
54 public void before() {
55 xForm
= (XForm
) tEnv
.getObjRelation("XFormLayerAccess.XForm");
57 throw new StatusException(Status
.failed("Object raltion 'XFormLayerAccess.XForm' is null"));
62 * Test disables the FormDesignMode and calls the mthod. <p>
63 * Has <b> OK </b> status if the method returns
64 * a not empty object of kind of com.sun.star.form.XFormController<P>
65 * The following method tests are to be completed successfully before :
67 * <li> <code> setFormDesignMode() </code></li>
69 * @see com.sun.star.view.XFormLayerAccess
71 public void _getFromController(){
72 requiredMethod("setFormDesignMode()") ;
74 log
.println("try to get current DesignMode...");
75 boolean currentMode
= oObj
.isFormDesignMode();
76 log
.println("DesignMode is " + currentMode
);
78 log
.println("enable DesignMode");
79 oObj
.setFormDesignMode(false);
81 log
.println("test for getFromController() ");
82 XFormController xFormCont
= oObj
.getFormController(xForm
);
84 if (xFormCont
== null)
85 log
.println("ERROR: Could not get FromContoller");
87 log
.println("set back DesignMode to previouse state");
88 oObj
.setFormDesignMode(currentMode
);
90 tRes
.tested("getFromController()", xFormCont
!= null );
94 * This test calls the test for <code>setFormDesignMode()</CODE>.
95 * Has <b> OK </b> status if the test for setFormDesignMode() returns
96 * <code>true</code> since the tests use <CODE>isFormDesignMode()</CODE><P>
97 * The following method tests are to be completed successfully before :
99 * <li> <code> setFormDesignMode() </code></li>
102 public void _isFormDesignMode(){
103 requiredMethod("setFormDesignMode()") ;
105 log
.println("test for isFormDesignMode() is ok since test for 'setFormDesingMode()' use it");
106 tRes
.tested("isFormDesignMode()", true);
110 * This test gets the current FormDesignMode, change it to the opposite and checks if the expected value of
111 * method isFormDesignmode() was given. Then the FormDesignmode was set back to the original value.<P>
112 * Has <B> OK </B> if expected values are returned.
116 public void _setFormDesignMode(){
117 log
.println("test for setFormDesignMode() and isFormDesignMode() ");
119 log
.println("try to get current DesignMode...");
120 boolean currentMode
= oObj
.isFormDesignMode();
121 log
.println("DesignMode is " + currentMode
);
123 log
.println("try to change to " + !currentMode
+ "...");
124 oObj
.setFormDesignMode(!currentMode
);
125 log
.println("try to get new DesignMode...");
126 boolean newMode
= oObj
.isFormDesignMode();
127 log
.println("DesignMode is " + newMode
);
129 boolean bOK
= (newMode
!= currentMode
);
132 log
.println("ERROR: both modes are equal");
134 log
.println("set back DesignMode to " + currentMode
);
135 oObj
.setFormDesignMode(currentMode
);
137 log
.println("try to get DesignMode...");
138 boolean oldMode
= oObj
.isFormDesignMode();
140 bOK
&= (bOK
&(currentMode
== oldMode
));
142 if (currentMode
!= oldMode
)
143 log
.println("ERROR: could not change back");
145 tRes
.tested("setFormDesignMode()", bOK
);
148 } // finish class _XFormLayerAccess