2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.awt.Component;
25 import java.awt.Dimension;
27 import javax.swing.Icon;
28 import javax.swing.JDesktopPane;
29 import javax.swing.JFrame;
30 import javax.swing.JPanel;
32 import org.testng.Assert;
33 import org.testng.annotations.BeforeClass;
34 import org.testng.annotations.Test;
36 public class JvOptionPaneTest
39 @BeforeClass(alwaysRun = true)
40 public void setUpJvOptionPane()
42 JvOptionPane.setInteractiveMode(false);
43 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
46 Component parentComponent = null;
48 String message = "Hello World!";
50 String title = "Title";
52 int optionType = JvOptionPane.OK_CANCEL_OPTION;
54 int messageType = JvOptionPane.INFORMATION_MESSAGE;
58 Object initialSelectionValue = null;
60 Object[] selectionValues = null;
63 @Test(groups = { "Functional" })
64 public void showConfirmDialogFamilyTest()
66 JvOptionPane.showConfirmDialog(parentComponent, message);
67 JvOptionPane.showConfirmDialog(parentComponent, message, title,
69 JvOptionPane.showConfirmDialog(parentComponent, message, title,
70 optionType, messageType);
71 JvOptionPane.showConfirmDialog(parentComponent, message, title,
72 optionType, messageType, icon);
73 Assert.assertTrue(true);
76 @Test(groups = { "Functional" })
77 public void showInputDialogFamilyTest()
79 JvOptionPane.showInputDialog(message);
80 JvOptionPane.showInputDialog(parentComponent, message);
81 JvOptionPane.showInputDialog(message, initialSelectionValue);
82 JvOptionPane.showInputDialog(parentComponent, message,
83 initialSelectionValue);
84 JvOptionPane.showInputDialog(parentComponent, message, title,
86 JvOptionPane.showInputDialog(parentComponent, message, title,
87 messageType, icon, selectionValues, initialSelectionValue);
88 Assert.assertTrue(true);
91 @Test(groups = { "Functional" })
92 public void showMessageDialogFamilyTest()
94 JvOptionPane.showMessageDialog(parentComponent, message);
95 JvOptionPane.showMessageDialog(parentComponent, message, title,
97 JvOptionPane.showMessageDialog(parentComponent, message, title,
99 Assert.assertTrue(true);
102 @Test(groups = { "Functional" })
103 public void showInternalMessageDialogFamilyTest()
105 JvOptionPane.showInternalMessageDialog(parentComponent, message);
106 JvOptionPane.showInternalMessageDialog(parentComponent, message, title,
108 JvOptionPane.showInternalMessageDialog(parentComponent, message, title,
110 Assert.assertTrue(true);
113 @Test(groups = { "Functional" })
114 public void showInternalConfirmDialogFamilyTest()
116 JvOptionPane.showInternalConfirmDialog(parentComponent, message, title,
118 JvOptionPane.showInternalConfirmDialog(parentComponent, message, title,
119 optionType, messageType);
121 JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message);
123 JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message,
124 title, optionType, messageType, icon);
125 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message);
126 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message,
128 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message,
129 title, messageType, icon, selectionValues,
130 initialSelectionValue);
131 Assert.assertTrue(true);
135 private JDesktopPane getDummyDesktopPane()
137 JFrame frame = new JFrame("Dummy JDesktopPane");
138 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
139 @SuppressWarnings("serial")
140 JDesktopPane jdpDesktop = new JDesktopPane()
143 public Dimension getPreferredSize()
145 return new Dimension(400, 300);
148 frame.setContentPane(jdpDesktop);
149 JPanel panel = new JPanel();
150 panel.setBounds(0, 0, 400, 300);
151 jdpDesktop.add(panel);
153 frame.setVisible(true);
154 panel.setVisible(true);