Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8319555: [TestBug] Utility for creating instruction window for manual tests #1413

Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/manual/text/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/controls">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="/manualTests-util"/>
<classpathentry excluding=".classpath|.project|.settings" kind="src" output="bin" path=""/>
<classpathentry kind="output" path="bin"/>
</classpath>
93 changes: 33 additions & 60 deletions tests/manual/text/EmojiTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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 @@ -23,64 +23,44 @@
* questions.
*/

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import com.oracle.util.testing.ManualTestWindow;

public class EmojiTest extends Application {

static String instructions =
"""
This tests rendering of Emoji glyphs which is only supported on macOS.
On macOS you should see a yellow-coloured smiling face image,
embedded between 'ab' and 'cd'.
On other platforms it may be a missing glyph, or an empty space, or
a similar rendering as a greyscale/B&W glyph.
Principally, you are checking that the emoji is rendered on macOS in
each of the controls and nodes displayed in the test, and that the
editable text field handles selection of the emoji glyph with the
same background as other glyphs - this presumes the emoji image has
transparent background pixels.
There are 3 different ways it is displayed to verify
1) Text node. 2) Label control, 3) TextField Control
Press the Pass or Fail button as appropriate and the test will exit.
If what you see is not explained here, ask before filing a bug.


""";

public class EmojiTest extends ManualTestWindow {
public static void main(String[] args) {
launch(args);
}

private void quit() {
Platform.exit();
public EmojiTest() {
super(
"Emoji Rendering Test (macOS)",
"""
This tests rendering of Emoji glyphs which is only supported on macOS.
On macOS you should see a yellow-coloured smiling face image,
embedded between 'ab' and 'cd'.
On other platforms it may be a missing glyph, or an empty space, or
a similar rendering as a greyscale/B&W glyph.
Principally, you are checking that the emoji is rendered on macOS in
each of the controls and nodes displayed in the test, and that the
editable text field handles selection of the emoji glyph with the
same background as other glyphs - this presumes the emoji image has
transparent background pixels.
There are 3 different ways it is displayed to verify
1) Text node. 2) Label control, 3) TextField Control
Press the Pass or Fail button as appropriate and the test will exit.
If what you see is not explained here, ask before filing a bug.
""",
1200, 800
);
}

@Override
public void start(Stage stage) {
Button passButton = new Button("Pass");
Button failButton = new Button("Fail");
passButton.setOnAction(e -> this.quit());
failButton.setOnAction(e -> {
this.quit();
throw new AssertionError("The Emoji was not rendered on macOS");
});

HBox hbox = new HBox(10, passButton, failButton);

Text instTA = new Text(instructions);
instTA.setWrappingWidth(500);

protected Node createContent() {
Font font = new Font(32);
String emojiString = "ab\ud83d\ude00cd";
Text text = new Text(emojiString);
Expand All @@ -90,18 +70,11 @@ public void start(Stage stage) {
TextField textField = new TextField(emojiString);
textField.setFont(font);

VBox vbox = new VBox();
Scene scene = new Scene(vbox);
vbox.getChildren().add(instTA);
vbox.getChildren().add(hbox);
vbox.getChildren().add(text);
vbox.getChildren().add(label);
vbox.getChildren().add(textField);
stage.setWidth(600);
stage.setHeight(600);
stage.setScene(scene);

stage.show();
return new VBox(
2,
text,
label,
textField
);
}

}
30 changes: 30 additions & 0 deletions tests/manual/util/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry combineaccessrules="false" kind="src" path="/base">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/controls">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/graphics">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions tests/manual/util/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>manualTests-util</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions tests/manual/util/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
14 changes: 14 additions & 0 deletions tests/manual/util/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
38 changes: 38 additions & 0 deletions tests/manual/util/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Test Utilities

## ManualTestWindow

This facility provides the base class for manual tests which displays the test instructions,
the UI under test, and the Pass/Fail buttons.

Example:

```java
public class ManualTestExample extends ManualTestWindow {
public ManualTestExample() {
super(
"Manual Test Example",
"""
Instructions:
1. you will see a button named "Test"
2. press the button
3. verify that the button can be pressed""",
400, 250
);
}

public static void main(String[] args) throws Exception {
launch(args);
}

@Override
protected Node createContent() {
return new Button("Test");
}
}
```

Resulting application window:
Copy link
Member

Choose a reason for hiding this comment

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

Resulting application window does not look like it is from example above. Not sure if it is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really important.

Apart from being resized to decrease the size of the PNG image, it looks exactly the same. Are you running it on a different platform? How does it look, anything appears missing (can you post a screenshot)?

Copy link
Member

Choose a reason for hiding this comment

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

If you run EmojiTest, then yes it will look correct, but if you run SampleManualTest it will not. Since you added this image to SampleManualTest as resulting image of SampleManualTest. Look at ReadMe.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed! thanks!


![screenshot](doc/ManualTestWindow.png)

Binary file added tests/manual/util/doc/ManualTestWindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading