Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _fwl / PathSettings.java
blobee12c94e4ba2e81a3423f5f16113379bb32c3026
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.uno.XInterface;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.comp.framework.PathSettings</code>. <p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
49 * <li> <code>com::sun::star::util::PathSettings</code></li>
50 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
52 * </ul> <p>
54 * @see com.sun.star.beans.XFastPropertySet
55 * @see com.sun.star.util.PathSettings
56 * @see com.sun.star.beans.XPropertySet
57 * @see com.sun.star.beans.XMultiPropertySet
58 * @see ifc.beans._XFastPropertySet
59 * @see ifc.util._PathSettings
60 * @see ifc.beans._XPropertySet
61 * @see ifc.beans._XMultiPropertySet
63 public class PathSettings extends TestCase {
65 private static NamedValue[] m_Properties;
66 private static XPropertySet xPS;
68 /**
69 * restores the old values of the path settings
70 * @param tParam the test parameter
71 * @param log the log writer
73 @Override
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 @Override
95 protected TestEnvironment createTestEnvironment
96 (TestParameters Param, PrintWriter log) {
97 XInterface oObj = null;
98 Object oInterface = null ;
100 //now get the OButtonControl
101 try {
102 oInterface = Param.getMSF().createInstance
103 ("com.sun.star.comp.framework.PathSettings") ;
104 } catch (com.sun.star.uno.Exception e) {
105 log.println("Couldn't get service");
106 e.printStackTrace(log);
107 throw new StatusException("Couldn't get GridControl", e );
110 if (oInterface == null) {
111 log.println("Service wasn't created") ;
112 throw new StatusException(Status.failed("Service wasn't created")) ;
115 oObj = (XInterface) oInterface ;
116 log.println("ImplName: "+utils.getImplName(oObj));
118 log.println( "creating a new environment for object" );
119 TestEnvironment tEnv = new TestEnvironment( oObj );
121 Set<String> exclProps = new HashSet<String>();
122 exclProps.add("UIConfig");
123 tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclProps);
124 tEnv.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps);
126 saveAllPropertyValues(oObj);
128 return tEnv;
129 } // finish method getTestEnvironment
131 private void saveAllPropertyValues(XInterface oObj){
133 xPS = UnoRuntime.queryInterface(
134 XPropertySet.class, oObj);
136 XPropertySetInfo xPSI = xPS.getPropertySetInfo();
138 Property[] allProperties = xPSI.getProperties();
139 m_Properties = new NamedValue[allProperties.length];
141 for (int i=0; i < allProperties.length; i++){
142 try{
143 m_Properties[i] = new NamedValue(allProperties[i].Name,
144 xPS.getPropertyValue(allProperties[i].Name));
146 } catch (com.sun.star.beans.UnknownPropertyException e){
147 } catch (WrappedTargetException e){