1 19 package org.openide.util.datatransfer; 20 21 import java.awt.AWTEvent ; 22 import java.awt.Component ; 23 import java.awt.Dialog ; 24 import java.awt.Graphics ; 25 import java.awt.Toolkit ; 26 import java.awt.datatransfer.DataFlavor ; 27 import java.awt.event.AWTEventListener ; 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 import java.util.ArrayList ; 31 import java.util.Arrays ; 32 import java.util.EventListener ; 33 import java.util.HashSet ; 34 import java.util.List ; 35 import javax.swing.JPanel ; 36 import javax.swing.SwingUtilities ; 37 import javax.swing.Timer ; 38 import junit.textui.TestRunner; 39 import org.openide.util.Utilities; 40 import org.netbeans.junit.NbTestCase; 41 import org.netbeans.junit.NbTestSuite; 42 import org.openide.util.AsyncGUIJob; 43 44 48 public class ExTransferableTest extends NbTestCase { 49 50 public ExTransferableTest (String testName) { 51 super(testName); 52 } 53 54 public static void main(java.lang.String [] args) { 55 TestRunner.run(new NbTestSuite(ExTransferableTest.class)); 56 } 57 58 public void testExTranferableKeepsOrderOfInsertedDataFlavors () throws Exception { 59 HashSet set = new HashSet (); 60 set.add (DataFlavor.stringFlavor); 61 set.add (DataFlavor.imageFlavor); 62 63 DataFlavor [] arr = (DataFlavor [])set.toArray (new DataFlavor [2]); 64 65 ExTransferable t = ExTransferable.create (ExTransferable.EMPTY); 66 t.put (new Sin (arr[1])); 69 t.put (new Sin (arr[0])); 70 71 72 List res = Arrays.asList (t.getTransferDataFlavors ()); 73 74 assertEquals ("First inserted is first", 0, res.indexOf (arr[1])); 75 assertEquals ("Second inserted is second", 1, res.indexOf (arr[0])); 76 } 77 78 private static final class Sin extends ExTransferable.Single { 79 public Sin (DataFlavor f) { 80 super (f); 81 } 82 83 protected Object getData () { 84 return null; 85 } 86 } } 88 | Popular Tags |