5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @bug 6392086 8014725 26 @summary Tests basic DnD functionality in an applet 27 @author Alexey Utkin, Semyon Sadetsky 28 @run applet HTMLTransferTest.html 29 */ 30 31 /** 32 * HTMLTransferTest.java 33 * 34 * summary: tests that HTMLs of all supported native HTML formats 35 * are transfered properly 36 */ 37 38 import java.applet.Applet; 39 import java.awt.*; 40 import java.awt.datatransfer.*; 41 import java.io.*; 42 43 44 public class HTMLTransferTest extends Applet { 45 public static final int CODE_NOT_RETURNED = 100; 46 public static final int CODE_CONSUMER_TEST_FAILED = 101; 47 public static final int CODE_FAILURE = 102; 48 public static DataFlavor[] HTMLFlavors = null; 49 public static DataFlavor SyncFlavor = null; 50 static { 51 try{ 52 HTMLFlavors = new DataFlavor[] { 53 new DataFlavor("text/html; document=selection; Class=" + InputStream.class.getName() + "; charset=UTF-8"), 54 new DataFlavor("text/html; document=selection; Class=" + String.class.getName() + "; charset=UTF-8") 55 }; 56 SyncFlavor = new DataFlavor( 57 "application/x-java-serialized-object; class=" 58 + SyncMessage.class.getName() 59 + "; charset=UTF-8" 60 ); 61 }catch(Exception e){ 62 e.printStackTrace(); 63 } 64 } 65 66 private THTMLProducer imPr; 67 private int returnCode = CODE_NOT_RETURNED; 68 69 public void init() { 70 initImpl(); 71 72 } // init() 73 74 private void initImpl() { 75 imPr = new THTMLProducer(); 76 imPr.begin(); 77 } 78 79 80 public void start() { 81 try { 82 String stFormats = ""; 83 84 String iniMsg = "Testing formats from the list:\n"; 85 for (int i = 0; i < HTMLTransferTest.HTMLFlavors.length; i++) { 86 stFormats += "\"" + HTMLTransferTest.HTMLFlavors[i].getMimeType() + "\"\n"; 87 } 88 System.out.println(iniMsg + stFormats); | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 6392086 8014725 28 @summary tests that HTMLs of all supported native HTML formats are transfered 29 properly 30 @run main/othervm HTMLTransferTest 31 */ 32 33 import java.awt.*; 34 import java.awt.datatransfer.*; 35 import java.io.*; 36 37 public class HTMLTransferTest { 38 public static final int CODE_NOT_RETURNED = 100; 39 public static final int CODE_CONSUMER_TEST_FAILED = 101; 40 public static final int CODE_FAILURE = 102; 41 public static DataFlavor[] HTMLFlavors = null; 42 public static DataFlavor SyncFlavor = null; 43 static { 44 try{ 45 HTMLFlavors = new DataFlavor[] { 46 new DataFlavor("text/html; document=selection; Class=" + InputStream.class.getName() + "; charset=UTF-8"), 47 new DataFlavor("text/html; document=selection; Class=" + String.class.getName() + "; charset=UTF-8") 48 }; 49 SyncFlavor = new DataFlavor( 50 "application/x-java-serialized-object; class=" 51 + SyncMessage.class.getName() 52 + "; charset=UTF-8" 53 ); 54 }catch(Exception e){ 55 e.printStackTrace(); 56 } 57 } 58 59 private THTMLProducer imPr; 60 private int returnCode = CODE_NOT_RETURNED; 61 62 public static void main(final String[] args) { 63 HTMLTransferTest app = new HTMLTransferTest(); 64 app.init(); 65 app.start(); 66 } 67 68 public void init() { 69 initImpl(); 70 71 } // init() 72 73 private void initImpl() { 74 imPr = new THTMLProducer(); 75 imPr.begin(); 76 } 77 78 79 public void start() { 80 try { 81 String stFormats = ""; 82 83 String iniMsg = "Testing formats from the list:\n"; 84 for (int i = 0; i < HTMLTransferTest.HTMLFlavors.length; i++) { 85 stFormats += "\"" + HTMLTransferTest.HTMLFlavors[i].getMimeType() + "\"\n"; 86 } 87 System.out.println(iniMsg + stFormats); |