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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.harness.ui.UIClassTestRunner;
  25. import com.dmdirc.harness.ui.UITestIface;
  26. import com.dmdirc.ui.swing.dialogs.FeedbackDialog;
  27. import com.dmdirc.ui.swing.dialogs.NewServerDialog;
  28. import com.dmdirc.ui.swing.dialogs.about.AboutDialog;
  29. import com.dmdirc.ui.swing.dialogs.actionsmanager.ActionsManagerDialog;
  30. import com.dmdirc.ui.swing.dialogs.aliases.AliasManagerDialog;
  31. import com.dmdirc.ui.swing.dialogs.prefs.SwingPreferencesDialog;
  32. import com.dmdirc.ui.swing.dialogs.profiles.ProfileManagerDialog;
  33. import org.fest.swing.exception.ActionFailedException;
  34. import org.fest.swing.finder.WindowFinder;
  35. import org.fest.swing.fixture.DialogFixture;
  36. import org.fest.swing.fixture.FrameFixture;
  37. import org.junit.After;
  38. import org.junit.Before;
  39. import org.junit.Test;
  40. import org.junit.runner.RunWith;
  41. import static org.junit.Assert.*;
  42. @RunWith(UIClassTestRunner.class)
  43. public class MainFrameTest implements UITestIface {
  44. private FrameFixture window;
  45. @Before
  46. public void setUp() {
  47. IdentityManager.load();
  48. window = new FrameFixture(SwingController.getMainFrame());
  49. window.show();
  50. }
  51. @After
  52. public void tearDown() {
  53. if (window != null) {
  54. window.cleanUp();
  55. }
  56. }
  57. @Test
  58. public void testNewServerDialog() {
  59. window.menuItemWithPath("Server", "New Server...").click();
  60. DialogFixture newwin = WindowFinder.findDialog(NewServerDialog.class)
  61. .withTimeout(5000).using(window.robot);
  62. newwin.requireVisible();
  63. }
  64. @Test
  65. public void testAboutDialog() {
  66. window.menuItemWithPath("Help", "About").click();
  67. DialogFixture newwin = WindowFinder.findDialog(AboutDialog.class)
  68. .withTimeout(5000).using(window.robot);
  69. newwin.requireVisible();
  70. }
  71. @Test
  72. public void testFeedbackDialog() {
  73. window.menuItemWithPath("Help", "Send Feedback").click();
  74. DialogFixture newwin = WindowFinder.findDialog(FeedbackDialog.class)
  75. .withTimeout(5000).using(window.robot);
  76. newwin.requireVisible();
  77. }
  78. @Test
  79. public void testPreferencesDialog() {
  80. window.menuItemWithPath("Settings", "Preferences").click();
  81. DialogFixture newwin = WindowFinder.findDialog(SwingPreferencesDialog.class)
  82. .withTimeout(5000).using(window.robot);
  83. newwin.requireVisible();
  84. }
  85. @Test
  86. public void testProfileManagerDialog() {
  87. window.menuItemWithPath("Settings", "Profile Manager").click();
  88. DialogFixture newwin = WindowFinder.findDialog(ProfileManagerDialog.class)
  89. .withTimeout(5000).using(window.robot);
  90. newwin.requireVisible();
  91. }
  92. @Test
  93. public void testActionsManagerDialog() {
  94. window.menuItemWithPath("Settings", "Actions Manager").click();
  95. DialogFixture newwin = WindowFinder.findDialog(ActionsManagerDialog.class)
  96. .withTimeout(5000).using(window.robot);
  97. newwin.requireVisible();
  98. }
  99. @Test
  100. public void testAliasManagerDialog() {
  101. window.menuItemWithPath("Settings", "Alias Manager").click();
  102. DialogFixture newwin = WindowFinder.findDialog(AliasManagerDialog.class)
  103. .withTimeout(5000).using(window.robot);
  104. newwin.requireVisible();
  105. }
  106. @Test
  107. public void testChannelServerSettings() {
  108. window.menuItemWithPath("Channel", "Channel Settings").requireDisabled();
  109. }
  110. @Test
  111. public void testServerServerSettings() {
  112. window.menuItemWithPath("Server", "Server settings").requireDisabled();
  113. }
  114. public static junit.framework.Test suite() {
  115. return new junit.framework.JUnit4TestAdapter(MainFrameTest.class);
  116. }
  117. }