merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _cfgmgr2 / OInnerGroupInfoAccess.java
blob5037bfb9a7e7f366bb322fdb4df89a204f51f429
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: OInnerGroupInfoAccess.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 ************************************************************************/
30 package mod._cfgmgr2;
32 import java.io.PrintWriter;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 import util.utils;
39 import com.sun.star.beans.PropertyState;
40 import com.sun.star.beans.PropertyValue;
41 import com.sun.star.container.XNameAccess;
42 import com.sun.star.container.XNameReplace;
43 import com.sun.star.lang.XMultiServiceFactory;
44 import com.sun.star.uno.UnoRuntime;
45 import com.sun.star.uno.XInterface;
48 public class OInnerGroupInfoAccess extends TestCase {
49 /** Called to create an instance of <code>TestEnvironment</code> with an
50 * object to test and related objects. <br>
52 * An instance of com.sun.star.comp.configuration.ConfigurationProvider
53 * is created at the MultiServiceFactory of the Office<br>
54 * At this an instance of com.sun.star.configuration.ConfigurationAccess is created
55 * and from the resulting XNameAccess the first element is taken.
57 * @param tParam test parameters
58 * @param log writer to log information while testing
60 * @see TestEnvironment
61 * @see #getTestEnvironment()
64 protected TestEnvironment createTestEnvironment(TestParameters tParam,
65 PrintWriter log) {
66 XInterface oObj = null;
67 log.println("creating the Environment");
69 PropertyValue[] nodeArgs = new PropertyValue[1];
70 PropertyValue nodepath = new PropertyValue();
71 nodepath.Name = "nodepath";
72 nodepath.Value = "org.openoffice.Office.Common";
73 nodepath.Handle = -1;
74 nodepath.State = PropertyState.DEFAULT_VALUE;
75 nodeArgs[0] = nodepath;
77 XNameReplace updateAccess = null;
78 try {
79 XInterface Provider = (XInterface) ((XMultiServiceFactory)tParam.getMSF())
80 .createInstance("com.sun.star.comp.configuration.ConfigurationProvider");
81 XMultiServiceFactory pMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
82 XMultiServiceFactory.class,
83 Provider);
84 XNameAccess names = (XNameAccess) UnoRuntime.queryInterface(
85 XNameAccess.class,
86 pMSF.createInstanceWithArguments(
87 "com.sun.star.configuration.ConfigurationAccess",
88 nodeArgs));
89 oObj = (XInterface) names.getByName(names.getElementNames()[0]);
91 names = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
92 oObj);
94 String[] theNames = names.getElementNames();
96 log.println("Contains " + theNames.length + " elements");
98 // create a changeable view on the element for XContainer interface
99 names = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, pMSF.createInstanceWithArguments(
100 "com.sun.star.configuration.ConfigurationUpdateAccess", nodeArgs));
101 updateAccess = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class,
102 names.getByName(names.getElementNames()[0]));
104 } catch (com.sun.star.uno.Exception e) {
105 e.printStackTrace();
108 log.println("ImplementationName: " + utils.getImplName(oObj));
110 TestEnvironment tEnv = new TestEnvironment(oObj);
112 String[] pNames = new String[] {
113 "AutoDetectSystemHC", "HelpTipSeconds", "IsAllowAnimatedGraphics",
114 "IsAllowAnimatedText", "IsAutomaticFontColor", "IsForPagePreviews",
115 "IsHelpTipsDisappear", "IsSelectionInReadonly", "IsSystemFont"
118 String[] pTypes = new String[] {
119 "Boolean", "Short", "Boolean", "Boolean", "Boolean", "Boolean",
120 "Boolean", "Boolean", "Boolean"
123 tEnv.addObjRelation("PropertyNames", pNames);
124 tEnv.addObjRelation("PropertyTypes", pTypes);
126 tEnv.addObjRelation("XContainer.Container", updateAccess);
127 // create an unlikely value for "HelpTipSeconds"
128 tEnv.addObjRelation("XContainer.NewValue", new Short((short)300000));
129 tEnv.addObjRelation("XContainer.ElementName", pNames[1]);
131 tEnv.addObjRelation("ElementName", "AutoDetectSystemHC");
133 tEnv.addObjRelation("cannotSwitchParent",
134 "configmgr: BasicElement::setParent: cannot move Entry");
136 tEnv.addObjRelation("allReadOnly",
137 "all Properties of OInnerGroupInfoAccess are read Only");
139 tEnv.addObjRelation("expectedName", "IsSelectionInReadonly");
140 tEnv.addObjRelation("HierachicalName", "/org.openoffice.Office");
141 tEnv.addObjRelation("NoSetName", "OInnerGroupInfoAccess");
143 return tEnv;