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.view; 25 26 import com.sun.star.form.XForm; 27 import com.sun.star.form.runtime.XFormController; 28 import lib.MultiMethodTest; 29 30 import com.sun.star.view.XFormLayerAccess; 31 import lib.Status; 32 import lib.StatusException; 33 34 35 /** 36 * Testing <code>com.sun.star.view.XFormLayerAccess</code> 37 * interface methods : 38 * <ul> 39 * <li><code> getFromController()</code></li> 40 * <li><code> isFormDesignMode()</code></li> 41 * <li><code> setFormDesignMode()</code></li> 42 * </ul> <p> 43 * 44 * Test is <b> NOT </b> multithread compilant. <p> 45 * @see com.sun.star.view.XFormLayerAccess 46 */ 47 public class _XFormLayerAccess extends MultiMethodTest { 48 49 // oObj filled by MultiMethodTest 50 51 public XFormLayerAccess oObj = null; 52 53 private XForm xForm = null; 54 55 /** 56 * checks if the object relation <CODE>XFormLayerAccess.XForm</CODE> 57 * is available 58 */ before()59 public void before() { 60 xForm = (XForm) tEnv.getObjRelation("XFormLayerAccess.XForm"); 61 if (xForm == null) { 62 throw new StatusException(Status.failed("Object raltion 'XFormLayerAccess.XForm' is null")); 63 } 64 } 65 66 /** 67 * Test disables the FormDesignMode and calls the mthod. <p> 68 * Has <b> OK </b> status if the method returns 69 * a not empty object of kind of com.sun.star.form.XFormController<P> 70 * The following method tests are to be completed successfully before : 71 * <ul> 72 * <li> <code> setFormDesignMode() </code></li> 73 * </ul> 74 * @see com.sun.star.view.XFormLayerAccess 75 */ _getFromController()76 public void _getFromController(){ 77 requiredMethod("setFormDesignMode()") ; 78 79 log.println("try to get current DesignMode..."); 80 boolean currentMode = oObj.isFormDesignMode(); 81 log.println("DesignMode is " + currentMode); 82 83 log.println("enable DesignMode"); 84 oObj.setFormDesignMode(false); 85 86 log.println("test for getFromController() "); 87 XFormController xFormCont = oObj.getFormController(xForm); 88 89 if (xFormCont == null) 90 log.println("ERROR: Could not get FromContoller"); 91 92 log.println("set back DesignMode to previouse state"); 93 oObj.setFormDesignMode(currentMode); 94 95 tRes.tested("getFromController()", xFormCont != null ); 96 } 97 98 /** 99 * This test calls the test for <code>setFormDesignMode()</CODE>. 100 * Has <b> OK </b> status if the test for setFormDesignMode() returns 101 * <code>true</code> since the tests use <CODE>isFormDesignMode()</CODE><P> 102 * The following method tests are to be completed successfully before : 103 * <ul> 104 * <li> <code> setFormDesignMode() </code></li> 105 * </ul> 106 */ _isFormDesignMode()107 public void _isFormDesignMode(){ 108 requiredMethod("setFormDesignMode()") ; 109 110 log.println("test for isFormDesignMode() is ok since test for 'setFormDesingMode()' use it"); 111 tRes.tested("isFormDesignMode()", true); 112 } 113 114 /** 115 * This test gets the current FormDesignMode, change it to the opposite and checks if the expected value of 116 * method isFormDesignmode() was given. Then the FormDesignmode was set back to the original value.<P> 117 * Has <B> OK </B> if expected values are returned. 118 * 119 */ 120 _setFormDesignMode()121 public void _setFormDesignMode(){ 122 log.println("test for setFormDesignMode() and isFormDesignMode() "); 123 124 log.println("try to get current DesignMode..."); 125 boolean currentMode = oObj.isFormDesignMode(); 126 log.println("DesignMode is " + currentMode); 127 128 log.println("try to change to " + !currentMode + "..."); 129 oObj.setFormDesignMode(!currentMode); 130 log.println("try to get new DesignMode..."); 131 boolean newMode = oObj.isFormDesignMode(); 132 log.println("DesignMode is " + newMode); 133 134 boolean bOK = (newMode != currentMode); 135 136 if ( !bOK) 137 log.println("ERROR: both modes are equal"); 138 139 log.println("set back DesignMode to " + currentMode); 140 oObj.setFormDesignMode(currentMode); 141 142 log.println("try to get DesignMode..."); 143 boolean oldMode = oObj.isFormDesignMode(); 144 145 bOK &= (bOK &(currentMode == oldMode)); 146 147 if (currentMode != oldMode) 148 log.println("ERROR: could not change back"); 149 150 tRes.tested("setFormDesignMode()", bOK ); 151 } 152 153 } // finish class _XFormLayerAccess 154 155