-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for Profile and Packet + minor fixes
- Loading branch information
Showing
14 changed files
with
188 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon Feb 10 16:34:29 CET 2020 | ||
#Wed Mar 25 02:20:13 EET 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-rc-1-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package hostage.profile; | ||
|
||
import android.graphics.Bitmap; | ||
import android.os.Parcel; | ||
import android.support.test.filters.LargeTest; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.HashMap; | ||
|
||
import de.tudarmstadt.informatik.hostage.model.Profile; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ProfileTest { | ||
private String mText; | ||
private String mLabel; | ||
private int mId; | ||
private boolean mActivated; | ||
transient private Bitmap mIcon; | ||
transient private int mIconId; | ||
private String mIconName; | ||
private String mIconPath; | ||
|
||
private boolean mEditable = false; | ||
private boolean mIsRandom = false; | ||
|
||
private HashMap<String, Boolean> mActiveProtocols = new HashMap<String, Boolean>(); | ||
private String mGhostPorts = ""; | ||
private boolean mGhostActive = false; | ||
private boolean mShowTooltip = false; | ||
|
||
Profile profileBitmap; | ||
Profile profilePath; | ||
|
||
@Before | ||
public void setUp() { | ||
mText = "androidTest"; | ||
mLabel = "testLabel"; | ||
mId = 2; | ||
mActivated = true; | ||
mIcon = null; | ||
mIconId = 3; | ||
mIconName = "testIcon"; | ||
mIconPath = "testPath"; | ||
mEditable = false; | ||
mIsRandom = false; | ||
mActiveProtocols = new HashMap<String, Boolean>(); | ||
mActiveProtocols.put("androidTest",true); | ||
mGhostPorts = ""; | ||
mGhostActive = false; | ||
mShowTooltip = false; | ||
|
||
profileBitmap = new Profile(mId, mLabel,mText, mIcon, mEditable); | ||
profilePath = new Profile(mId, mLabel,mText, mIconPath, mEditable); | ||
} | ||
|
||
@Test | ||
public void emptyConstructorTest() { | ||
Profile profile = new Profile(); | ||
|
||
assertTrue(profile.mEditable); | ||
assertFalse(profile.mActivated); | ||
assertTrue(profile.mId == -1); | ||
|
||
} | ||
|
||
@Test | ||
public void bitMapConstructorTest(){ | ||
|
||
assertTrue(profileBitmap.mId == 2) ; | ||
assertEquals("testLabel",profileBitmap.mLabel); | ||
assertTrue(profileBitmap.mText.equals("androidTest")); | ||
assertNull(profileBitmap.mIcon); | ||
assertFalse(profileBitmap.mEditable); | ||
|
||
} | ||
|
||
@Test | ||
public void pathConstructorTest(){ | ||
|
||
assertTrue(profilePath.mId == 2) ; | ||
assertEquals("testLabel",profilePath.mLabel); | ||
assertTrue(profilePath.mText.equals("androidTest")); | ||
assertTrue(profilePath.mIconPath.equals("testPath")); | ||
assertFalse(profilePath.mEditable); | ||
|
||
} | ||
|
||
@Test | ||
public void checkProfileIsParcableTest(){ | ||
|
||
Parcel parcel = Parcel.obtain(); | ||
parcel.writeString(mText); | ||
parcel.writeString(mLabel); | ||
parcel.writeInt(mId); | ||
parcel.writeByte((byte) (mActivated ? 1 : 0)); | ||
parcel.writeInt(mIconId); | ||
parcel.writeString(mIconName); | ||
parcel.writeString(mIconPath); | ||
parcel.writeByte((byte) (mEditable ? 1 : 0)); | ||
parcel.writeSerializable(mActiveProtocols); | ||
parcel.setDataPosition(0); | ||
|
||
|
||
Profile parceled = new Profile(parcel); | ||
|
||
assertTrue(parceled.mId == 2) ; | ||
assertTrue(parceled.mIconId == 3) ; | ||
assertTrue(parceled.mLabel.equals("testLabel")); | ||
assertTrue(parceled.mText.equals("androidTest")); | ||
assertTrue(parceled.mIconPath.equals("testPath")); | ||
assertTrue(mActivated); | ||
assertFalse(mEditable); | ||
assertFalse(parceled.mEditable); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hostage.wrapper; | ||
|
||
import org.junit.Test; | ||
import de.tudarmstadt.informatik.hostage.wrapper.Packet; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class PacketTest { | ||
@Test | ||
public void constructorTest(){ | ||
String test = "androidTest"; | ||
byte[] payload = test.getBytes(); | ||
String protocol = "SMB"; | ||
Packet packet = new Packet(payload,protocol); | ||
assertTrue(packet.getBytes().equals(payload)); | ||
assertTrue(packet.getProtocol().equals(protocol)); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.