mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
issue #18 fix feeder initialization from command-line
This commit is contained in:
parent
c583e79fc2
commit
3c3e38870e
@ -16,7 +16,6 @@ import net.azib.ipscan.core.state.StateTransitionListener;
|
||||
import net.azib.ipscan.gui.MainMenu.CommandsMenu;
|
||||
import net.azib.ipscan.gui.actions.StartStopScanningAction;
|
||||
import net.azib.ipscan.gui.actions.ToolsActions;
|
||||
import net.azib.ipscan.gui.feeders.AbstractFeederGUI;
|
||||
import net.azib.ipscan.gui.feeders.FeederGUIRegistry;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
@ -142,11 +141,7 @@ public class MainWindow {
|
||||
// feederArea is the placeholder for the visible feeder
|
||||
this.feederArea = feederArea;
|
||||
feederArea.setLayoutData(formData(new FormAttachment(0), null, new FormAttachment(0), null));
|
||||
|
||||
this.feederRegistry = feederRegistry;
|
||||
for (AbstractFeederGUI feeder : feederRegistry) {
|
||||
feeder.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -32,6 +32,7 @@ public abstract class AbstractFeederGUI extends Composite implements FeederCreat
|
||||
public AbstractFeederGUI(Composite parent) {
|
||||
super(parent, SWT.NONE);
|
||||
setVisible(false);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public abstract void initialize();
|
||||
|
||||
@ -11,6 +11,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* AbstractFeederGUITest
|
||||
@ -18,13 +19,14 @@ import static org.junit.Assert.assertEquals;
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class AbstractFeederGUITest {
|
||||
|
||||
private boolean initialized;
|
||||
private AbstractFeederGUI feederGUI;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
feederGUI = new AbstractFeederGUI(new Shell()) {
|
||||
public void initialize() {
|
||||
initialized = true;
|
||||
}
|
||||
public String getFeederName() {
|
||||
return "Mega Feeder";
|
||||
@ -45,7 +47,12 @@ public class AbstractFeederGUITest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInfo() {
|
||||
public void initializeMustBeCalledInConstructor() throws Exception {
|
||||
assertTrue("otherwise command-line will be broken", initialized);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInfo() {
|
||||
assertEquals("Mega Feeder: 127.0.0.1 - 127.0.0.2", feederGUI.getInfo());
|
||||
}
|
||||
|
||||
@ -56,5 +63,4 @@ public class AbstractFeederGUITest {
|
||||
Labels.getLabel(label);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user