1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.io;
29 
30 import lib.MultiMethodTest;
31 
32 import com.sun.star.io.XConnectable;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
35 
36 /**
37 * Testing <code>com.sun.star.io.XConnectable</code>
38 * interface methods:
39 * <ul>
40 *   <li><code>setPredecessor()</code></li>
41 *   <li><code>getPredecessor()</code></li>
42 *   <li><code>setSuccessor()</code></li>
43 *   <li><code>getSuccessor()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
47 *  <li> <code>'Connectable'</code> (supports the <code>XConnectable</code>
48 *   interface):
49 *   another 0bject to connect </li>
50 * </ul>
51 * After test completion object environment has to be recreated.
52 * @see com.sun.star.io.XConnectable
53 */
54 public class _XConnectable extends MultiMethodTest {
55 
56     public XConnectable oObj = null;
57 
58     private XConnectable xConnect = null ;
59 
60     /**
61      * Get another connectable object from object relations.
62     */
63     public void before() {
64         XInterface x = (XInterface)tEnv.getObjRelation("Connectable");
65         xConnect = (XConnectable)UnoRuntime.queryInterface(
66                                                     XConnectable.class, x) ;
67     }
68 
69     /**
70     * Test calls the method using interface <code>XConnectable</code>
71     * received in method <code>before()</code> as parameter. <p>
72     * Has <b> OK </b> status if the method successfully returns. <p>
73     */
74     public void _setPredecessor() {
75         oObj.setPredecessor(xConnect) ;
76 
77         tRes.tested("setPredecessor()", true) ;
78     }
79 
80     /**
81     * Test calls the method and compares returned value with value that was
82     * set in the method <code>setPredecessor()</code>. <p>
83     * Has <b> OK </b> status if values are equal. <p>
84     * The following method tests are to be completed successfully before :
85     * <ul>
86     *  <li> <code> setPredecessor() </code></li>
87     * </ul>
88     */
89     public void _getPredecessor() {
90         requiredMethod("setPredecessor()") ;
91 
92         XConnectable gConnect = oObj.getPredecessor() ;
93 
94         tRes.tested("getPredecessor()", xConnect.equals(gConnect)) ;
95     }
96 
97     /**
98     * Test calls the method using interface <code>XConnectable</code>
99     * received in method <code>before()</code> as parameter. <p>
100     * Has <b> OK </b> status if the method successfully returns. <p>
101     */
102     public void _setSuccessor() {
103         oObj.setSuccessor(xConnect) ;
104 
105         tRes.tested("setSuccessor()", true) ;
106     }
107 
108     /**
109     * Test calls the method and compares returned value with value that was
110     * set in the method <code>setSuccessor()</code>. <p>
111     * Has <b> OK </b> status if values are equal. <p>
112     * The following method tests are to be completed successfully before :
113     * <ul>
114     *  <li> <code> setSuccessor() </code></li>
115     * </ul>
116     */
117     public void _getSuccessor() {
118         requiredMethod("setSuccessor()") ;
119 
120         XConnectable gConnect = oObj.getSuccessor() ;
121 
122         tRes.tested("getSuccessor()", xConnect.equals(gConnect)) ;
123     }
124 
125     /**
126     * Forces object environment recreation.
127     */
128     public void after() {
129         this.disposeEnvironment() ;
130     }
131 }
132 
133