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
.drawing
.XDrawPage
;
24 import com
.sun
.star
.drawing
.XDrawPageDuplicator
;
25 import com
.sun
.star
.drawing
.XDrawPages
;
26 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
27 import com
.sun
.star
.uno
.AnyConverter
;
28 import com
.sun
.star
.uno
.Type
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
30 import com
.sun
.star
.uno
.XInterface
;
34 * Testing <code>com.sun.star.drawing.XDrawPageDuplicator</code>
37 * <li><code> duplicate()</code></li>
39 * The object tested <b> must implement </b>
40 * <code>XDrawPagesSupplier</code> interface to have access to draw
41 * pages collection. <p>
42 * Test is <b> NOT </b> multithread compliant. <p>
43 * After test completion object environment has to be recreated.
44 * @see com.sun.star.drawing.XDrawPageDuplicator
46 public class _XDrawPageDuplicator
extends MultiMethodTest
{
47 public XDrawPageDuplicator oObj
= null;
50 * First queries object tested for <code>XDrawPagesSupplier</code>
51 * interface and obtains one draw page from document. Then it
52 * tries to duplicate it.<p>
53 * Has <b> OK </b> status if the method returns not null value and
54 * this value is not equal to the page which was duplicated. <p>
56 public void _duplicate(){
57 boolean result
= false;
58 XInterface testobj
= tEnv
.getTestObject();
59 XDrawPagesSupplier PS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, testobj
);
60 XDrawPages DPs
= PS
.getDrawPages();
63 DP
= (XDrawPage
) AnyConverter
.toObject(
64 new Type(XDrawPage
.class),DPs
.getByIndex(0));
65 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
66 log
.println("Exception occurred while testing: " + e
);
67 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
68 log
.println("Exception occurred while testing: " + e
);
69 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
70 log
.println("Exception occurred while testing: " + e
);
74 XDrawPage newPage
= oObj
.duplicate(DP
);
75 result
= (newPage
!= null) && !(newPage
.equals(DP
));
77 tRes
.tested("duplicate()", result
);