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.sheet;
29 
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
33 
34 import com.sun.star.sheet.XDDELink;
35 
36 /**
37 * Testing <code>com.sun.star.sheet.XDDELink</code>
38 * interface methods :
39 * <ul>
40 *  <li><code> getApplication()</code></li>
41 *  <li><code> getTopic()</code></li>
42 *  <li><code> getItem()</code></li>
43 * </ul> <p>
44 * This test needs the following object relations :
45 * <ul>
46 *  <li> <code>'APPLICATION'</code> (of type <code>String</code>):
47 *   to have application name </li>
48 *  <li> <code>'ITEM'</code> (of type <code>String</code>):
49 *   to have DDE item </li>
50 *  <li> <code>'TOPIC'</code> (of type <code>String</code>):
51 *   to have DDE topic </li>
52 * <ul> <p>
53 * @see com.sun.star.sheet.XDDELink
54 */
55 public class _XDDELink extends MultiMethodTest {
56     public XDDELink oObj = null;
57 
58     /**
59     * Test calls the method and compares returned value to value obtained by
60     * relation <code>'APPLICATION'</code>. <p>
61     * Has <b> OK </b> status if values are equal. <p>
62     */
63     public void _getApplication(){
64         log.println("testing getApplication()");
65         boolean bResult = false;
66 
67         String oAppl = (String)tEnv.getObjRelation("APPLICATION");
68         if (oAppl == null) throw new StatusException(Status.failed
69             ("Relation 'APPLICATION' not found"));
70 
71         bResult = oAppl.equals(oObj.getApplication());
72         tRes.tested("getApplication()", bResult) ;
73     }
74 
75     /**
76     * Test calls the method and compares returned value to value obtained by
77     * relation <code>'ITEM'</code>. <p>
78     * Has <b> OK </b> status if values are equal. <p>
79     */
80     public void _getItem(){
81         log.println("testing getItem()");
82         boolean bResult = false;
83         String sItem = oObj.getItem();
84 
85         String oItem = (String)tEnv.getObjRelation("ITEM");
86         if (oItem == null) throw new StatusException(Status.failed
87             ("Relation 'ITEM' not found"));
88 
89         bResult = oItem.equals(sItem);
90         tRes.tested("getItem()", bResult) ;
91     }
92 
93     /**
94     * Test calls the method and compares returned value to value obtained by
95     * relation <code>'TOPIC'</code>. <p>
96     * Has <b> OK </b> status if values are equal. <p>
97     */
98     public void _getTopic(){
99         log.println("testing getTopic()");
100         boolean bResult = false;
101         String sTopic = oObj.getTopic();
102 
103         String oTopic = (String)tEnv.getObjRelation("TOPIC");
104         if (oTopic == null) throw new StatusException(Status.failed
105             ("Relation 'TOPIC' not found"));
106 
107         bResult = oTopic.equals(sTopic);
108         tRes.tested("getTopic()", bResult) ;
109     }
110 }
111 
112