Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8285617: Fix java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.j…
…ava manual test

Reviewed-by: prr, psadhukhan
  • Loading branch information
lawrence-andrew authored and prsadhuk committed Apr 27, 2022
1 parent 16a8ebb commit e7c3b9d
Showing 1 changed file with 42 additions and 23 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, 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,42 +21,59 @@
* questions.
*/

/**
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.lang.reflect.InvocationTargetException;

/*
* @test
* @bug 6581756
* @library ../../../regtesthelpers
* @build PassFailJFrame
* @summary Test printing of images which need to have src area clipped
* @run main/manual=yesno PrintARGBImage
* @run main/manual PrintARGBImage
*/

import java.awt.*;
import java.awt.image.*;
import java.awt.print.*;

public class PrintARGBImage implements Printable {

static String[] text = {
"This is a manual test which needs a printer installed",
"If you have no printer installed you CANNOT use this test",
"It runs automatically and sends one page to the default printer",
"It passes if the text shows through the rectangular image",
};
public static void main(String[] args) throws InterruptedException,
InvocationTargetException {
if (PrinterJob.lookupPrintServices().length > 0) {

public static void main( String[] args ) {

for (int i=0;i<text.length;i++) {
System.out.println(text[i]);
}
String instruction = """
This is a manual test which needs a printer installed.
If you have no printer installed the test passes automatically.
The test runs automatically and sends one page to the default printer.
The test passes if the text shows through the rectangular image.
""";

try {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PrintARGBImage());
pj.print();
PassFailJFrame passFailJFrame = new PassFailJFrame(instruction, 10);
try {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PrintARGBImage());
pj.print();
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException("Exception whilst printing.");
}

passFailJFrame.awaitAndCheck();

} else {
System.out.println("Printer not configured or available."
+ " Test cannot continue.");
PassFailJFrame.forcePass();
}
}

public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException{
throws PrinterException {

if (pageIndex != 0) {
return NO_SUCH_PAGE;
Expand All @@ -77,3 +94,5 @@ public int print(Graphics g, PageFormat pf, int pageIndex)
return PAGE_EXISTS;
}
}


3 comments on commit e7c3b9d

@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 e7c3b9d Aug 2, 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 e7c3b9d Aug 2, 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-e7c3b9de 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 e7c3b9de from the openjdk/jdk repository.

The commit being backported was authored by lawrence.andrews on 27 Apr 2022 and was reviewed by Phil Race and Prasanta Sadhukhan.

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-e7c3b9de:GoeLin-backport-e7c3b9de
$ git checkout GoeLin-backport-e7c3b9de
# 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-e7c3b9de

Please sign in to comment.