merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / util / _XProtectable.java
blob2675cb5788b9ac87b7c9443b49fcbf1867500e1d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XProtectable.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package ifc.util;
32 import com.sun.star.util.XProtectable;
33 import lib.MultiMethodTest;
35 /**
36 * Check the XProtectable interface.
38 public class _XProtectable extends MultiMethodTest {
39 public XProtectable oObj = null;
40 String sPassWord = "TopSecret";
42 /**
43 * Check, if the sheet is protected.
44 * Has OK status, if this is the case.
46 public void _isProtected() {
47 requiredMethod("protect()");
48 boolean result = oObj.isProtected();
49 tRes.tested("isProtected()", result);
52 /**
53 * Protect the sheet
55 public void _protect() {
56 oObj.protect(sPassWord);
57 tRes.tested("protect()", true);
60 /**
61 * Unprotect with wrong password, see if it's still protected.
62 * Unprotect with correct password, see if it's unprotected.
64 public void _unprotect() {
65 requiredMethod("isProtected()");
66 boolean result = true;
67 try {
68 oObj.unprotect("WrongPassword");
69 // result = false;
71 catch(com.sun.star.lang.IllegalArgumentException e) {
72 log.println("Correct Exception thrown.");
74 // just check if it's still protected
75 result &= oObj.isProtected();
76 try {
77 oObj.unprotect(sPassWord);
79 catch(com.sun.star.lang.IllegalArgumentException e) {
80 log.println("Wrong Exception thrown: password is correct.");
81 result = false;
83 result &= !oObj.isProtected();
84 tRes.tested("unprotect()", result);