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
.beans
.PropertyState
;
24 import com
.sun
.star
.beans
.PropertyValue
;
25 import com
.sun
.star
.frame
.XComponentLoader
;
26 import com
.sun
.star
.lang
.XComponent
;
30 * Testing <code>com.sun.star.frame.XComponentLoader</code>
33 * <li><code> loadComponentFromURL() </code></li>
35 * Test is <b> NOT </b> multithread compliant. <p>
36 * @see com.sun.star.frame.XComponentLoader
38 public class _XComponentLoader
extends MultiMethodTest
{
39 public XComponentLoader oObj
= null; // oObj filled by MultiMethodTest
42 * Method which tests the objects ability to load a
43 * component from URL. All available components are loaded by turns. <p>
44 * Has <b> OK </b> status if the method successfully returns
45 * and no exceptions were thrown. <p>
48 public void _loadComponentFromURL() {
49 boolean result
= true;
51 log
.println("testing loadComponentFromURL() ... ");
53 PropertyValue
[] szEmptyArgs
= new PropertyValue
[0];
54 String frameName
= "_blank";
55 XComponent oDoc
= null;
57 log
.println("load writer doc that contains links");
58 PropertyValue
[] szArgs
= new PropertyValue
[1];
59 PropertyValue Arg
= new PropertyValue();
60 Arg
.Name
= "UpdateDocMode";
61 Arg
.Value
= Short
.valueOf(com
.sun
.star
.document
.UpdateDocMode
.NO_UPDATE
);
63 String url
= util
.utils
.getFullTestURL("Writer_link.sxw");
64 log
.println("try to load '" + url
+ "'");
65 oDoc
= oObj
.loadComponentFromURL(
66 url
, frameName
, 0, szArgs
);
68 util
.utils
.shortWait();
72 url
= util
.utils
.getFullTestURL("Calc_Link.sxc");
73 log
.println("try to load '" + url
+ "'");
74 oDoc
= oObj
.loadComponentFromURL(
75 url
, frameName
, 0, szArgs
);
77 util
.utils
.shortWait();
83 log
.println("load a blank impress doc");
84 Arg
.Name
= "OpenFlags";
87 Arg
.State
= PropertyState
.DEFAULT_VALUE
;
89 oDoc
= oObj
.loadComponentFromURL(
90 "private:factory/simpress", frameName
, 0, szArgs
);
92 log
.println("disposing impress doc");
95 log
.println("load a blank writer doc");
96 oDoc
= oObj
.loadComponentFromURL(
97 "private:factory/swriter", frameName
, 0, szEmptyArgs
);
99 log
.println("disposing writer doc");
102 log
.println("load a blank calc doc");
103 oDoc
= oObj
.loadComponentFromURL(
104 "private:factory/scalc", frameName
, 0, szEmptyArgs
);
106 log
.println("disposing calc doc");
109 log
.println("load a blank draw doc");
110 oDoc
= oObj
.loadComponentFromURL(
111 "private:factory/sdraw", frameName
, 0, szEmptyArgs
);
113 log
.println("disposing draw doc");
116 log
.println("load a blank math doc");
117 oDoc
= oObj
.loadComponentFromURL(
118 "private:factory/smath", frameName
, 0, szEmptyArgs
);
120 log
.println("disposing math doc");
124 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
125 log
.println("Exception occurred while loading");
126 e
.printStackTrace(log
);
129 catch (com
.sun
.star
.io
.IOException e
) {
130 log
.println("Exception occurred while loading");
131 e
.printStackTrace(log
);
135 tRes
.tested("loadComponentFromURL()", result
);