< prev index next >

test/jdk/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java

Print this page
rev 51542 : 8210039: move OSInfo to top level testlibrary
Reviewed-by: duke


  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 7075105
  28  * @summary WIN: Provide a way to format HTML on drop
  29  * @author Denis Fokin: area=datatransfer
  30  * @requires (os.family == "windows")
  31  * @library ../../../../lib/testlibrary
  32  * @build HtmlTransferable PutAllHtmlFlavorsOnClipboard
  33  * @build PutOnlyAllHtmlFlavorOnClipboard PutSelectionAndFragmentHtmlFlavorsOnClipboard
  34  * @build jdk.testlibrary.OSInfo
  35  * @run main HTMLDataFlavorTest
  36  */
  37 


  38 import java.awt.*;
  39 import java.awt.datatransfer.*;
  40 import java.io.*;
  41 import java.util.HashMap;
  42 
  43 public class HTMLDataFlavorTest {
  44 
  45     private static HashMap<DataFlavor, String> dataFlavors = new HashMap<DataFlavor, String>();
  46 
  47 
  48     public static void main(String[] args) throws IOException, UnsupportedFlavorException {
  49 
  50         if (jdk.testlibrary.OSInfo.getOSType() != jdk.testlibrary.OSInfo.OSType.WINDOWS) {
  51             System.err.println("This test is for MS Windows only. Considered passed.");
  52             return;
  53         }
  54 
  55         dataFlavors.put(DataFlavor.allHtmlFlavor, HtmlTransferable.ALL_HTML_AS_STRING);
  56         dataFlavors.put(DataFlavor.fragmentHtmlFlavor, HtmlTransferable.FRAGMENT_HTML_AS_STRING);
  57         dataFlavors.put(DataFlavor.selectionHtmlFlavor, HtmlTransferable.SELECTION_HTML_AS_STRING);
  58 
  59         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  60         resetClipboardContent(clipboard);
  61 
  62         // 1. Put all three html flavors on clipboard.
  63         //    Get the data within the same JVM
  64         //    Expect that the resulted html is the selection
  65         //    wrapped in all three types
  66 
  67         clipboard.setContents(new HtmlTransferable(HtmlTransferable.htmlDataFlavors),null);
  68 
  69         // Test local transfer
  70         testClipboardContent(clipboard, HtmlTransferable.htmlDataFlavors);




  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 7075105
  28  * @summary WIN: Provide a way to format HTML on drop
  29  * @author Denis Fokin: area=datatransfer
  30  * @requires (os.family == "windows")
  31  * @library /test/lib
  32  * @build HtmlTransferable PutAllHtmlFlavorsOnClipboard
  33  * @build PutOnlyAllHtmlFlavorOnClipboard PutSelectionAndFragmentHtmlFlavorsOnClipboard
  34  * @build jdk.test.lib.Platform
  35  * @run main HTMLDataFlavorTest
  36  */
  37 
  38 import jdk.test.lib.Platform;
  39 
  40 import java.awt.*;
  41 import java.awt.datatransfer.*;
  42 import java.io.*;
  43 import java.util.HashMap;
  44 
  45 public class HTMLDataFlavorTest {
  46 
  47     private static HashMap<DataFlavor, String> dataFlavors = new HashMap<DataFlavor, String>();
  48 
  49 
  50     public static void main(String[] args) throws IOException, UnsupportedFlavorException {
  51 
  52         if (!Platform.isWindows()) {
  53             System.err.println("This test is for MS Windows only. Considered passed.");
  54             return;
  55         }
  56 
  57         dataFlavors.put(DataFlavor.allHtmlFlavor, HtmlTransferable.ALL_HTML_AS_STRING);
  58         dataFlavors.put(DataFlavor.fragmentHtmlFlavor, HtmlTransferable.FRAGMENT_HTML_AS_STRING);
  59         dataFlavors.put(DataFlavor.selectionHtmlFlavor, HtmlTransferable.SELECTION_HTML_AS_STRING);
  60 
  61         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  62         resetClipboardContent(clipboard);
  63 
  64         // 1. Put all three html flavors on clipboard.
  65         //    Get the data within the same JVM
  66         //    Expect that the resulted html is the selection
  67         //    wrapped in all three types
  68 
  69         clipboard.setContents(new HtmlTransferable(HtmlTransferable.htmlDataFlavors),null);
  70 
  71         // Test local transfer
  72         testClipboardContent(clipboard, HtmlTransferable.htmlDataFlavors);


< prev index next >