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 package ifc.form.validation;
24 
25 import com.sun.star.form.validation.XValidatable;
26 import com.sun.star.form.validation.XValidator;
27 
28 import lib.MultiMethodTest;
29 
30 
31 public class _XValidatable extends MultiMethodTest {
32     public XValidatable oObj;
33 
_getValidator()34     public void _getValidator() {
35         requiredMethod("setValidator()");
36 
37         XValidator xValidator = oObj.getValidator();
38         boolean res = xValidator.isValid(Boolean.FALSE);
39         tRes.tested("getValidator()", res);
40     }
41 
_setValidator()42     public void _setValidator() {
43         boolean res = false;
44 
45         try {
46             oObj.setValidator(new MyValidator());
47 
48             XValidator xValidator = oObj.getValidator();
49             String getting = xValidator.explainInvalid(null);
50             res = getting.equals("explainInvalid");
51 
52             if (!res) {
53                 log.println("\tExpected: explainInvalid");
54                 log.println("\tGetting: " + getting);
55                 log.println("FAILED");
56             }
57         } catch (com.sun.star.util.VetoException e) {
58             e.printStackTrace();
59         }
60 
61         tRes.tested("setValidator()", res);
62     }
63 
64     public class MyValidator implements XValidator {
addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)65         public void addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
66             throws com.sun.star.lang.NullPointerException {
67         }
68 
explainInvalid(Object obj)69         public String explainInvalid(Object obj) {
70             return "explainInvalid";
71         }
72 
isValid(Object obj)73         public boolean isValid(Object obj) {
74             return true;
75         }
76 
removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)77         public void removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
78             throws com.sun.star.lang.NullPointerException {
79         }
80     }
81 }