Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / util / _XCloneable.java
blob3b9301a538a89f4bfb7b9ac310da416ef64c88f6
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 ************************************************************************/
28 package ifc.util;
30 import lib.MultiMethodTest;
32 import com.sun.star.lang.XServiceInfo;
33 import com.sun.star.lang.XTypeProvider;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
36 import com.sun.star.util.XCloneable;
38 /**
39 * Testing <code>com.sun.star.util.XCloneable</code>
40 * interface methods :
41 * <ul>
42 * <li><code> createClone()</code></li>
43 * </ul> <p>
44 * @see com.sun.star.util.XCloneable
46 public class _XCloneable extends MultiMethodTest {
48 // oObj filled by MultiMethodTest
49 public XCloneable oObj = null ;
50 protected XCloneable clone = null;
52 /**
53 * calls the method. <p>
54 * Has <b>OK</b> status if no exception has occurred. <p>
56 public void _createClone() {
57 boolean result = true;
58 clone = oObj.createClone();
60 //check if the implementaionname equals
61 result &= checkImplementationName(oObj,clone);
63 //check ImplementationID
64 result &= checkImplementationID(oObj, clone);
66 tRes.tested("createClone()", result) ;
69 protected byte[] getImplementationID(XInterface ifc) {
70 byte[] res = new byte[0];
71 XTypeProvider provider = (XTypeProvider)
72 UnoRuntime.queryInterface(XTypeProvider.class, ifc);
73 if (provider != null) {
74 res = provider.getImplementationId();
76 return res;
79 protected boolean checkImplementationID(XInterface org, XInterface clone) {
80 boolean res = getImplementationID(org).equals(
81 getImplementationID(clone));
82 if (res && getImplementationID(org).length > 0) {
83 log.println("ImplementationID equals the clone has the same id as the original Object");
84 log.println("------------------------------------------------------------------------");
86 return !res;
89 protected String getImplementationName(XInterface ifc) {
90 String res = "";
91 XServiceInfo info = (XServiceInfo)
92 UnoRuntime.queryInterface(XServiceInfo.class, ifc);
93 if (info != null) {
94 res = info.getImplementationName();
96 return res;
99 protected boolean checkImplementationName(XInterface org, XInterface clone) {
100 boolean res = getImplementationName(org).equals(
101 getImplementationName(clone));
102 if (!res) {
103 log.println("ImplementationName differs: ");
104 log.println("Expected: "+getImplementationName(org));
105 log.println("Gained: "+getImplementationName(clone));
106 log.println("----------------------------------------");
108 return res;
111 } // finish class _XCloneable