author | akolarkunnu |
Thu, 11 Oct 2018 07:22:53 -0700 | |
changeset 52128 | 1e0cdaf980f3 |
parent 51595 | 02572bed95b6 |
child 53666 | 1a1c393b5c42 |
permissions | -rw-r--r-- |
51595 | 1 |
/* |
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.DEMO_TITLE; |
|
25 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.HTML_TOOLTIP_COMP_TITLE; |
|
26 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.HTML_TOOLTIP_TEXT; |
|
27 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.PLAIN_TOOLTIP_COMP_TITLE; |
|
28 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.PLAIN_TOOLTIP_TEXT; |
|
29 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.STYLE_TOOLTIP_COMP_TITLE; |
|
30 |
import static com.sun.swingset3.demos.tooltip.ToolTipDemo.STYLE_TOOLTIP_TEXT; |
|
31 |
import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR; |
|
32 |
||
33 |
import java.awt.Dimension; |
|
34 |
import java.awt.Point; |
|
35 |
||
36 |
import javax.swing.ToolTipManager; |
|
37 |
||
38 |
import org.jtregext.GuiTestListener; |
|
39 |
import org.netbeans.jemmy.ClassReference; |
|
40 |
import org.netbeans.jemmy.operators.JComponentOperator; |
|
41 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
42 |
import org.netbeans.jemmy.operators.JLabelOperator; |
|
43 |
import org.netbeans.jemmy.operators.JToolTipOperator; |
|
44 |
import org.testng.annotations.Listeners; |
|
45 |
import org.testng.annotations.Test; |
|
46 |
||
47 |
import com.sun.swingset3.demos.tooltip.ToolTipDemo; |
|
48 |
||
49 |
/* |
|
50 |
* @test |
|
51 |
* @key headful |
|
52 |
* @summary Verifies SwingSet3 ToolTipDemo page by checking whether tooltip |
|
53 |
* shown or removed on user actions, tooltip text, location, number of |
|
54 |
* tooltips shown at a time, with different tooltip texts plain, html and |
|
55 |
* styled. |
|
56 |
* |
|
57 |
* @library /sanity/client/lib/jemmy/src |
|
58 |
* @library /sanity/client/lib/Extensions/src |
|
59 |
* @library /sanity/client/lib/SwingSet3/src |
|
60 |
* @modules java.desktop |
|
61 |
* java.logging |
|
62 |
* @build org.jemmy2ext.JemmyExt |
|
63 |
* @build com.sun.swingset3.demos.tooltip.ToolTipDemo |
|
52128
1e0cdaf980f3
8211139: Increase timeout value in all tests under jdk/sanity/client/SwingSet/src
akolarkunnu
parents:
51595
diff
changeset
|
64 |
* @run testng/timeout=600 ToolTipDemoTest |
51595 | 65 |
*/ |
66 |
@Listeners(GuiTestListener.class) |
|
67 |
public class ToolTipDemoTest { |
|
68 |
||
69 |
private static int TOOLTIP_DISMISS_DELAY = 60000; |
|
70 |
||
71 |
/** |
|
72 |
* Testing whether tooltip shown while keeping the mouse on label, removed |
|
73 |
* on mouse press, tooltip text, location, number of tooltips shown at a |
|
74 |
* time with different tooltip texts plain, html and styled. |
|
75 |
* |
|
76 |
* @throws Exception |
|
77 |
*/ |
|
78 |
@Test |
|
79 |
public void test() throws Exception { |
|
80 |
new ClassReference(ToolTipDemo.class.getCanonicalName()).startApplication(); |
|
81 |
JFrameOperator frameOperator = new JFrameOperator(DEMO_TITLE); |
|
82 |
frameOperator.setComparator(EXACT_STRING_COMPARATOR); |
|
83 |
// Setting the tooltip dismiss delay |
|
84 |
ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY); |
|
85 |
||
86 |
// Verifying the plain tooltip properties |
|
87 |
checkToolTip(frameOperator, PLAIN_TOOLTIP_COMP_TITLE, |
|
88 |
PLAIN_TOOLTIP_TEXT); |
|
89 |
// Verifying the html tooltip properties |
|
90 |
checkToolTip(frameOperator, HTML_TOOLTIP_COMP_TITLE, |
|
91 |
HTML_TOOLTIP_TEXT); |
|
92 |
// Verifying the styled tooltip properties |
|
93 |
checkToolTip(frameOperator, STYLE_TOOLTIP_COMP_TITLE, |
|
94 |
STYLE_TOOLTIP_TEXT); |
|
95 |
||
96 |
// Reducing the frame size to half and verifying that tooltip shown |
|
97 |
// even it goes out of the window |
|
98 |
Dimension newSize = new Dimension(frameOperator.getWidth() / 2, |
|
99 |
frameOperator.getHeight() / 2); |
|
100 |
frameOperator.resize(newSize.width, newSize.height); |
|
101 |
frameOperator.waitComponentSize(newSize); |
|
102 |
checkToolTip(frameOperator, HTML_TOOLTIP_COMP_TITLE, |
|
103 |
HTML_TOOLTIP_TEXT); |
|
104 |
} |
|
105 |
||
106 |
/** |
|
107 |
* Shows the tooltip on specified component and verifies the properties |
|
108 |
* tooltip text, location. And dismisses thetooltip after verification of |
|
109 |
* the properties. |
|
110 |
* |
|
111 |
* @param frameOperator |
|
112 |
* @param compTitle |
|
113 |
* @param toolTipText |
|
114 |
*/ |
|
115 |
private void checkToolTip(JFrameOperator frameOperator, String compTitle, |
|
116 |
String toolTipText) { |
|
117 |
||
118 |
JLabelOperator toolTipHostComp = |
|
119 |
new JLabelOperator(frameOperator, compTitle); |
|
120 |
JToolTipOperator toolTipOperator = |
|
121 |
new JToolTipOperator(toolTipHostComp.showToolTip()); |
|
122 |
toolTipOperator.waitTipText(toolTipText); |
|
123 |
checkToolTipLocation(toolTipHostComp, toolTipOperator); |
|
124 |
||
125 |
// Dismissing the tooltip by mouse click |
|
126 |
toolTipHostComp.clickMouse(); |
|
127 |
toolTipOperator.waitComponentShowing(false); |
|
128 |
||
129 |
} |
|
130 |
||
131 |
private void checkToolTipLocation(JComponentOperator componentOpertor, |
|
132 |
JToolTipOperator toolTipOperator) { |
|
133 |
Point labelStartPoint = componentOpertor.getLocationOnScreen(); |
|
134 |
Dimension labelSize = componentOpertor.getSize(); |
|
135 |
Point labelEndPoint = new Point((labelStartPoint.x + labelSize.width), |
|
136 |
(labelStartPoint.y + labelSize.height)); |
|
137 |
toolTipOperator.waitComponentLocationOnScreen( |
|
138 |
labelStartPoint, labelEndPoint); |
|
139 |
} |
|
140 |
} |