1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.form; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 import lib.StatusException; 33 34 import com.sun.star.form.XApproveActionBroadcaster; 35 import com.sun.star.form.XApproveActionListener; 36 import com.sun.star.lang.EventObject; 37 38 /** 39 * Testing <code>com.sun.star.form.XApproveActionBroadcaster</code> 40 * interface methods: 41 * <ul> 42 * <li><code> addApproveActionListener() </code></li> 43 * <li><code> removeApproveActionListener() </code></li> 44 * </ul><p> 45 * Test is <b> NOT </b> multithread compilant. <p> 46 * @see com.sun.star.form.XApproveActionBroadcaster 47 */ 48 public class _XApproveActionBroadcaster extends MultiMethodTest { 49 public XApproveActionBroadcaster oObj = null; 50 51 /** 52 * Class we need to test methods. 53 */ 54 protected class TestListener implements XApproveActionListener { 55 public boolean approve = false ; 56 57 public void init() { 58 approve = false ; 59 } 60 public void disposing(EventObject ev) {} 61 public boolean approveAction(EventObject ev) { 62 log.println("XApproveActionListener: ActionListener was called"); 63 return approve ; 64 } 65 66 } 67 68 private TestListener listener = new TestListener(); 69 70 /** 71 * Test calls the method. <p> 72 * Has <b> OK </b> status if the method successfully returns 73 * and no exceptions were thrown. 74 */ 75 public void _addApproveActionListener() { 76 oObj.addApproveActionListener(listener) ; 77 tRes.tested("addApproveActionListener()", true); 78 } 79 80 /** 81 * Test calls the method. <p> 82 * Has <b> OK </b> status if the method successfully returns 83 * and no exceptions were thrown. <p> 84 * The following method tests are to be completed successfully before : 85 * <ul> 86 * <li> <code> addApproveActionListener() </code> : adds listener to an 87 * object </li> 88 * </ul> 89 */ 90 public void _removeApproveActionListener() { 91 requiredMethod("addApproveActionListener()"); 92 listener.init() ; 93 listener.approve = true ; 94 oObj.removeApproveActionListener(listener); 95 tRes.tested("removeApproveActionListener()", true); 96 } 97 98 99 /** 100 * Just log output 101 */ 102 protected void after() { 103 log.println("Skipping all XApproveActionBroadcaster methods, since they" 104 + " need user interaction"); 105 throw new StatusException(Status.skipped(true)); 106 } 107 108 } 109 110 111