tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / datatransfer / clipboard / _XClipboard.java
blob95606a6845617437d7f3ae75e7142a421f55e9e6
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 ifc.datatransfer.clipboard;
21 import lib.MultiMethodTest;
22 import lib.StatusException;
24 import com.sun.star.datatransfer.DataFlavor;
25 import com.sun.star.datatransfer.XTransferable;
26 import com.sun.star.datatransfer.clipboard.XClipboard;
27 import com.sun.star.datatransfer.clipboard.XClipboardOwner;
29 /**
30 * Testing <code>com.sun.star.datatransfer.clipboard.XClipboard</code>
31 * interface methods :
32 * <ul>
33 * <li><code> getContents()</code></li>
34 * <li><code> setContents()</code></li>
35 * <li><code> getName()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.datatransfer.clipboard.XClipboard
40 public class _XClipboard extends MultiMethodTest {
42 public XClipboard oObj;
44 MyTransferable myTransferable1;
45 MyTransferable myTransferable2;
47 /**
48 * <code>XClipboardOwner</code> interface implementation which
49 * stores parameters passed to <code>lostOwnership</code> method.
51 static class MyOwner implements XClipboardOwner {
53 public void lostOwnership(XClipboard board, XTransferable contents) {
58 /**
59 * Simplest <code>XTransferable</code> interface implementation.
61 static class MyTransferable implements XTransferable {
62 public Object getTransferData(DataFlavor dataFlavor) {
63 return "";
66 public com.sun.star.datatransfer.DataFlavor[] getTransferDataFlavors() {
67 return new DataFlavor[0];
70 public boolean isDataFlavorSupported(DataFlavor dataFlavor) {
71 return false;
76 /**
77 * Initially sets the content of the clipboard.
79 @Override
80 public void before() {
81 oObj.setContents(myTransferable1 = new MyTransferable(), new MyOwner());
84 /**
85 * Gets the name of the clipboard. <p>
86 * Has <b>OK</b> status if not <code>null</code> value returned.
88 public void _getName() {
89 String name = oObj.getName();
90 tRes.tested("getName()", name != null);
93 /**
94 * Gets the contents of the clipboard. <p>
95 * Has <b>OK</b> status if the content obtained is equal to content
96 * set in <code>before</code> method.
98 public void _getContents() {
99 tRes.tested("getContents()", oObj.getContents() == myTransferable1);
103 * Sets new contents for the clipboard. Then checks if it was set,
104 * and if <code>lostOwnership()</code> notification of the previous
105 * contents was called with appropriate parameters.<p>
106 * Has <b> OK </b> status if <code>getContents</code> returns the same
107 * object which is set, and notification was received.
108 * The following method tests are to be completed successfully before :
109 * <ul>
110 * <li> <code> getContents() </code> : for right testing order </li>
111 * </ul>
113 public void _setContents() {
114 requiredMethod("getContents()");
115 myTransferable2 = new MyTransferable();
117 oObj.setContents(myTransferable2, new MyOwner());
119 log.println("sleeping for 1 second");
121 try {
122 Thread.sleep(1000);
123 } catch (InterruptedException e) {
124 log.println("interrupted");
125 e.printStackTrace(log);
126 throw new StatusException("Operation interrupted", e);
129 tRes.tested("setContents()", oObj.getContents() == myTransferable2);