Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / form / binding / _XBindableValue.java
blobd8ecf916965b691ec7115ade84573e2272591d0a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 package ifc.form.binding;
29 import com.sun.star.form.binding.XBindableValue;
30 import com.sun.star.form.binding.XValueBinding;
31 import com.sun.star.uno.Type;
33 import java.util.ArrayList;
35 import lib.MultiMethodTest;
38 public class _XBindableValue extends MultiMethodTest {
39 public XBindableValue oObj;
40 protected XValueBinding xValueBinding = null;
42 public void _getValueBinding() {
43 requiredMethod("setValueBinding");
45 boolean res = true;
46 xValueBinding = oObj.getValueBinding();
47 res &= checkValueBinding(xValueBinding);
48 tRes.tested("getValueBinding()", res);
51 public void _setValueBinding() {
52 String rightOne = "";
54 try {
55 oObj.setValueBinding(new MyValueBinding());
56 rightOne = (String) oObj.getValueBinding().getValue(null);
57 } catch (com.sun.star.form.binding.IncompatibleTypesException e) {
58 e.printStackTrace();
61 boolean res = rightOne.equals("MyValueBinding");
63 if (!res) {
64 log.println("Excepted: MyValueBinding");
65 log.println("getting: " + rightOne);
68 tRes.tested("setValueBinding()", res);
71 protected boolean checkValueBinding(XValueBinding xValueBinding) {
72 boolean res = true;
73 Type[] types = xValueBinding.getSupportedValueTypes();
74 log.println("Checking: ");
76 for (int i = 0; i < types.length; i++) {
77 log.println("\t" + types[i].getTypeName());
79 boolean localRes = xValueBinding.supportsType(types[i]);
81 if (!localRes) {
82 log.println("\t\tsupportsType returns false -- FAILED");
83 } else {
84 log.println("\t\tis supported -- OK");
87 res &= localRes;
90 return res;
93 class MyValueBinding implements XValueBinding {
94 private Type[] TypeArray;
95 private ArrayList types = new ArrayList();
97 public com.sun.star.uno.Type[] getSupportedValueTypes() {
98 return TypeArray;
101 public Object getValue(com.sun.star.uno.Type type)
102 throws com.sun.star.form.binding.IncompatibleTypesException {
103 return "MyValueBinding";
106 public void setValue(Object obj)
107 throws com.sun.star.form.binding.IncompatibleTypesException,
108 com.sun.star.lang.NoSupportException {
111 public boolean supportsType(com.sun.star.uno.Type type) {
112 types.add(type);
113 TypeArray = new Type[types.size()];
115 for (int i = 0; i < types.size(); i++) {
116 TypeArray[i] = (Type) types.toArray()[i];
119 return true;