您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ProfileManagerDialogTest.java 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.dialogs.profiles;
  23. import com.dmdirc.Main;
  24. import com.dmdirc.addons.ui_swing.SwingController;
  25. import com.dmdirc.addons.ui_swing.UIUtilities;
  26. import com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList;
  27. import com.dmdirc.config.IdentityManager;
  28. import com.dmdirc.config.InvalidIdentityFileException;
  29. import com.dmdirc.config.prefs.validator.FileNameValidator;
  30. import com.dmdirc.config.prefs.validator.IdentValidator;
  31. import com.dmdirc.config.prefs.validator.NotEmptyValidator;
  32. import com.dmdirc.harness.ui.ClassFinder;
  33. import com.dmdirc.harness.ui.ValidatingJTextFieldFinder;
  34. import javax.swing.JList;
  35. import org.fest.swing.fixture.DialogFixture;
  36. import org.junit.After;
  37. import org.junit.Before;
  38. import org.junit.BeforeClass;
  39. import org.junit.Test;
  40. import static org.junit.Assert.*;
  41. public class ProfileManagerDialogTest {
  42. private DialogFixture window;
  43. private Profile profile;
  44. @BeforeClass
  45. public static void setUpClass() throws InvalidIdentityFileException {
  46. IdentityManager.load();
  47. UIUtilities.initUISettings();
  48. Main.setUI(new SwingController());
  49. }
  50. @Before
  51. public void setUp() {
  52. profile = new Profile("unit-test1", "nick1", "real name", "ident");
  53. profile.save();
  54. }
  55. @After
  56. public void tearDown() {
  57. if (window != null) {
  58. window.cleanUp();
  59. }
  60. profile.delete();
  61. }
  62. @Test
  63. public void testDetails() {
  64. setupWindow();
  65. window.list(new ClassFinder<JList>(JList.class, null))
  66. .selectItem("unit-test1").requireSelection("unit-test1");
  67. window.textBox(new ValidatingJTextFieldFinder(FileNameValidator.class))
  68. .requireText("unit-test1"); // Profile name
  69. window.textBox(new ValidatingJTextFieldFinder(NotEmptyValidator.class))
  70. .requireText("real name"); // Real name
  71. window.textBox(new ValidatingJTextFieldFinder(IdentValidator.class))
  72. .requireText("ident"); // Ident
  73. assertEquals(1,
  74. window.list(new ClassFinder<ReorderableJList>(ReorderableJList.class, null))
  75. .selectItem("nick1").requireSelection("nick1").contents().length);
  76. }
  77. protected void setupWindow() {
  78. window = new DialogFixture(ProfileManagerDialog.getProfileManagerDialog(null));
  79. window.show();
  80. }
  81. }