1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
91 |
83 |
92 String iniMsg = "Testing formats from the list:\n"; |
84 String iniMsg = "Testing formats from the list:\n"; |
93 for (int i = 0; i < HTMLTransferTest.HTMLFlavors.length; i++) { |
85 for (int i = 0; i < HTMLTransferTest.HTMLFlavors.length; i++) { |
94 stFormats += "\"" + HTMLTransferTest.HTMLFlavors[i].getMimeType() + "\"\n"; |
86 stFormats += "\"" + HTMLTransferTest.HTMLFlavors[i].getMimeType() + "\"\n"; |
95 } |
87 } |
96 Sysout.println(iniMsg + stFormats); |
88 System.out.println(iniMsg + stFormats); |
97 System.err.println("===>" + iniMsg + stFormats); |
89 System.err.println("===>" + iniMsg + stFormats); |
98 |
90 |
99 String javaPath = System.getProperty("java.home", ""); |
91 String javaPath = System.getProperty("java.home", ""); |
100 String cmd = javaPath + File.separator + "bin" + File.separator |
92 String cmd = javaPath + File.separator + "bin" + File.separator |
101 + "java -cp " + System.getProperty("test.classes", ".") + |
93 + "java -cp " + System.getProperty("test.classes", ".") + |
647 throw new UnsupportedFlavorException(flavor); |
639 throw new UnsupportedFlavorException(flavor); |
648 } |
640 } |
649 } |
641 } |
650 |
642 |
651 } // class HTMLSelection |
643 } // class HTMLSelection |
652 |
|
653 |
|
654 /**************************************************** |
|
655 Standard Test Machinery |
|
656 DO NOT modify anything below -- it's a standard |
|
657 chunk of code whose purpose is to make user |
|
658 interaction uniform, and thereby make it simpler |
|
659 to read and understand someone else's test. |
|
660 ****************************************************/ |
|
661 class Sysout |
|
662 { |
|
663 private static TestDialog dialog; |
|
664 |
|
665 public static void createDialogWithInstructions( String[] instructions ) |
|
666 { |
|
667 dialog = new TestDialog( new Frame(), "Instructions" ); |
|
668 dialog.printInstructions( instructions ); |
|
669 dialog.show(); |
|
670 println( "Any messages for the tester will display here." ); |
|
671 } |
|
672 |
|
673 public static void createDialog( ) |
|
674 { |
|
675 dialog = new TestDialog( new Frame(), "Instructions" ); |
|
676 String[] defInstr = { "Instructions will appear here. ", "" } ; |
|
677 dialog.printInstructions( defInstr ); |
|
678 dialog.show(); |
|
679 println( "Any messages for the tester will display here." ); |
|
680 } |
|
681 |
|
682 |
|
683 public static void printInstructions( String[] instructions ) |
|
684 { |
|
685 dialog.printInstructions( instructions ); |
|
686 } |
|
687 |
|
688 |
|
689 public static void println( String messageIn ) |
|
690 { |
|
691 dialog.displayMessage( messageIn ); |
|
692 } |
|
693 |
|
694 }// Sysout class |
|
695 |
|
696 class TestDialog extends Dialog |
|
697 { |
|
698 |
|
699 TextArea instructionsText; |
|
700 TextArea messageText; |
|
701 int maxStringLength = 80; |
|
702 |
|
703 //DO NOT call this directly, go through Sysout |
|
704 public TestDialog( Frame frame, String name ) |
|
705 { |
|
706 super( frame, name ); |
|
707 int scrollBoth = TextArea.SCROLLBARS_BOTH; |
|
708 instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); |
|
709 add( "North", instructionsText ); |
|
710 |
|
711 messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); |
|
712 add("South", messageText); |
|
713 |
|
714 pack(); |
|
715 |
|
716 show(); |
|
717 }// TestDialog() |
|
718 |
|
719 //DO NOT call this directly, go through Sysout |
|
720 public void printInstructions( String[] instructions ) |
|
721 { |
|
722 //Clear out any current instructions |
|
723 instructionsText.setText( "" ); |
|
724 |
|
725 //Go down array of instruction strings |
|
726 |
|
727 String printStr, remainingStr; |
|
728 for( int i=0; i < instructions.length; i++ ) |
|
729 { |
|
730 //chop up each into pieces maxSringLength long |
|
731 remainingStr = instructions[ i ]; |
|
732 while( remainingStr.length() > 0 ) |
|
733 { |
|
734 //if longer than max then chop off first max chars to print |
|
735 if( remainingStr.length() >= maxStringLength ) |
|
736 { |
|
737 //Try to chop on a word boundary |
|
738 int posOfSpace = remainingStr. |
|
739 lastIndexOf(' ', maxStringLength - 1); |
|
740 |
|
741 if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; |
|
742 |
|
743 printStr = remainingStr.substring( 0, posOfSpace + 1 ); |
|
744 remainingStr = remainingStr.substring( posOfSpace + 1 ); |
|
745 } |
|
746 //else just print |
|
747 else |
|
748 { |
|
749 printStr = remainingStr; |
|
750 remainingStr = ""; |
|
751 } |
|
752 |
|
753 instructionsText.append( printStr + "\n" ); |
|
754 |
|
755 }// while |
|
756 |
|
757 }// for |
|
758 |
|
759 }//printInstructions() |
|
760 |
|
761 //DO NOT call this directly, go through Sysout |
|
762 public void displayMessage( String messageIn ) |
|
763 { |
|
764 messageText.append( messageIn + "\n" ); |
|
765 } |
|
766 |
|
767 }// TestDialog class |
|