1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ORootElementGroupInfoAccess.java,v $
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 ************************************************************************/
32 import java
.io
.PrintWriter
;
35 import lib
.TestEnvironment
;
36 import lib
.TestParameters
;
39 import com
.sun
.star
.beans
.PropertyState
;
40 import com
.sun
.star
.beans
.PropertyValue
;
41 import com
.sun
.star
.beans
.XPropertySet
;
42 import com
.sun
.star
.container
.XNameAccess
;
43 import com
.sun
.star
.container
.XNameReplace
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
46 import com
.sun
.star
.uno
.XInterface
;
47 import com
.sun
.star
.util
.XChangesBatch
;
50 public class ORootElementGroupInfoAccess
extends TestCase
{
51 /** Called to create an instance of <code>TestEnvironment</code> with an
52 * object to test and related objects. <br>
54 * An instance of com.sun.star.comp.configuration.ConfigurationProvider
55 * is created at the MultiServiceFactory of the Office<br>
56 * At this an instance of com.sun.star.configuration.ConfigurationAccess is created
57 * and from the resulting XNameAccess the first element is taken.
59 * @param tParam test parameters
60 * @param log writer to log information while testing
62 * @see TestEnvironment
63 * @see #getTestEnvironment()
66 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
68 XInterface oObj
= null;
69 log
.println("creating the Environment");
71 PropertyValue
[] nodeArgs
= new PropertyValue
[1];
72 PropertyValue nodepath
= new PropertyValue();
73 nodepath
.Name
= "nodepath";
74 nodepath
.Value
= "org.openoffice.Office.Common";
76 nodepath
.State
= PropertyState
.DEFAULT_VALUE
;
77 nodeArgs
[0] = nodepath
;
79 XInterface changeView
= null;
80 XInterface alternateObject
= null;
82 XInterface Provider
= (XInterface
) ((XMultiServiceFactory
)tParam
.getMSF())
83 .createInstance("com.sun.star.comp.configuration.ConfigurationProvider");
84 XMultiServiceFactory pMSF
= (XMultiServiceFactory
) UnoRuntime
.queryInterface(
85 XMultiServiceFactory
.class,
87 oObj
= (XNameAccess
) UnoRuntime
.queryInterface(XNameAccess
.class,
88 pMSF
.createInstanceWithArguments(
89 "com.sun.star.configuration.ConfigurationAccess",
91 // create a view on a different object that can change something, so listeners can be triggered.
92 // this is done for XContainer test
93 nodepath
.Value
= "org.openoffice.Office.Common/Internal";
94 changeView
= (XNameReplace
) UnoRuntime
.queryInterface(XNameReplace
.class,
95 pMSF
.createInstanceWithArguments(
96 "com.sun.star.configuration.ConfigurationUpdateAccess",
98 alternateObject
= (XNameAccess
) UnoRuntime
.queryInterface(XNameAccess
.class,
99 pMSF
.createInstanceWithArguments(
100 "com.sun.star.configuration.ConfigurationAccess",
102 } catch (com
.sun
.star
.uno
.Exception e
) {
106 log
.println("ImplementationName: " + utils
.getImplName(oObj
));
108 TestEnvironment tEnv
= new TestEnvironment(oObj
);
110 XPropertySet prop
= (XPropertySet
) UnoRuntime
.queryInterface(
111 XPropertySet
.class, oObj
);
112 util
.dbg
.printPropertiesNames(prop
);
114 String
[] pNames
= new String
[] {
115 "Accessibility", "AddXMLToStorage", "AsianLayout", "AutoCorrect",
116 "Cache", "DateFormat", "ExternalApps", "ExternalMailer", "Filter",
117 "Font", "Gallery", "Help", "History", "I18N", "Image", "Internal",
118 "InternalMSExport", "Java", "Load", "Menus", "Misc",
119 "OfficeObjects", "Passwords", "Path", "Print", "Save",
120 "SearchOptions", "Security", "Setup", "Startup", "Undo",
121 "Vectorize", "View", "WorkingSet", "_3D_Engine"
124 String
[] pTypes
= new String
[36];
126 for (int k
= 0; k
< pTypes
.length
; k
++) {
127 pTypes
[k
] = "XInterface";
130 tEnv
.addObjRelation("PropertyNames", pNames
);
131 tEnv
.addObjRelation("PropertyTypes", pTypes
);
133 tEnv
.addObjRelation("ElementName", "Accessibility");
135 tEnv
.addObjRelation("XLocalizable.ReadOnly", "Locale of ORootElementGroupInfoAccess is read Only");
136 tEnv
.addObjRelation("allReadOnly",
137 "all Properties of ORootElementGroupInfoAccess are read Only");
139 tEnv
.addObjRelation("XContainer.NewValue", "SenselessString");
140 tEnv
.addObjRelation("XContainer.ElementName", "CurrentTempURL");
141 tEnv
.addObjRelation("XContainer.Container", changeView
);
142 tEnv
.addObjRelation("XContainer.AlternateObject", alternateObject
);
144 tEnv
.addObjRelation("XChangesNotifier.ChangesBatch", (XChangesBatch
)UnoRuntime
.queryInterface(
145 XChangesBatch
.class, changeView
));
147 // set a new temp directory: use java.io.tmpdir as substitute, for XChangesNotifier test
148 // get a XPropertySet from the sub element
149 XPropertySet xProp
= (XPropertySet
)UnoRuntime
.queryInterface(XPropertySet
.class, changeView
);
150 String newTempURL
= util
.utils
.getFullURL(util
.utils
.getUsersTempDir());
151 String curTempURL
= "";
153 curTempURL
= (String
)xProp
.getPropertyValue("CurrentTempURL");
156 log
.println("Cannot get property for XChangesNotifier test: this test is bound to fail.");
157 e
.printStackTrace((PrintWriter
)log
);
159 // fallback 1: get user home
160 if (newTempURL
.equalsIgnoreCase(curTempURL
)) {
161 newTempURL
= util
.utils
.getFullURL(System
.getProperty("user.home"));
162 // fallback 2: get user dir
163 if (newTempURL
.equalsIgnoreCase(curTempURL
)) {
164 newTempURL
= util
.utils
.getFullURL(System
.getProperty("user.dir"));
167 tEnv
.addObjRelation("XChangesNotifier.ChangeElement", newTempURL
);
168 tEnv
.addObjRelation("XChangesNotifier.OriginalElement", curTempURL
);
169 tEnv
.addObjRelation("XChangesNotifier.PropertyName", "CurrentTempURL");
170 tEnv
.addObjRelation("XChangesNotifier.PropertySet", xProp
);
172 tEnv
.addObjRelation("expectedName", "OfficeObjects");
173 tEnv
.addObjRelation("HierachicalName", "/org.openoffice");
175 tEnv
.addObjRelation("NoSetName", "ORootElementGroupInfoAccess");