Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / form / validation / _XValidatable.java
blob3d0bd6111eb17197ff215c6dfe2d57eab7735b3f
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package ifc.form.validation;
20 import com.sun.star.form.validation.XValidatable;
21 import com.sun.star.form.validation.XValidator;
23 import lib.MultiMethodTest;
26 public class _XValidatable extends MultiMethodTest {
27 public XValidatable oObj;
29 public void _getValidator() {
30 requiredMethod("setValidator()");
32 XValidator xValidator = oObj.getValidator();
33 boolean res = xValidator.isValid(Boolean.FALSE);
34 tRes.tested("getValidator()", res);
37 public void _setValidator() {
38 boolean res = false;
40 try {
41 oObj.setValidator(new MyValidator());
43 XValidator xValidator = oObj.getValidator();
44 String getting = xValidator.explainInvalid(null);
45 res = getting.equals("explainInvalid");
47 if (!res) {
48 log.println("\tExpected: explainInvalid");
49 log.println("\tGetting: " + getting);
50 log.println("FAILED");
52 } catch (com.sun.star.util.VetoException e) {
53 e.printStackTrace();
56 tRes.tested("setValidator()", res);
59 public class MyValidator implements XValidator {
60 public void addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
61 throws com.sun.star.lang.NullPointerException {
64 public String explainInvalid(Object obj) {
65 return "explainInvalid";
68 public boolean isValid(Object obj) {
69 return true;
72 public void removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
73 throws com.sun.star.lang.NullPointerException {