Skip to content

Commit de588b4

Browse files
Merge pull request #11 from stealthcopter/develop
Develop
2 parents 412fe8c + ca141f4 commit de588b4

File tree

15 files changed

+582
-196
lines changed

15 files changed

+582
-196
lines changed

.directory

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Dolphin]
2+
Timestamp=2016,10,20,19,55,56
3+
Version=3
4+
5+
[Settings]
6+
HiddenFilesShown=true

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,77 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
9+
}
10+
}
11+
112
apply plugin: 'com.android.application'
13+
apply plugin: 'spoon'
214

315
android {
4-
compileSdkVersion 24
5-
buildToolsVersion "24.0.0"
16+
compileSdkVersion compileSdkVer
17+
buildToolsVersion buildToolsVer
618

719
defaultConfig {
820
applicationId "com.stealthcotper.networktools"
9-
minSdkVersion 14
10-
targetSdkVersion 24
11-
versionCode 4
12-
versionName "0.1.05"
21+
minSdkVersion minSdkVer
22+
targetSdkVersion targetSdkVer
23+
versionCode 6
24+
versionName "0.1.08"
25+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1326
}
27+
28+
//check if the keystore details are defined in gradle.properties (this is so the key is not in github)
29+
if (project.hasProperty("ANDROID_NETWORK_TOOLS_STORE")) {
30+
signingConfigs {
31+
//from ~/.gradle/gradle.properties
32+
release {
33+
storeFile file(ANDROID_NETWORK_TOOLS_STORE)
34+
keyAlias ANDROID_NETWORK_TOOLS_ALIAS
35+
storePassword ANDROID_NETWORK_TOOLS_PASS
36+
keyPassword ANDROID_NETWORK_TOOLS_KEY_PASS
37+
}
38+
}
39+
}
40+
1441
buildTypes {
1542
release {
43+
if (project.hasProperty("ANDROID_NETWORK_TOOLS_STORE")) {
44+
signingConfig signingConfigs.release
45+
}
1646
minifyEnabled false
1747
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1848
}
1949
}
50+
51+
productFlavors {
52+
regular { }
53+
// Add a CI only flavor that has extra permissions needed for CI to perform
54+
ci { }
55+
}
56+
57+
}
58+
59+
// Spoon used for CI / Testing
60+
spoon {
61+
debug = true
62+
// To grant permissions to Android M >= devices */
63+
grantAllPermissions = true
2064
}
2165

2266
dependencies {
2367
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
testCompile 'junit:junit:4.12'
25-
compile 'com.android.support:appcompat-v7:24.2.0'
26-
compile 'com.android.support:design:24.2.0'
68+
compile "com.android.support:appcompat-v7:$supportLibVer"
69+
compile "com.android.support:design:$supportLibVer"
2770
compile project(':library')
71+
72+
testCompile 'junit:junit:4.12'
73+
74+
androidTestCompile 'com.squareup.spoon:spoon-client:1.6.4'
75+
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
76+
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2')
2877
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.stealthcotper.networktools;
2+
3+
/**
4+
* Created by matthew on 20/12/16.
5+
*/
6+
7+
import android.support.test.rule.ActivityTestRule;
8+
import android.support.test.runner.AndroidJUnit4;
9+
import android.view.WindowManager;
10+
11+
import com.squareup.spoon.Spoon;
12+
13+
import org.junit.Before;
14+
import org.junit.Rule;
15+
import org.junit.Test;
16+
import org.junit.runner.RunWith;
17+
18+
import static android.support.test.espresso.Espresso.onView;
19+
import static android.support.test.espresso.action.ViewActions.clearText;
20+
import static android.support.test.espresso.action.ViewActions.click;
21+
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
22+
import static android.support.test.espresso.action.ViewActions.typeText;
23+
import static android.support.test.espresso.assertion.ViewAssertions.matches;
24+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
25+
import static android.support.test.espresso.matcher.ViewMatchers.withText;
26+
27+
@RunWith(AndroidJUnit4.class)
28+
public class MainActivityTest {
29+
30+
private MainActivity activity;
31+
32+
@Rule
33+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
34+
MainActivity.class);
35+
36+
@Before
37+
public void setUp() {
38+
activity = mActivityRule.getActivity();
39+
40+
// Code to wake up screen before running tests
41+
Runnable wakeUpDevice = new Runnable() {
42+
public void run() {
43+
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
44+
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
45+
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
46+
}
47+
};
48+
activity.runOnUiThread(wakeUpDevice);
49+
}
50+
51+
@Test
52+
public void checkPing() {
53+
54+
Spoon.screenshot(mActivityRule.getActivity(), "ping");
55+
56+
setUpText("google.com");
57+
58+
// Click ping button
59+
onView(withId(R.id.pingButton)).perform(click());
60+
61+
sleep();
62+
63+
Spoon.screenshot(mActivityRule.getActivity(), "ping");
64+
}
65+
66+
@Test
67+
public void checkWOL() {
68+
69+
Spoon.screenshot(mActivityRule.getActivity(), "wake-on-lan");
70+
71+
setUpText("localhost");
72+
73+
// Click ping button
74+
onView(withId(R.id.wolButton)).perform(click());
75+
76+
sleep();
77+
78+
Spoon.screenshot(mActivityRule.getActivity(), "wake-on-lan");
79+
}
80+
81+
@Test
82+
public void checkPortScan() {
83+
84+
Spoon.screenshot(mActivityRule.getActivity(), "port_scan");
85+
86+
setUpText("localhost");
87+
88+
// Click ping button
89+
onView(withId(R.id.portScanButton)).perform(click());
90+
91+
sleep();
92+
93+
Spoon.screenshot(mActivityRule.getActivity(), "port_scan");
94+
}
95+
96+
// @Test
97+
// public void checkGitHubButton(){
98+
// onView(withId(R.id.action_github)).perform(click());
99+
//
100+
// intended(allOf(hasData(hasHost(equalTo("www.google.com"))),
101+
// hasAction(Intent.ACTION_VIEW)));
102+
// }
103+
104+
private void setUpText(String hostNameOrIp){
105+
// Enter text
106+
onView(withId(R.id.editIpAddress))
107+
.perform(clearText(), typeText(hostNameOrIp), closeSoftKeyboard());
108+
109+
// Check text is entered
110+
onView(withId(R.id.editIpAddress)).check(matches(withText(hostNameOrIp)));
111+
}
112+
113+
private void sleep(){
114+
try {
115+
Thread.sleep(1500);
116+
} catch (InterruptedException e) {
117+
e.printStackTrace();
118+
}
119+
}
120+
121+
}

app/src/ci/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.stealthcotper.networktools"
4+
>
5+
<!-- Debug package contains write storage for screenshots in CI server and wake lock to keep emulator screen on-->
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
8+
</manifest>

0 commit comments

Comments
 (0)