Browse Source

Use new getMetaData method (and fix unit tests)

Change-Id: Id0ea49f368628d25bc4232eb3d3137fc41c89bbe
Depends-On: I0bf84a236b3d4a3a86bb3cdceadbfb972b7dec27
Reviewed-on: http://gerrit.dmdirc.com/2090
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 13 years ago
parent
commit
3f05ed9579

+ 1
- 1
src/com/dmdirc/addons/identd/IdentdServer.java View File

@@ -130,7 +130,7 @@ public final class IdentdServer implements Runnable {
130 130
                 Logger.userError(ErrorLevel.MEDIUM, "Unable to start identd server: " + e.getMessage());
131 131
                 if (e.getMessage().equals("Permission denied")) {
132 132
                     final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName("identd");
133
-                    if (plugin != null && PluginManager.getPluginManager().delPlugin(plugin.getRelativeFilename())) {
133
+                    if (plugin != null && PluginManager.getPluginManager().delPlugin(plugin.getMetaData().getRelativeFilename())) {
134 134
                         PluginManager.getPluginManager().updateAutoLoad(plugin);
135 135
                     }
136 136
                 }

+ 2
- 2
src/com/dmdirc/addons/notifications/NotificationCommand.java View File

@@ -113,7 +113,7 @@ public class NotificationCommand extends Command implements
113 113
             final String[][] data = new String[methods.size()][1];
114 114
             int i = 0;
115 115
             for (PluginInfo method : methods) {
116
-                data[i][0] = method.getName();
116
+                data[i][0] = method.getMetaData().getName();
117 117
                 i++;
118 118
             }
119 119
 
@@ -134,7 +134,7 @@ public class NotificationCommand extends Command implements
134 134
         } else if (arg == 1 && context.getPreviousArgs().get(0)
135 135
                 .equalsIgnoreCase("--method")) {
136 136
             for (PluginInfo source : parent.getMethods()) {
137
-                res.add(source.getName());
137
+                res.add(source.getMetaData().getName());
138 138
             }
139 139
             return res;
140 140
         }

+ 4
- 4
src/com/dmdirc/addons/notifications/NotificationsPlugin.java View File

@@ -130,7 +130,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
130 130
      */
131 131
     private void addPlugin(final PluginInfo target) {
132 132
         if (target.hasExportedService("showNotification")) {
133
-            methods.add(target.getName());
133
+            methods.add(target.getMetaData().getName());
134 134
             addMethodToOrder(target);
135 135
         }
136 136
     }
@@ -142,8 +142,8 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
142 142
      * @param source The notification method to be tested
143 143
      */
144 144
     private void addMethodToOrder(final PluginInfo source) {
145
-        if (!order.contains(source.getName())) {
146
-            order.add(source.getName());
145
+        if (!order.contains(source.getMetaData().getName())) {
146
+            order.add(source.getMetaData().getName());
147 147
         }
148 148
     }
149 149
 
@@ -154,7 +154,7 @@ public class NotificationsPlugin extends BasePlugin implements ActionListener {
154 154
      * @param target The plugin to be tested
155 155
      */
156 156
     private void removePlugin(final PluginInfo target) {
157
-        methods.remove(target.getName());
157
+        methods.remove(target.getMetaData().getName());
158 158
     }
159 159
 
160 160
     /**

+ 4
- 4
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonToggle.java View File

@@ -144,7 +144,7 @@ public class AddonToggle {
144 144
      */
145 145
     public String getName() {
146 146
         if (pi != null) {
147
-            return pi.getNiceName();
147
+            return pi.getMetaData().getFriendlyName();
148 148
         }
149 149
         if (theme != null) {
150 150
             return theme.getName();
@@ -160,7 +160,7 @@ public class AddonToggle {
160 160
      */
161 161
     public String getVersion() {
162 162
         if (pi != null) {
163
-            return pi.getFriendlyVersion();
163
+            return pi.getMetaData().getFriendlyVersion();
164 164
         }
165 165
 
166 166
         if (theme != null) {
@@ -177,7 +177,7 @@ public class AddonToggle {
177 177
      */
178 178
     public String getAuthor() {
179 179
         if (pi != null) {
180
-            return pi.getAuthor();
180
+            return pi.getMetaData().getAuthor();
181 181
         }
182 182
 
183 183
         if (theme != null) {
@@ -194,7 +194,7 @@ public class AddonToggle {
194 194
      */
195 195
     public String getDescription() {
196 196
         if (pi != null) {
197
-            return pi.getDescription();
197
+            return pi.getMetaData().getDescription();
198 198
         }
199 199
 
200 200
         if (theme != null) {

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/about/InfoPanel.java View File

@@ -83,7 +83,7 @@ public final class InfoPanel extends JPanel {
83 83
                  .getGlobalConfig().getOption("identity", "modealiasversion")
84 84
                  + "<br>"
85 85
                  + "<b>Swing UI version: </b>" + controller.getPluginInfo()
86
-                 .getVersion().toString() + "<br>"
86
+                 .getMetaData().getVersion().toString() + "<br>"
87 87
                  + "<b>OS Version: </b>" + Info.getOSVersion() + "<br>"
88 88
                  + "<b>Profile directory: </b>" + Main.getConfigDir() + "<br>"
89 89
                  + "<b>Java version: </b>" + Info.getJavaVersion() + "<br>"

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceRenderer.java View File

@@ -23,8 +23,8 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.plugins.PluginInfo;
26
-import java.awt.Color;
27 26
 
27
+import java.awt.Color;
28 28
 import java.awt.Component;
29 29
 
30 30
 import javax.swing.JLabel;
@@ -56,7 +56,7 @@ public class LicenceRenderer extends DefaultTreeCellRenderer {
56 56
         if (((DefaultMutableTreeNode) value).getUserObject()
57 57
                 instanceof PluginInfo) {
58 58
             setText(((PluginInfo) ((DefaultMutableTreeNode) value)
59
-                    .getUserObject()).getNiceName());
59
+                    .getUserObject()).getMetaData().getFriendlyName());
60 60
         }
61 61
         return label;
62 62
     }

+ 5
- 5
src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java View File

@@ -43,8 +43,8 @@ import javax.swing.text.html.HTMLEditorKit;
43 43
 import javax.swing.tree.DefaultMutableTreeNode;
44 44
 import javax.swing.tree.DefaultTreeModel;
45 45
 import javax.swing.tree.TreeSelectionModel;
46
-import net.miginfocom.layout.PlatformDefaults;
47 46
 
47
+import net.miginfocom.layout.PlatformDefaults;
48 48
 import net.miginfocom.swing.MigLayout;
49 49
 
50 50
 /**
@@ -148,10 +148,10 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
148 148
         licence.setText(((Licence) userObject).getBody());
149 149
         } else if (userObject instanceof PluginInfo) {
150 150
             final PluginInfo pi = (PluginInfo) userObject;
151
-            licence.setText("<b>Name:</b> " + pi.getNiceName() + "<br>"
152
-                    + "<b>Version:</b> " + pi.getFriendlyVersion() + "<br>"
153
-                    + "<b>Author:</b> " + pi.getAuthor() + "<br>"
154
-                    + "<b>Description:</b> " + pi.getDescription() + "<br>");
151
+            licence.setText("<b>Name:</b> " + pi.getMetaData().getFriendlyName() + "<br>"
152
+                    + "<b>Version:</b> " + pi.getMetaData().getFriendlyVersion() + "<br>"
153
+                    + "<b>Author:</b> " + pi.getMetaData().getAuthor() + "<br>"
154
+                    + "<b>Description:</b> " + pi.getMetaData().getDescription() + "<br>");
155 155
         } else {
156 156
             licence.setText("<b>Name:</b> DMDirc<br>"
157 157
                     + "<b>Version:</b> " + IdentityManager.getGlobalConfig().

+ 14
- 5
test/com/dmdirc/addons/ui_swing/MainFrameTest.java View File

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2011 DMDirc Developers
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,11 +24,12 @@ package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 import com.dmdirc.harness.ui.DMDircUITestCase;
26 26
 import org.junit.Test;
27
+import org.uispec4j.Trigger;
27 28
 import org.uispec4j.Window;
28 29
 import org.uispec4j.interception.WindowInterceptor;
29 30
 
30 31
 public class MainFrameTest extends DMDircUITestCase {
31
-    
32
+
32 33
     private static Window window;
33 34
 
34 35
     static {
@@ -36,8 +37,15 @@ public class MainFrameTest extends DMDircUITestCase {
36 37
 
37 38
         window = new Window(new MainFrame(controller));
38 39
         window.containsMenuBar().check();
40
+        WindowInterceptor.run(new Trigger() {
41
+
42
+            @Override
43
+            public void run() throws Exception {
44
+                window.getAwtComponent().setVisible(true);
45
+            }
46
+        });
39 47
     }
40
-    
48
+
41 49
     @Test
42 50
     public void testNewServerDialog() {
43 51
         Window popup = WindowInterceptor.run(window.getMenuBar()
@@ -68,6 +76,7 @@ public class MainFrameTest extends DMDircUITestCase {
68 76
 
69 77
     @Test
70 78
     public void testProfileManagerDialog() {
79
+        Window main = WindowInterceptor.run(Trigger.DO_NOTHING);
71 80
         Window popup = WindowInterceptor.run(window.getMenuBar()
72 81
                 .getMenu("Settings").getSubMenu("Profile Manager").triggerClick());
73 82
         popup.titleEquals("DMDirc: Profile Editor").check();

+ 11
- 4
test/com/dmdirc/harness/ui/DMDircUITestCase.java View File

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2011 DMDirc Developers
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,17 +22,19 @@
22 22
 
23 23
 package com.dmdirc.harness.ui;
24 24
 
25
+import com.dmdirc.plugins.PluginInfo;
26
+import com.dmdirc.plugins.PluginMetaData;
25 27
 import com.dmdirc.Main;
26 28
 import com.dmdirc.WritableFrameContainer;
27 29
 import com.dmdirc.addons.ui_swing.MainFrame;
28 30
 import com.dmdirc.addons.ui_swing.SwingController;
29 31
 import com.dmdirc.addons.ui_swing.SwingWindowFactory;
30
-import com.dmdirc.addons.ui_swing.components.frames.CustomInputFrame;
31 32
 import com.dmdirc.config.ConfigManager;
32 33
 import com.dmdirc.config.IdentityManager;
33 34
 import com.dmdirc.config.InvalidIdentityFileException;
34 35
 import com.dmdirc.plugins.PluginManager;
35 36
 import com.dmdirc.ui.messages.IRCDocument;
37
+import com.dmdirc.updater.Version;
36 38
 
37 39
 import org.uispec4j.UISpecTestCase;
38 40
 import static org.mockito.Mockito.*;
@@ -63,10 +65,15 @@ public class DMDircUITestCase extends UISpecTestCase {
63 65
      * @return SwingController mock
64 66
      */
65 67
     public static SwingController getMockedController() {
68
+        final PluginInfo pluginInfo = mock(PluginInfo.class);
69
+        final PluginMetaData metaData = mock(PluginMetaData.class);
66 70
         SwingController controller = mock(SwingController.class);
67 71
         final SwingWindowFactory windowFactory = mock(SwingWindowFactory.class);
68 72
         when(controller.getDomain()).thenReturn("test");
69 73
         when(controller.getWindowFactory()).thenReturn(windowFactory);
74
+        when(controller.getPluginInfo()).thenReturn(pluginInfo);
75
+        when(pluginInfo.getMetaData()).thenReturn(metaData);
76
+        when(metaData.getVersion()).thenReturn(new Version(1));
70 77
 
71 78
         return controller;
72 79
     }

Loading…
Cancel
Save