Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8274456: Remove jtreg tag manual=yesno java/awt/print/PrinterJob/Page…
…DialogTest.java

Reviewed-by: serb
  • Loading branch information
lawrence-andrew authored and mrserb committed Oct 6, 2021
1 parent 734d1fb commit d57fb6f
Showing 1 changed file with 91 additions and 137 deletions.
228 changes: 91 additions & 137 deletions test/jdk/java/awt/print/PrinterJob/PageDialogTest.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,157 +21,111 @@
* questions.
*/

/* @test
/*
@test
@bug 6302514
@run main/manual=yesno PageDialogTest
@run main/manual PageDialogTest
@summary A toolkit modal dialog should not be blocked by Page/Print dialog.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class PageDialogTest {

public static void main(String[] args) {
String[] instructions =
{
"The test shows a Toolkit modal dialog. ",
"Click the 'Open' button. It opens a page dialog.",
"The test fails if the page dialog blocks the toolkit",
"modal dialog, otherwise it passes."
};

Sysout.createDialog( );
Sysout.printInstructions( instructions );

Dialog td = new Dialog((Frame) null, "Toolkit modal dialog",
Dialog.ModalityType.TOOLKIT_MODAL);
td.setLayout(new FlowLayout());
td.add(new Button("Dummy"));
Button tdb = new Button("Open");
tdb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
PrinterJob.getPrinterJob().pageDialog(new PageFormat());
}
public static Frame frame;
public static Dialog dialog;
public static volatile boolean testResult;
public static final CountDownLatch countDownLatch = new CountDownLatch(1);

public static void createUI() {
frame = new Frame("Test 6302514");
String instructions =
"1. Click on the 'Show Dialog' button to show a 'Toolkit Modal Dialog' \n" +
"2. Click on the 'Open PageDialog' button to show 'Page Dialog'.\n" +
"3. The test fails if the page dialog blocks the toolkit\n"+
" else test pass.\n" +
"4. Close Page dialog and 'Toolkit modal dialog'\n" +
"5. Click appropriate button to mark the test case pass or fail.\n" ;

TextArea instructionsTextArea = new TextArea( instructions, 8,
50, TextArea.SCROLLBARS_NONE );
instructionsTextArea.setEditable(false);
frame.add(BorderLayout.NORTH, instructionsTextArea);

Panel buttonPanel = new Panel(new FlowLayout());
Button passButton = new Button("pass");
passButton.setActionCommand("pass");
passButton.addActionListener(e -> {
testResult = true;
countDownLatch.countDown();
dialog.dispose();
frame.dispose();
});
td.add(tdb);
td.setSize(250, 150);
td.setVisible(true);
}
}

class Sysout {
private static TestDialog dialog;

public static void createDialogWithInstructions( String[] instructions )
{
dialog = new TestDialog( new Frame(), "Instructions" );
dialog.printInstructions( instructions );
dialog.show();
println( "Any messages for the tester will display here." );
}

public static void createDialog( )
{
dialog = new TestDialog( new Frame(), "Instructions" );
String[] defInstr = { "Instructions will appear here. ", "" } ;
dialog.printInstructions( defInstr );
dialog.show();
println( "Any messages for the tester will display here." );
}
Button failButton = new Button("fail");
failButton.addActionListener(e->{
testResult = false;
countDownLatch.countDown();
dialog.dispose();
frame.dispose();
});

Button showDialog = new Button("Show Dialog");
showDialog.addActionListener(e->{
createToolkitModalDialog();
});

public static void printInstructions( String[] instructions )
{
dialog.printInstructions( instructions );
buttonPanel.add(showDialog);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
frame.add(BorderLayout.SOUTH, buttonPanel);
frame.pack();
frame.setVisible(true);
}

public static void createToolkitModalDialog() {
dialog = new Dialog((Frame) null, "Toolkit modal dialog",
Dialog.ModalityType.TOOLKIT_MODAL);
dialog.setLayout(new FlowLayout());
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
dialog.dispose();
}
});

public static void println( String messageIn )
{
dialog.displayMessage( messageIn );
Button openPageDialogButton = new Button("Open PageDialog");
openPageDialogButton.addActionListener(e->{
PrinterJob.getPrinterJob().pageDialog(new PageFormat());
});
dialog.add(openPageDialogButton);
dialog.setSize(250, 150);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}

}// Sysout class

/**
This is part of the standard test machinery. It provides a place for the
test instructions to be displayed, and a place for interactive messages
to the user to be displayed.
To have the test instructions displayed, see Sysout.
To have a message to the user be displayed, see Sysout.
Do not call anything in this dialog directly.
*/
class TestDialog extends Dialog {

TextArea instructionsText;
TextArea messageText;
int maxStringLength = 80;

//DO NOT call this directly, go through Sysout
public TestDialog( Frame frame, String name )
{
super( frame, name );
int scrollBoth = TextArea.SCROLLBARS_BOTH;
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
add( "North", instructionsText );

messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
add("Center", messageText);

pack();

show();
}// TestDialog()

//DO NOT call this directly, go through Sysout
public void printInstructions( String[] instructions )
{
//Clear out any current instructions
instructionsText.setText( "" );

//Go down array of instruction strings

String printStr, remainingStr;
for( int i=0; i < instructions.length; i++ )
{
//chop up each into pieces maxSringLength long
remainingStr = instructions[ i ];
while( remainingStr.length() > 0 )
{
//if longer than max then chop off first max chars to print
if( remainingStr.length() >= maxStringLength )
{
//Try to chop on a word boundary
int posOfSpace = remainingStr.
lastIndexOf( ' ', maxStringLength - 1 );

if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;

printStr = remainingStr.substring( 0, posOfSpace + 1 );
remainingStr = remainingStr.substring( posOfSpace + 1 );
}
//else just print
else
{
printStr = remainingStr;
remainingStr = "";
}

instructionsText.append( printStr + "\n" );

}// while

}// for

}//printInstructions()

//DO NOT call this directly, go through Sysout
public void displayMessage( String messageIn )
{
messageText.append( messageIn + "\n" );
public static void main(String []args) throws InterruptedException {
createUI();
if ( !countDownLatch.await(5, TimeUnit.MINUTES)) {
throw new RuntimeException("Timeout : user did not perform any " +
"action on the UI.");
}
if ( !testResult) {
throw new RuntimeException("Test failed");
}
}
}

}// TestDialog class

