bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _fwl / PathSettings.java
blob6e91ee8363fc52a371d5c39a7a166a1eed0aa882
1 /*
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 .
19 package mod._fwl;
21 import com.sun.star.beans.NamedValue;
22 import com.sun.star.beans.Property;
23 import com.sun.star.beans.PropertyVetoException;
24 import com.sun.star.beans.XPropertySet;
25 import com.sun.star.beans.XPropertySetInfo;
26 import com.sun.star.lang.IllegalArgumentException;
27 import com.sun.star.lang.WrappedTargetException;
28 import com.sun.star.uno.UnoRuntime;
29 import java.io.PrintWriter;
30 import java.util.HashSet;
31 import java.util.Set;
33 import lib.Status;
34 import lib.StatusException;
35 import lib.TestCase;
36 import lib.TestEnvironment;
37 import lib.TestParameters;
38 import util.utils;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.uno.XInterface;
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.comp.framework.PathSettings</code>. <p>
47 * Object implements the following interfaces :
48 * <ul>
49 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
50 * <li> <code>com::sun::star::util::PathSettings</code></li>
51 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
52 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
53 * </ul> <p>
55 * @see com.sun.star.beans.XFastPropertySet
56 * @see com.sun.star.util.PathSettings
57 * @see com.sun.star.beans.XPropertySet
58 * @see com.sun.star.beans.XMultiPropertySet
59 * @see ifc.beans._XFastPropertySet
60 * @see ifc.util._PathSettings
61 * @see ifc.beans._XPropertySet
62 * @see ifc.beans._XMultiPropertySet
64 public class PathSettings extends TestCase {
66 private static NamedValue[] m_Properties;
67 private static XPropertySet xPS;
69 /**
70 * restores the old values of the path settings
71 * @param tParam the test parameter
72 * @param log the log writer
74 protected void cleanup(TestParameters tParam, PrintWriter log) {
75 log.println("restore old values of path settings...");
77 for (int i=0; i < m_Properties.length; i++){
78 try{
80 xPS.setPropertyValue(m_Properties[i].Name, m_Properties[i].Value);
82 } catch (com.sun.star.beans.UnknownPropertyException e){
83 } catch (PropertyVetoException e){
84 } catch (IllegalArgumentException e){
85 } catch (WrappedTargetException e){
89 /**
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Creates an instance of the service
92 * <code>com.sun.star.comp.framework.PathSettings</code>.
94 protected TestEnvironment createTestEnvironment
95 (TestParameters Param, PrintWriter log) {
96 XInterface oObj = null;
97 Object oInterface = null ;
99 //now get the OButtonControl
100 try {
101 oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
102 ("com.sun.star.comp.framework.PathSettings") ;
103 } catch (com.sun.star.uno.Exception e) {
104 log.println("Couldn't get service");
105 e.printStackTrace(log);
106 throw new StatusException("Couldn't get GridControl", e );
109 if (oInterface == null) {
110 log.println("Service wasn't created") ;
111 throw new StatusException(Status.failed("Service wasn't created")) ;
114 oObj = (XInterface) oInterface ;
115 log.println("ImplName: "+utils.getImplName(oObj));
117 log.println( "creating a new environment for object" );
118 TestEnvironment tEnv = new TestEnvironment( oObj );
120 Set<String> exclProps = new HashSet<String>();
121 exclProps.add("UIConfig");
122 tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclProps);
123 tEnv.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps);
125 saveAllPropertyValues(oObj);
127 return tEnv;
128 } // finish method getTestEnvironment
130 private void saveAllPropertyValues(XInterface oObj){
132 xPS = UnoRuntime.queryInterface(
133 XPropertySet.class, oObj);
135 XPropertySetInfo xPSI = xPS.getPropertySetInfo();
137 Property[] allProperties = xPSI.getProperties();
138 m_Properties = new NamedValue[allProperties.length];
140 for (int i=0; i < allProperties.length; i++){
141 try{
142 m_Properties[i] = new NamedValue(allProperties[i].Name,
143 xPS.getPropertyValue(allProperties[i].Name));
145 } catch (com.sun.star.beans.UnknownPropertyException e){
146 } catch (WrappedTargetException e){