< prev index next >

test/javax/swing/text/Utilities/8142966/SwingFontMetricsTest.java

Print this page
rev 17561 : 8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
Summary: Add new keyword 'printer'. Some minor test fixes to show headless exception. Add some @requires windows.
   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 import java.awt.Font;
  24 import java.awt.Graphics;
  25 import java.util.concurrent.CountDownLatch;
  26 import java.util.concurrent.TimeUnit;
  27 import javax.swing.JFrame;
  28 import javax.swing.JLabel;
  29 import javax.swing.SwingUtilities;
  30 
  31 /**
  32  * @test

  33  * @bug 8142966
  34  * @summary Wrong cursor position in text components on HiDPI display
  35  * @run main/othervm -Dsun.java2d.uiScale=2 SwingFontMetricsTest
  36  */
  37 public class SwingFontMetricsTest {
  38 
  39     private static final String LOWER_CASE_TEXT = "the quick brown fox jumps over the lazy dog";
  40     private static final String UPPER_CASE_TEXT = LOWER_CASE_TEXT.toUpperCase();
  41     private static final String TEXT = LOWER_CASE_TEXT + UPPER_CASE_TEXT;
  42     private static boolean passed = false;
  43     private static CountDownLatch latch = new CountDownLatch(1);
  44 
  45     public static void main(String[] args) throws Exception {
  46         SwingUtilities.invokeAndWait(SwingFontMetricsTest::createAndShowGUI);
  47         latch.await(5, TimeUnit.SECONDS);
  48 
  49         if (!passed) {
  50             throw new RuntimeException("Test Failed!");
  51         }
  52     }


   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 import java.awt.Font;
  24 import java.awt.Graphics;
  25 import java.util.concurrent.CountDownLatch;
  26 import java.util.concurrent.TimeUnit;
  27 import javax.swing.JFrame;
  28 import javax.swing.JLabel;
  29 import javax.swing.SwingUtilities;
  30 
  31 /**
  32  * @test
  33  * @key headful
  34  * @bug 8142966
  35  * @summary Wrong cursor position in text components on HiDPI display
  36  * @run main/othervm -Dsun.java2d.uiScale=2 SwingFontMetricsTest
  37  */
  38 public class SwingFontMetricsTest {
  39 
  40     private static final String LOWER_CASE_TEXT = "the quick brown fox jumps over the lazy dog";
  41     private static final String UPPER_CASE_TEXT = LOWER_CASE_TEXT.toUpperCase();
  42     private static final String TEXT = LOWER_CASE_TEXT + UPPER_CASE_TEXT;
  43     private static boolean passed = false;
  44     private static CountDownLatch latch = new CountDownLatch(1);
  45 
  46     public static void main(String[] args) throws Exception {
  47         SwingUtilities.invokeAndWait(SwingFontMetricsTest::createAndShowGUI);
  48         latch.await(5, TimeUnit.SECONDS);
  49 
  50         if (!passed) {
  51             throw new RuntimeException("Test Failed!");
  52         }
  53     }


< prev index next >