Skip to content

Commit

Permalink
8273685: Remove jtreg tag manual=yesno for java/awt/Graphics/LCDTextA…
Browse files Browse the repository at this point in the history
…ndGraphicsState.java & show test instruction

Reviewed-by: aivanov, pbansal
  • Loading branch information
lawrence-andrew authored and aivanov-jdk committed Sep 17, 2021
1 parent 8302061 commit 2a2e919
Showing 1 changed file with 86 additions and 24 deletions.
110 changes: 86 additions & 24 deletions test/jdk/java/awt/Graphics/LCDTextAndGraphicsState.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,72 +21,134 @@
* questions.
*/

/**
/*
* @test
* @bug 6576507
* @summary Both lines of text should be readable
* @run main/manual=yesno LCDTextAndGraphicsState
* @run main/manual LCDTextAndGraphicsState
*/
import java.awt.*;
import java.awt.geom.*;

import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.geom.RoundRectangle2D;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class LCDTextAndGraphicsState extends Component {

String text = "This test passes only if this text appears SIX TIMES";
private static final Frame testFrame = new Frame("Composite and Text Test");
private static final String text = "This test passes only if this text appears SIX TIMES else fail";
private static volatile boolean testResult;
private static volatile CountDownLatch countDownLatch;

public void paint(Graphics g) {

Graphics2D g2d = (Graphics2D)g.create();
g2d.setColor(Color.white);
g2d.fillRect(0,0,getSize().width, getSize().height);

test1(g.create(0, 0, 500, 200));
test2(g.create(0, 200, 500, 200));
test3(g.create(0, 400, 500, 200));
test1(g.create(0, 0, 500, 100));
test2(g.create(0, 100, 500, 100));
test3(g.create(0, 200, 500, 100));
}

public void test1(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g2d.setColor(Color.black);
g2d.drawString(text, 10, 50);
g2d.drawString(text, 10, 20);
g2d.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.9f));
g2d.drawString(text, 10, 80);
g2d.drawString(text, 10, 50);
}

public void test2(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g2d.setColor(Color.black);
g2d.drawString(text, 10, 50);
g2d.drawString(text, 10, 20);
g2d.setPaint(new GradientPaint(
0f, 0f, Color.BLACK, 100f, 100f, Color.GRAY));
g2d.drawString(text, 10, 80);
g2d.drawString(text, 10, 50);
}

public void test3(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g2d.setColor(Color.black);
g2d.drawString(text, 10, 50);
Shape s = new RoundRectangle2D.Double(0, 60, 400, 50, 5, 5);
g2d.drawString(text, 10, 20);
Shape s = new RoundRectangle2D.Double(0, 30, 400, 50, 5, 5);
g2d.clip(s);
g2d.drawString(text, 10, 80);
g2d.drawString(text, 10, 50);
}

public Dimension getPreferredSize() {
return new Dimension(500,600);
return new Dimension(500,300);
}

public static void disposeUI() {
countDownLatch.countDown();
testFrame.dispose();
}

public static void main(String[] args) throws Exception {
public static void createTestUI() {
testFrame.add(new LCDTextAndGraphicsState(), BorderLayout.NORTH);
Panel resultButtonPanel = new Panel(new GridLayout(1, 2));
Button passButton = new Button("Pass");
passButton.addActionListener((ActionEvent e) -> {
testResult = true;
disposeUI();
});
Button failButton = new Button("Fail");
failButton.addActionListener(e -> {
testResult = false;
disposeUI();
});
resultButtonPanel.add(passButton);
resultButtonPanel.add(failButton);

Panel controlUI = new Panel(new BorderLayout());
TextArea instructions = new TextArea(
"Instructions:\n" +
"If you see the text six times above, press Pass.\n" +
"If not, press Fail.",
3,
50,
TextArea.SCROLLBARS_NONE
);
instructions.setEditable(false);
controlUI.add(instructions, BorderLayout.CENTER);
controlUI.add(resultButtonPanel, BorderLayout.SOUTH);

testFrame.add(controlUI, BorderLayout.SOUTH);
testFrame.pack();
testFrame.setLocationRelativeTo(null);
testFrame.setVisible(true);
}

Frame f = new Frame("Composite and Text Test");
f.add(new LCDTextAndGraphicsState(), BorderLayout.CENTER);
f.pack();
f.setVisible(true);
public static void main(String[] args) throws InterruptedException {
countDownLatch = new CountDownLatch(1);
createTestUI();
if (!countDownLatch.await(10, TimeUnit.MINUTES)) {
throw new RuntimeException("Timeout : No action was performed on the test UI.");
}
if (!testResult) {
throw new RuntimeException("Test failed!");
}
}
}

5 comments on commit 2a2e919

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 2a2e919 Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2a2e919 Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-2a2e9190 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2a2e9190 from the openjdk/jdk repository.

The commit being backported was authored by lawrence.andrews on 17 Sep 2021 and was reviewed by Alexey Ivanov and Pankaj Bansal.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-2a2e9190:GoeLin-backport-2a2e9190
$ git checkout GoeLin-backport-2a2e9190
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-2a2e9190

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 2a2e919 Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2a2e919 Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-2a2e9190 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2a2e9190 from the openjdk/jdk repository.

The commit being backported was authored by lawrence.andrews on 17 Sep 2021 and was reviewed by Alexey Ivanov and Pankaj Bansal.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-2a2e9190:GoeLin-backport-2a2e9190
$ git checkout GoeLin-backport-2a2e9190
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-2a2e9190

Please sign in to comment.