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.awt;
25 
26 
27 import lib.MultiMethodTest;
28 import lib.Status;
29 import lib.StatusException;
30 
31 import com.sun.star.awt.XDataTransferProviderAccess;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.datatransfer.clipboard.XClipboard;
34 import com.sun.star.datatransfer.dnd.XDragGestureRecognizer;
35 import com.sun.star.datatransfer.dnd.XDragSource;
36 import com.sun.star.datatransfer.dnd.XDropTarget;
37 
38 /**
39 * Testing <code>com.sun.star.awt.XDataTransferProviderAccess</code>
40 * interface methods :
41 * <ul>
42 *  <li><code> getDragGestureRecognizer()</code></li>
43 *  <li><code> getDragSource()</code></li>
44 *  <li><code> getDropTarget()</code></li>
45 *  <li><code> getClipboard()</code></li>
46 * </ul> <p>
47 * This test needs the following object relations :
48 * <ul>
49 *  <li> <code>'XDataTransferProviderAccess.XWindow'</code>
50 *  (of type <code>com.sun.star.awt.XWindow</code>):
51 *   this window must created by the Toolkit tested. </li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.awt.XDataTransferProviderAccess
55 */
56 public class _XDataTransferProviderAccess extends MultiMethodTest {
57 
58     public XDataTransferProviderAccess oObj = null;
59     protected XWindow win = null ;
60 
61     /**
62     * Retrieves object relations.
63     * @throws StatusException If one of relations not found.
64     */
before()65     public void before() {
66         win = (XWindow) tEnv.getObjRelation
67             ("XDataTransferProviderAccess.XWindow") ;
68         if (win == null) throw new StatusException(Status.failed
69             ("Relation not found")) ;
70     }
71 
72     /**
73     * Tries to get gesture recognizer for the window passed as
74     * relation. <p>
75     * Has <b> OK </b> status if not <code>null</code> value returned
76     */
_getDragGestureRecognizer()77     public void _getDragGestureRecognizer() {
78 
79         boolean result = true ;
80         XDragGestureRecognizer rec = oObj.getDragGestureRecognizer(win) ;
81 
82         result = rec != null ;
83 
84         tRes.tested("getDragGestureRecognizer()", result) ;
85     }
86 
87     /**
88     * Tries to get drag source for the window passed as
89     * relation. <p>
90     * Has <b> OK </b> status if not <code>null</code> value returned
91     */
_getDragSource()92     public void _getDragSource() {
93 
94         boolean result = true ;
95         XDragSource src = oObj.getDragSource(win) ;
96 
97         result = src != null ;
98 
99         tRes.tested("getDragSource()", result) ;
100     }
101 
102     /**
103     * Tries to get drop target for the window passed as
104     * relation. <p>
105     * Has <b> OK </b> status if not <code>null</code> value returned
106     */
_getDropTarget()107     public void _getDropTarget() {
108 
109         boolean result = true ;
110         XDropTarget targ = oObj.getDropTarget(win) ;
111 
112         result = targ != null ;
113 
114         tRes.tested("getDropTarget()", result) ;
115     }
116 
117     /**
118     * Tries to obtain default clipboard.<p>
119     * Has <b> OK </b> status if not <code>null</code> value returned.
120     */
_getClipboard()121     public void _getClipboard() {
122 
123         boolean result = true ;
124         XClipboard cb = oObj.getClipboard("") ;
125 
126         result = cb != null ;
127 
128         tRes.tested("getClipboard()", result) ;
129     }
130 }
131 
132