mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
test written for prepareText in StatisticsDialog
git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@393 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
f597e582f0
commit
30f04aa82d
@ -289,14 +289,14 @@ public class ScanningResultList implements Iterable<ScanningResult> {
|
||||
*/
|
||||
public static class ScanInfo {
|
||||
|
||||
boolean scanFinished;
|
||||
boolean scanAborted;
|
||||
protected boolean scanFinished;
|
||||
protected boolean scanAborted;
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
long endTime;
|
||||
int numScanned;
|
||||
int numAlive;
|
||||
int numWithPorts;
|
||||
protected long startTime = System.currentTimeMillis();
|
||||
protected long endTime;
|
||||
protected int numScanned;
|
||||
protected int numAlive;
|
||||
protected int numWithPorts;
|
||||
|
||||
/**
|
||||
* @return total scan time, in milliseconds.
|
||||
|
||||
@ -81,7 +81,7 @@ public class StatisticsDialog extends AbstractModalDialog {
|
||||
Text statsText = new Text(shell, SWT.MULTI | SWT.READ_ONLY);
|
||||
statsText.setBackground(currentDisplay.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
statsText.setLayoutData(LayoutHelper.formData(new FormAttachment(iconLabel), null, new FormAttachment(titleLabel), null));
|
||||
statsText.setText(prepareText(scanningResults.getScanInfo()));
|
||||
statsText.setText(prepareText());
|
||||
statsText.pack();
|
||||
|
||||
Button button = createCloseButton();
|
||||
@ -92,7 +92,8 @@ public class StatisticsDialog extends AbstractModalDialog {
|
||||
shell.pack();
|
||||
}
|
||||
|
||||
private String prepareText(ScanInfo scanInfo) {
|
||||
String prepareText() {
|
||||
ScanInfo scanInfo = scanningResults.getScanInfo();
|
||||
String ln = System.getProperty("line.separator");
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append(Labels.getLabel("text.scan.time.total"))
|
||||
|
||||
@ -6,11 +6,19 @@
|
||||
|
||||
package net.azib.ipscan.gui;
|
||||
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.core.ScanningResultList;
|
||||
import net.azib.ipscan.core.ScanningResultList.ScanInfo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -33,4 +41,35 @@ public class StatisticsDialogTest {
|
||||
assertEquals("1\u00A0h", StatisticsDialog.timeToText(3600000));
|
||||
assertEquals("2.5\u00A0h", StatisticsDialog.timeToText(9036000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testname() throws Exception {
|
||||
ScanningResultList results = createMock(ScanningResultList.class);
|
||||
ScanInfo scanInfo = new ScanInfo() {
|
||||
{
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.endTime = this.startTime + 10000;
|
||||
this.numScanned = 20;
|
||||
this.numAlive = 10;
|
||||
this.numWithPorts = 5;
|
||||
}
|
||||
};
|
||||
|
||||
expect(results.getScanInfo()).andReturn(scanInfo);
|
||||
expect(results.getFeederName()).andReturn("SomeFeeder");
|
||||
expect(results.getFeederInfo()).andReturn("SomeInfoHere");
|
||||
replay(results);
|
||||
|
||||
String text = new StatisticsDialog(results).prepareText();
|
||||
|
||||
assertNotNull(text);
|
||||
assertTrue(text.contains(Labels.getLabel("text.scan.time.total") + "10"));
|
||||
assertTrue(text.contains(Labels.getLabel("text.scan.time.average") + "0.5"));
|
||||
assertTrue(text.contains("SomeFeeder"));
|
||||
assertTrue(text.contains("SomeInfoHere"));
|
||||
assertTrue(text.contains(Labels.getLabel("text.scan.hosts.total") + "20"));
|
||||
assertTrue(text.contains(Labels.getLabel("text.scan.hosts.alive") + "10"));
|
||||
assertTrue(text.contains(Labels.getLabel("text.scan.hosts.ports") + "5"));
|
||||
verify(results);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user