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.BeforeMethod;
34 import org.testng.annotations.Test;
36 public class JvOptionPaneTest
39 Component parentComponent = null;
41 String message = "Hello World!";
43 String title = "Title";
45 int optionType = JvOptionPane.OK_CANCEL_OPTION;
47 int messageType = JvOptionPane.INFORMATION_MESSAGE;
51 Object initialSelectionValue = null;
53 Object[] selectionValues = null;
55 @BeforeMethod(alwaysRun = true)
58 JvOptionPane.setInteractiveMode(false);
59 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
62 @Test(groups = { "Functional" })
63 public void showConfirmDialogFamilyTest()
65 JvOptionPane.showConfirmDialog(parentComponent, message);
66 JvOptionPane.showConfirmDialog(parentComponent, message, title,
68 JvOptionPane.showConfirmDialog(parentComponent, message, title,
69 optionType, messageType);
70 JvOptionPane.showConfirmDialog(parentComponent, message, title,
71 optionType, messageType, icon);
72 Assert.assertTrue(true);
75 @Test(groups = { "Functional" })
76 public void showInputDialogFamilyTest()
78 JvOptionPane.showInputDialog(message);
79 JvOptionPane.showInputDialog(parentComponent, message);
80 JvOptionPane.showInputDialog(message, initialSelectionValue);
81 JvOptionPane.showInputDialog(parentComponent, message,
82 initialSelectionValue);
83 JvOptionPane.showInputDialog(parentComponent, message, title,
85 JvOptionPane.showInputDialog(parentComponent, message, title,
86 messageType, icon, selectionValues, initialSelectionValue);
87 Assert.assertTrue(true);
90 @Test(groups = { "Functional" })
91 public void showMessageDialogFamilyTest()
93 JvOptionPane.showMessageDialog(parentComponent, message);
94 JvOptionPane.showMessageDialog(parentComponent, message, title,
96 JvOptionPane.showMessageDialog(parentComponent, message, title,
98 Assert.assertTrue(true);
101 @Test(groups = { "Functional" })
102 public void showInternalMessageDialogFamilyTest()
104 JvOptionPane.showInternalMessageDialog(parentComponent, message);
105 JvOptionPane.showInternalMessageDialog(parentComponent, message, title,
107 JvOptionPane.showInternalMessageDialog(parentComponent, message, title,
109 Assert.assertTrue(true);
112 @Test(groups = { "Functional" })
113 public void showInternalConfirmDialogFamilyTest()
115 JvOptionPane.showInternalConfirmDialog(parentComponent, message, title,
117 JvOptionPane.showInternalConfirmDialog(parentComponent, message, title,
118 optionType, messageType);
120 JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message);
122 JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message,
123 title, optionType, messageType, icon);
124 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message);
125 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message,
127 JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message,
128 title, messageType, icon, selectionValues,
129 initialSelectionValue);
130 Assert.assertTrue(true);
134 private JDesktopPane getDummyDesktopPane()
136 JFrame frame = new JFrame("Dummy JDesktopPane");
137 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
138 @SuppressWarnings("serial")
139 JDesktopPane jdpDesktop = new JDesktopPane()
142 public Dimension getPreferredSize()
144 return new Dimension(400, 300);
147 frame.setContentPane(jdpDesktop);
148 JPanel panel = new JPanel();
149 panel.setBounds(0, 0, 400, 300);
150 jdpDesktop.add(panel);
152 frame.setVisible(true);
153 panel.setVisible(true);