1 /*
2 * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 */
5 package javafx.scene.control.test.richtexteditor;
6
7 import client.test.Keywords;
8 import client.test.ScreenshotCheck;
9 import client.test.Smoke;
10 import java.awt.Toolkit;
11 import java.io.*;
12 import java.net.URL;
13 import java.util.*;
14 import java.util.Map.Entry;
15 import javafx.beans.property.SimpleStringProperty;
16 import javafx.scene.Node;
17 import javafx.scene.Scene;
18 import javafx.scene.control.*;
19 import javafx.scene.control.test.ControlsTestBase;
20 import javafx.scene.control.test.MenuApp;
21 import javafx.scene.control.test.RichTextEditorApp;
22 import javafx.scene.input.Clipboard;
29 import org.jemmy.fx.ByID;
30 import org.jemmy.fx.ByWindowType;
31 import org.jemmy.fx.Root;
32 import org.jemmy.fx.control.TextControlWrap;
33 import org.jemmy.fx.control.ThemeDriverFactory;
34 import org.jemmy.fx.control.caspian.CaspianDriverFactory;
35 import org.jemmy.interfaces.Keyboard.KeyboardButton;
36 import org.jemmy.interfaces.Keyboard.KeyboardButtons;
37 import org.jemmy.interfaces.Keyboard.KeyboardModifiers;
38 import org.jemmy.interfaces.Parent;
39 import org.jemmy.interfaces.Selectable;
40 import org.jemmy.lookup.Lookup;
41 import org.jemmy.lookup.LookupCriteria;
42 import org.jemmy.timing.State;
43 import static org.junit.Assert.*;
44 import org.junit.*;
45 import org.junit.runner.RunWith;
46 import test.javaclient.shared.FilteredTestRunner;
47 import test.javaclient.shared.JemmyUtils;
48 import test.javaclient.shared.Utils;
49 import test.javaclient.shared.screenshots.ImagesManager;
50 import test.javaclient.shared.screenshots.ScreenshotUtils;
51
52 @RunWith(FilteredTestRunner.class)
53 public class RichTextEditorTest extends ControlsTestBase {
54
55 public RichTextEditorTest() {
56 }
57 static Wrap<? extends Scene> scene = null;
58 static Parent<Node> parent = null;
59 static Wrap resetBtn;
60 static Wrap contentPane = null;
61 Wrap<? extends WebView> webView = null;
62 Wrap cut = null;
63 Wrap copy = null;
64 Wrap paste = null;
65 Wrap undo = null;
66 Wrap redo = null;
67 Wrap separator = null;
68 Wrap left = null;
69 Wrap center = null;
859 return plsSpecName;
860 }
861 }
862 }
863
864 System.out.println("there is no platform specific html for name <" + name + ">.");
865 return name;
866 }
867
868 protected void check(final String html) throws IOException, FileNotFoundException {
869 System.out.println(readResource(getHTMLName(html) + ".html"));
870 try {
871 htmlEditor.waitState(new State<String>() {
872
873 public String reached() {
874 System.out.println(htmlEditor.getControl().getHtmlText());
875 return htmlEditor.getControl().getHtmlText();
876 }
877 }, readResource(getHTMLName(html) + ".html"));
878 } finally {
879 Writer out = new OutputStreamWriter(new FileOutputStream(ImagesManager.getInstance().getHTMLPath(html)));
880 try {
881 out.write("Found : " + htmlEditor.getControl().getHtmlText() + "\n");
882 out.write("Expected : " + readResource(getHTMLName(html) + ".html") + "\n");
883 } finally {
884 out.close();
885 }
886 }
887 }
888
889 protected void checkClipboard(String html) throws IOException {
890 try {
891 htmlEditor.waitState(new State<String>() {
892
893 public String reached() {
894 return getClipboardHTML();
895 }
896 }, readResource(getHTMLName(html) + ".html"));
897 } finally {
898 Writer out = new OutputStreamWriter(new FileOutputStream(ImagesManager.getInstance().getHTMLPath(html)));
899 try {
900 out.write(getClipboardHTML());
901 } finally {
902 out.close();
903 }
904 }
905 }
906
907 protected void typeText(String text) {
908 for (int i = 0; i < text.length(); i++) {
909 char c = text.charAt(i);
910 if (c == '\n') {
911 webView.keyboard().pushKey(KeyboardButtons.ENTER);
912 } else {
913 webView.keyboard().typeChar(text.charAt(i), ZERO_TIMEOUT);
914 }
915 }
916 }
917
918 protected String readResource(String name) throws IOException {
|
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 package javafx.scene.control.test.richtexteditor;
6
7 import client.test.Keywords;
8 import client.test.ScreenshotCheck;
9 import client.test.Smoke;
10 import java.awt.Toolkit;
11 import java.io.*;
12 import java.net.URL;
13 import java.util.*;
14 import java.util.Map.Entry;
15 import javafx.beans.property.SimpleStringProperty;
16 import javafx.scene.Node;
17 import javafx.scene.Scene;
18 import javafx.scene.control.*;
19 import javafx.scene.control.test.ControlsTestBase;
20 import javafx.scene.control.test.MenuApp;
21 import javafx.scene.control.test.RichTextEditorApp;
22 import javafx.scene.input.Clipboard;
29 import org.jemmy.fx.ByID;
30 import org.jemmy.fx.ByWindowType;
31 import org.jemmy.fx.Root;
32 import org.jemmy.fx.control.TextControlWrap;
33 import org.jemmy.fx.control.ThemeDriverFactory;
34 import org.jemmy.fx.control.caspian.CaspianDriverFactory;
35 import org.jemmy.interfaces.Keyboard.KeyboardButton;
36 import org.jemmy.interfaces.Keyboard.KeyboardButtons;
37 import org.jemmy.interfaces.Keyboard.KeyboardModifiers;
38 import org.jemmy.interfaces.Parent;
39 import org.jemmy.interfaces.Selectable;
40 import org.jemmy.lookup.Lookup;
41 import org.jemmy.lookup.LookupCriteria;
42 import org.jemmy.timing.State;
43 import static org.junit.Assert.*;
44 import org.junit.*;
45 import org.junit.runner.RunWith;
46 import test.javaclient.shared.FilteredTestRunner;
47 import test.javaclient.shared.JemmyUtils;
48 import test.javaclient.shared.Utils;
49 import test.javaclient.shared.screenshots.GoldenImageManager;
50 import test.javaclient.shared.screenshots.ScreenshotUtils;
51
52 @RunWith(FilteredTestRunner.class)
53 public class RichTextEditorTest extends ControlsTestBase {
54
55 public RichTextEditorTest() {
56 }
57 static Wrap<? extends Scene> scene = null;
58 static Parent<Node> parent = null;
59 static Wrap resetBtn;
60 static Wrap contentPane = null;
61 Wrap<? extends WebView> webView = null;
62 Wrap cut = null;
63 Wrap copy = null;
64 Wrap paste = null;
65 Wrap undo = null;
66 Wrap redo = null;
67 Wrap separator = null;
68 Wrap left = null;
69 Wrap center = null;
859 return plsSpecName;
860 }
861 }
862 }
863
864 System.out.println("there is no platform specific html for name <" + name + ">.");
865 return name;
866 }
867
868 protected void check(final String html) throws IOException, FileNotFoundException {
869 System.out.println(readResource(getHTMLName(html) + ".html"));
870 try {
871 htmlEditor.waitState(new State<String>() {
872
873 public String reached() {
874 System.out.println(htmlEditor.getControl().getHtmlText());
875 return htmlEditor.getControl().getHtmlText();
876 }
877 }, readResource(getHTMLName(html) + ".html"));
878 } finally {
879 Writer out = new OutputStreamWriter(new FileOutputStream(GoldenImageManager.getGoldenPath(html, ".html")));
880 try {
881 out.write("Found : " + htmlEditor.getControl().getHtmlText() + "\n");
882 out.write("Expected : " + readResource(getHTMLName(html) + ".html") + "\n");
883 } finally {
884 out.close();
885 }
886 }
887 }
888
889 protected void checkClipboard(String html) throws IOException {
890 try {
891 htmlEditor.waitState(new State<String>() {
892
893 public String reached() {
894 return getClipboardHTML();
895 }
896 }, readResource(getHTMLName(html) + ".html"));
897 } finally {
898 Writer out = new OutputStreamWriter(new FileOutputStream(GoldenImageManager.getGoldenPath(html, ".html")));
899 try {
900 out.write(getClipboardHTML());
901 } finally {
902 out.close();
903 }
904 }
905 }
906
907 protected void typeText(String text) {
908 for (int i = 0; i < text.length(); i++) {
909 char c = text.charAt(i);
910 if (c == '\n') {
911 webView.keyboard().pushKey(KeyboardButtons.ENTER);
912 } else {
913 webView.keyboard().typeChar(text.charAt(i), ZERO_TIMEOUT);
914 }
915 }
916 }
917
918 protected String readResource(String name) throws IOException {
|