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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.lang
.XServiceInfo
;
24 import com
.sun
.star
.lang
.XTypeProvider
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
26 import com
.sun
.star
.uno
.XInterface
;
27 import com
.sun
.star
.util
.XCloneable
;
30 * Testing <code>com.sun.star.util.XCloneable</code>
33 * <li><code> createClone()</code></li>
35 * @see com.sun.star.util.XCloneable
37 public class _XCloneable
extends MultiMethodTest
{
39 // oObj filled by MultiMethodTest
40 public XCloneable oObj
= null ;
41 protected XCloneable clone
= null;
44 * calls the method. <p>
45 * Has <b>OK</b> status if no exception has occurred. <p>
47 public void _createClone() {
48 boolean result
= true;
49 clone
= oObj
.createClone();
51 //check if the implementaionname equals
52 result
&= checkImplementationName(oObj
,clone
);
54 //check ImplementationID
55 result
&= checkImplementationID(oObj
, clone
);
57 tRes
.tested("createClone()", result
) ;
60 protected byte[] getImplementationID(XInterface ifc
) {
61 byte[] res
= new byte[0];
62 XTypeProvider provider
= UnoRuntime
.queryInterface(XTypeProvider
.class, ifc
);
63 if (provider
!= null) {
64 res
= provider
.getImplementationId();
69 protected boolean checkImplementationID(XInterface org
, XInterface clone
) {
70 boolean res
= getImplementationID(org
).equals(
71 getImplementationID(clone
));
72 if (res
&& getImplementationID(org
).length
> 0) {
73 log
.println("ImplementationID equals the clone has the same id as the original Object");
74 log
.println("------------------------------------------------------------------------");
79 protected String
getImplementationName(XInterface ifc
) {
81 XServiceInfo info
= UnoRuntime
.queryInterface(XServiceInfo
.class, ifc
);
83 res
= info
.getImplementationName();
88 protected boolean checkImplementationName(XInterface org
, XInterface clone
) {
89 boolean res
= getImplementationName(org
).equals(
90 getImplementationName(clone
));
92 log
.println("ImplementationName differs: ");
93 log
.println("Expected: "+getImplementationName(org
));
94 log
.println("Gained: "+getImplementationName(clone
));
95 log
.println("----------------------------------------");
100 } // finish class _XCloneable