You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainFrameTest.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.ui.swing;
  23. import com.dmdirc.config.IdentityManager;
  24. import com.dmdirc.ui.swing.dialogs.FeedbackDialog;
  25. import com.dmdirc.ui.swing.dialogs.NewServerDialog;
  26. import com.dmdirc.ui.swing.dialogs.about.AboutDialog;
  27. import com.dmdirc.ui.swing.dialogs.actionsmanager.ActionsManagerDialog;
  28. import com.dmdirc.ui.swing.dialogs.aliases.AliasManagerDialog;
  29. import com.dmdirc.ui.swing.dialogs.prefs.SwingPreferencesDialog;
  30. import com.dmdirc.ui.swing.dialogs.profiles.ProfileManagerDialog;
  31. import org.fest.swing.finder.WindowFinder;
  32. import org.fest.swing.fixture.DialogFixture;
  33. import org.fest.swing.fixture.FrameFixture;
  34. import org.junit.After;
  35. import org.junit.Before;
  36. import org.junit.Test;
  37. import static org.junit.Assert.*;
  38. public class MainFrameTest {
  39. private FrameFixture window;
  40. @Before
  41. public void setUp() {
  42. IdentityManager.load();
  43. window = new FrameFixture(SwingController.getMainFrame());
  44. window.show();
  45. }
  46. @After
  47. public void tearDown() {
  48. if (window != null) {
  49. window.cleanUp();
  50. }
  51. }
  52. @Test
  53. public void testNewServerDialog() {
  54. window.menuItemWithPath("Server", "New Server...").click();
  55. DialogFixture newwin = WindowFinder.findDialog(NewServerDialog.class)
  56. .withTimeout(5000).using(window.robot);
  57. newwin.requireVisible();
  58. }
  59. @Test
  60. public void testAboutDialog() {
  61. window.menuItemWithPath("Help", "About").click();
  62. DialogFixture newwin = WindowFinder.findDialog(AboutDialog.class)
  63. .withTimeout(5000).using(window.robot);
  64. newwin.requireVisible();
  65. }
  66. @Test
  67. public void testFeedbackDialog() {
  68. window.menuItemWithPath("Help", "Send Feedback").click();
  69. DialogFixture newwin = WindowFinder.findDialog(FeedbackDialog.class)
  70. .withTimeout(5000).using(window.robot);
  71. newwin.requireVisible();
  72. }
  73. @Test
  74. public void testPreferencesDialog() {
  75. window.menuItemWithPath("Settings", "Preferences").click();
  76. DialogFixture newwin = WindowFinder.findDialog(SwingPreferencesDialog.class)
  77. .withTimeout(5000).using(window.robot);
  78. newwin.requireVisible();
  79. }
  80. @Test
  81. public void testProfileManagerDialog() {
  82. window.menuItemWithPath("Settings", "Profile Manager").click();
  83. DialogFixture newwin = WindowFinder.findDialog(ProfileManagerDialog.class)
  84. .withTimeout(5000).using(window.robot);
  85. newwin.requireVisible();
  86. }
  87. @Test
  88. public void testActionsManagerDialog() {
  89. window.menuItemWithPath("Settings", "Actions Manager").click();
  90. DialogFixture newwin = WindowFinder.findDialog(ActionsManagerDialog.class)
  91. .withTimeout(5000).using(window.robot);
  92. newwin.requireVisible();
  93. }
  94. @Test
  95. public void testAliasManagerDialog() {
  96. window.menuItemWithPath("Settings", "Alias Manager").click();
  97. DialogFixture newwin = WindowFinder.findDialog(AliasManagerDialog.class)
  98. .withTimeout(5000).using(window.robot);
  99. newwin.requireVisible();
  100. }
  101. @Test
  102. public void testChannelServerSettings() {
  103. window.menuItemWithPath("Settings", "Server settings").requireDisabled();
  104. window.menuItemWithPath("Settings", "Channel Settings").requireDisabled();
  105. }
  106. public static junit.framework.Test suite() {
  107. return new junit.framework.JUnit4TestAdapter(MainFrameTest.class);
  108. }
  109. }