Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

MainFrameTest.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2006-2010 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.addons.ui_swing;
  23. import com.dmdirc.config.IdentityManager;
  24. import com.dmdirc.config.InvalidIdentityFileException;
  25. import org.junit.Test;
  26. import org.uispec4j.UISpecTestCase;
  27. import org.uispec4j.Window;
  28. import org.uispec4j.interception.WindowInterceptor;
  29. import static org.mockito.Mockito.*;
  30. public class MainFrameTest extends UISpecTestCase {
  31. private static Window window;
  32. static {
  33. try {
  34. IdentityManager.load();
  35. } catch (InvalidIdentityFileException ex) {
  36. //Ignore
  37. }
  38. SwingController controller = mock(SwingController.class);
  39. final SwingWindowFactory windowFactory = mock(SwingWindowFactory.class);
  40. when(controller.getDomain()).thenReturn("test");
  41. when(controller.getWindowFactory()).thenReturn(windowFactory);
  42. IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
  43. IdentityManager.getAddonIdentity().setOption("test", "desktopbackground", "");
  44. IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "STRETCH");
  45. IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems", "1");
  46. IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
  47. window = new Window(new MainFrame(controller));
  48. window.containsMenuBar().check();
  49. }
  50. @Test
  51. public void testNewServerDialog() {
  52. Window popup = WindowInterceptor.run(window.getMenuBar()
  53. .getMenu("Server").getSubMenu("New Server...").triggerClick());
  54. popup.titleEquals("DMDirc: Connect to a new server").check();
  55. }
  56. @Test
  57. public void testAboutDialog() {
  58. Window popup = WindowInterceptor.run(window.getMenuBar()
  59. .getMenu("Help").getSubMenu("About").triggerClick());
  60. popup.titleEquals("DMDirc: About").check();
  61. }
  62. @Test
  63. public void testFeedbackDialog() {
  64. Window popup = WindowInterceptor.run(window.getMenuBar()
  65. .getMenu("Help").getSubMenu("Send Feedback").triggerClick());
  66. popup.titleEquals("DMDirc: Feedback").check();
  67. }
  68. @Test
  69. public void testPreferencesDialog() {
  70. Window popup = WindowInterceptor.run(window.getMenuBar()
  71. .getMenu("Settings").getSubMenu("Preferences").triggerClick());
  72. popup.titleEquals("DMDirc: Preferences").check();
  73. }
  74. @Test
  75. public void testProfileManagerDialog() {
  76. Window popup = WindowInterceptor.run(window.getMenuBar()
  77. .getMenu("Settings").getSubMenu("Profile Manager").triggerClick());
  78. popup.titleEquals("DMDirc: Profile Editor").check();
  79. }
  80. @Test
  81. public void testActionsManagerDialog() {
  82. Window popup = WindowInterceptor.run(window.getMenuBar()
  83. .getMenu("Settings").getSubMenu("Actions Manager").triggerClick());
  84. popup.titleEquals("DMDirc: Actions Manager").check();
  85. }
  86. @Test
  87. public void testAliasManagerDialog() {
  88. Window popup = WindowInterceptor.run(window.getMenuBar()
  89. .getMenu("Settings").getSubMenu("Alias Manager").triggerClick());
  90. popup.titleEquals("DMDirc: Alias manager").check();
  91. }
  92. @Test
  93. public void testChannelServerSettings() {
  94. assertFalse(window.getMenuBar().getMenu("Channel").getSubMenu("Channel Settings").isEnabled());
  95. }
  96. @Test
  97. public void testServerServerSettings() {
  98. assertFalse(window.getMenuBar().getMenu("Server").getSubMenu("Server Settings").isEnabled());
  99. }
  100. }