1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.ucb;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.lang.XMultiServiceFactory;
29 import com.sun.star.ucb.XFileIdentifierConverter;
30 
31 /**
32 * Testing <code>com.sun.star.ucb.XFileIdentifierConverter</code>
33 * interface methods :
34 * <ul>
35 *  <li><code> getFileProviderLocality()</code></li>
36 *  <li><code> getFileURLFromSystemPath()</code></li>
37 *  <li><code> getSystemPathFromFileURL()</code></li>
38 * </ul> <p>
39 * Test is <b> NOT </b> multithread compilant. <p>
40 * @see com.sun.star.ucb.XFileIdentifierConverter
41 */
42 public class _XFileIdentifierConverter extends MultiMethodTest {
43 
44     /**
45      * Contains the tested object.
46      */
47     public XFileIdentifierConverter oObj;
48 
49     /**
50      * Gets the locality for SOffice temporary directory. <p>
51      * Has <b> OK </b> status if the method returns value greater
52      * than 0 (as office temp directory is supposed to be in the
53      * same location). <p>
54      */
_getFileProviderLocality()55     public void _getFileProviderLocality() {
56         String baseURL = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
57         log.println("Using: "+baseURL);
58         int loc = oObj.getFileProviderLocality(baseURL);
59         log.println("Getting: "+loc);
60         tRes.tested("getFileProviderLocality()",loc > 0);
61     }
62 
63     /**
64      * Tries to convert URL of SOffice temp directory to system
65      * dependent path. <p>
66      * Has <b> OK </b> status if the method returns system dependent
67      * representation of the URL passed. <p>
68      */
_getSystemPathFromFileURL()69     public void _getSystemPathFromFileURL() {
70         String baseURL = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
71         log.println("Using (Base): "+baseURL);
72         String sysURL = util.utils.getOfficeTempDirSys((XMultiServiceFactory)tParam.getMSF());
73         log.println("Using (System): "+sysURL);
74         String get = oObj.getSystemPathFromFileURL(baseURL);
75         log.println("Getting: "+get);
76         //sysURL = sysURL.substring(0,sysURL.length()-1);
77         tRes.tested("getSystemPathFromFileURL()",get.equals(sysURL));
78     }
79 
80     /**
81      * Tries to convert system dependent path of SOffice temp
82      * directory to URL representation. <p>
83      * Has <b> OK </b> status if the method returns URL representation
84      * of the system dependent path passed. <p>
85      */
_getFileURLFromSystemPath()86     public void _getFileURLFromSystemPath() {
87         String baseURL = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
88         log.println("Using (Base): "+baseURL);
89         String sysURL = util.utils.getOfficeTempDirSys((XMultiServiceFactory)tParam.getMSF());
90         log.println("Using (System): "+sysURL);
91         String get = oObj.getFileURLFromSystemPath(sysURL,sysURL);
92         log.println("Getting: "+get);
93         tRes.tested("getFileURLFromSystemPath()",get.equals(baseURL));
94     }
95 
96 }
97