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.document;
29 
30 import lib.MultiMethodTest;
31 
32 import com.sun.star.document.XActionLockable;
33 
34 /**
35 * Testing <code>com.sun.star.document.XActionLockable</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> isActionLocked()</code></li>
39 *  <li><code> addActionLock()</code></li>
40 *  <li><code> removeActionLock()</code></li>
41 *  <li><code> setActionLocks()</code></li>
42 *  <li><code> resetActionLocks()</code></li>
43 * </ul> <p>
44 * Test is <b> NOT </b> multithread compilant. <p>
45 * @see com.sun.star.document.XActionLockable
46 */
47 public class _XActionLockable extends MultiMethodTest {
48     public XActionLockable oObj = null;
49 
50     /**
51      * Method addActionLock called first and then
52      * checked value returned by isActionLocked().<p>
53      * Has <b> OK </b> status if no runtime exceptions occured
54      * and returned value is true.
55      */
56     public void _isActionLocked() {
57         //determines if at least one lock exists
58         oObj.addActionLock();
59         boolean result = oObj.isActionLocked();
60         tRes.tested("isActionLocked()", result);
61     }
62 
63     /**
64     * Just calls the method. <p>
65     * Has <b> OK </b> status if no runtime exceptions occured
66     */
67     public void _addActionLock() {
68         requiredMethod("resetActionLocks()");
69         oObj.addActionLock();
70         tRes.tested("addActionLock()", true);
71     }
72 
73     /**
74     * Calls the method and check value returned by isActionLocked(). <p>
75     * Has <b> OK </b> status if no runtime exceptions occured
76     * and returned value is false.
77     */
78     public void _removeActionLock() {
79         requiredMethod("addActionLock()");
80         oObj.removeActionLock();
81         boolean result = ! oObj.isActionLocked();
82         tRes.tested("removeActionLock()", result);
83     }
84 
85     /**
86     * Calls the method with specific value. <p>
87     * Has <b> OK </b> status if no runtime exceptions occured
88     */
89     public void _setActionLocks() {
90         oObj.setActionLocks( nLock );
91         tRes.tested("setActionLocks()", true);
92     }
93 
94     final short nLock = 8;
95 
96     /**
97     * Calls the method and checks returned value.<p>
98     * Has <b> OK </b> status if the component is not currently
99     * locked and returned value is the same as locks number
100     * set by <code>setActionLocks</code> method test.
101     */
102     public void _resetActionLocks() {
103         requiredMethod("setActionLocks()");
104         short nLocksBeforeReset = oObj.resetActionLocks();
105         boolean result = !oObj.isActionLocked() && nLocksBeforeReset == nLock;
106         tRes.tested("resetActionLocks()", result);
107     }
108 }// finish class _XActionLockable
109 
110