7 comments on commit d57fb6f

@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 d57fb6f Nov 10, 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 d57fb6f Nov 10, 2022

Choose a reason for hiding this comment

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

@GoeLin The target repository jd17u-dev is not a valid target for backports.
List of valid target repositories: openjdk/jdk, openjdk/jdk11u, openjdk/jdk11u-dev, openjdk/jdk12u, openjdk/jdk13u, openjdk/jdk13u-dev, openjdk/jdk14u, openjdk/jdk15u, openjdk/jdk15u-dev, openjdk/jdk16u, openjdk/jdk17u, openjdk/jdk17u-dev, openjdk/jdk18u, openjdk/jdk19, openjdk/jdk19u, openjdk/jdk7u, openjdk/jdk8u, openjdk/jdk8u-dev, openjdk/shenandoah-jdk8u, openjdk/shenandoah-jdk8u-dev.
Supplying the organization/group prefix is optional.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on d57fb6f Nov 10, 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 d57fb6f Nov 10, 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-d57fb6f6 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 d57fb6f6 from the openjdk/jdk repository.

The commit being backported was authored by lawrence.andrews on 6 Oct 2021 and was reviewed by Sergey Bylokhov.

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on d57fb6f Nov 11, 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 d57fb6f Nov 11, 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-d57fb6f6 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 d57fb6f6 from the openjdk/jdk repository.

The commit being backported was authored by lawrence.andrews on 6 Oct 2021 and was reviewed by Sergey Bylokhov.

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

Please sign in to comment.