Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / frame / _XComponentLoader.java
blobca891c848e0e0bb01389e1523545d6d8cf9708ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XComponentLoader.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.frame;
33 import lib.MultiMethodTest;
35 import com.sun.star.beans.PropertyState;
36 import com.sun.star.beans.PropertyValue;
37 import com.sun.star.frame.XComponentLoader;
38 import com.sun.star.lang.XComponent;
41 /**
42 * Testing <code>com.sun.star.frame.XComponentLoader</code>
43 * interface methods:
44 * <ul>
45 * <li><code> loadComponentFromURL() </code></li>
46 * </ul><p>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.frame.XComponentLoader
50 public class _XComponentLoader extends MultiMethodTest {
51 public XComponentLoader oObj = null; // oObj filled by MultiMethodTest
53 /**
54 * Method which tests the objects ability to load a
55 * component from URL. All available components are loaded by turns. <p>
56 * Has <b> OK </b> status if the method successfully returns
57 * and no exceptions were thrown. <p>
58 * @see XComponent
60 public void _loadComponentFromURL() {
61 boolean result = true;
63 log.println("testing loadComponentFromURL() ... ");
64 try {
65 PropertyValue [] szEmptyArgs = new PropertyValue [0];
66 String frameName = "_blank";
67 XComponent oDoc = null;
69 log.println("load writer doc that contains links");
70 PropertyValue [] szArgs = new PropertyValue [1];
71 PropertyValue Arg = new PropertyValue();
72 Arg.Name = "UpdateDocMode";
73 Arg.Value = new Short(com.sun.star.document.UpdateDocMode.NO_UPDATE);
74 szArgs[0]=Arg;
75 String url = util.utils.getFullTestURL("Writer_link.sxw");
76 log.println("try to load '" + url + "'");
77 oDoc = oObj.loadComponentFromURL(
78 url, frameName, 0, szArgs);
80 try {
81 Thread.sleep(500);
83 catch (InterruptedException ex) {
86 oDoc.dispose();
88 url = util.utils.getFullTestURL("Calc_Link.sxc");
89 log.println("try to load '" + url + "'");
90 oDoc = oObj.loadComponentFromURL(
91 url, frameName, 0, szArgs);
93 try {
94 Thread.sleep(500);
96 catch (InterruptedException ex) {
99 oDoc.dispose();
103 log.println("load a blank impress doc");
104 Arg.Name = "OpenFlags";
105 Arg.Value = "S";
106 Arg.Handle = -1;
107 Arg.State = PropertyState.DEFAULT_VALUE;
108 szArgs[0]=Arg;
109 oDoc = oObj.loadComponentFromURL(
110 "private:factory/simpress", frameName, 0, szArgs );
112 log.println("disposing impress doc");
113 oDoc.dispose();
115 log.println("load a blank writer doc");
116 oDoc = oObj.loadComponentFromURL(
117 "private:factory/swriter", frameName, 0, szEmptyArgs );
119 log.println("disposing writer doc");
120 oDoc.dispose();
122 log.println("load a blank calc doc");
123 oDoc = oObj.loadComponentFromURL(
124 "private:factory/scalc", frameName, 0, szEmptyArgs );
126 log.println("disposing calc doc");
127 oDoc.dispose();
129 log.println("load a blank draw doc");
130 oDoc = oObj.loadComponentFromURL(
131 "private:factory/sdraw", frameName, 0, szEmptyArgs );
133 log.println("disposing draw doc");
134 oDoc.dispose();
136 log.println("load a blank math doc");
137 oDoc = oObj.loadComponentFromURL(
138 "private:factory/smath", frameName, 0, szEmptyArgs );
140 log.println("disposing math doc");
141 oDoc.dispose();
144 catch (com.sun.star.lang.IllegalArgumentException e) {
145 log.println("Exception occured while loading");
146 e.printStackTrace(log);
147 result=false;
149 catch (com.sun.star.io.IOException e) {
150 log.println("Exception occured while loading");
151 e.printStackTrace(log);
152 result=false;
155 tRes.tested("loadComponentFromURL()", result);
156 return;