Skip to content

Commit fc791a3

Browse files
committed
add shell app for testing cli apps
1 parent 911fb5c commit fc791a3

File tree

11 files changed

+417
-206
lines changed

11 files changed

+417
-206
lines changed

test-cli-app/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
/build
88
/captures
99
app/build
10-
app/src
10+
app/src/*
1111
app/.iml
1212
app/proguard-rules.pro
1313
!app/build.gradle
14-
!app/src/.gitkeep
14+
!app/src/.gitkeep
15+
gradle-app.setting

test-cli-app/app/build.gradle

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* run from dir: test-app/
3+
* run on emulator: ./gradlew runtests //default
4+
* run on device: ./gradlew runtests -PrunOnDevice
5+
*
6+
*/
7+
8+
9+
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
10+
11+
apply plugin: 'com.android.model.application'
12+
13+
def runOnDevice = project.hasProperty("runOnDevice");
14+
def runOnDeviceOrEmulator = runOnDevice ? "-d" : "-e";
15+
16+
model {
17+
android {
18+
compileSdkVersion = 25
19+
buildToolsVersion = "25.0.2"
20+
21+
defaultConfig.with {
22+
applicationId = "com.tns.debugapp"
23+
minSdkVersion.apiLevel = 17
24+
targetSdkVersion.apiLevel = 22
25+
versionCode = 1
26+
versionName = "1.0"
27+
}
28+
29+
lintOptions.with {
30+
abortOnError = false
31+
}
32+
}
33+
34+
// android.ndk {
35+
// moduleName = "test-app-dummy-native-lib"
36+
// }
37+
38+
android.buildTypes {
39+
release {
40+
minifyEnabled = false
41+
proguardFiles.add(file('proguard-rules.txt'))
42+
}
43+
}
44+
}
45+
46+
dependencies {
47+
def supportVer = "23.3.0"
48+
compile project(':runtime')
49+
compile fileTree(include: ['*.jar'], dir: 'libs')
50+
51+
compile "com.android.support:support-v4:$supportVer"
52+
compile "com.android.support:appcompat-v7:$supportVer"
53+
compile "com.android.support:design:$supportVer"
54+
55+
testCompile 'junit:junit:4.12'
56+
}
57+
58+
repositories {
59+
jcenter()
60+
flatDir {
61+
dirs 'src/F0', 'src/F1',
62+
'src/F2', 'src/F3',
63+
'src/F4', 'src/F5',
64+
'src/F6', 'src/F7',
65+
'src/F8', 'src/F9',
66+
'src/F10', 'src/F11'
67+
}
68+
}
69+
70+
task addAarDependencies {
71+
FileTree tree = fileTree(dir: "$projectDir/src", include: ["**/*.aar"])
72+
tree.each { File file ->
73+
// remove the extension of the file (.aar)
74+
def length = file.name.length() - 4
75+
def fileName = file.name[0..<length]
76+
println "\t+adding dependency: " + file.getAbsolutePath()
77+
project.dependencies.add("compile", [name: fileName, ext: "aar"])
78+
}
79+
}
80+
81+
/////////////////////////////// installing application ////////////////////////////
82+
83+
task installApk(type: Exec) {
84+
doFirst {
85+
println "Attempting to install buit apk"
86+
87+
if (isWinOs) {
88+
commandLine "cmd", "/c", "node", "$rootDir\\tools\\deploy-apk.js", "$rootDir\\runtimedebug\\build\\outputs\\apk\\app-debug.apk"
89+
} else {
90+
commandLine "node", "$rootDir/tools/deploy-apk.js", "$rootDir/runtimedebug/build/outputs/apk/app-debug.apk"
91+
}
92+
}
93+
94+
doLast {
95+
println "Install result:" + execResult
96+
}
97+
}
98+
99+
task startInstalledApk(type: Exec) {
100+
doFirst {
101+
println "Starting test application"
102+
103+
if (isWinOs) {
104+
commandLine "cmd", "/c", "adb", "shell", "am", "start", "-n", "org.nativescript.runtimedebug/com.tns.NativeScriptActivity", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER"
105+
} else {
106+
commandLine "adb", "shell", "am", "start", "-n", "org.nativescript.runtimedebug/com.tns.NativeScriptActivity", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER"
107+
}
108+
}
109+
}
110+
111+
startInstalledApk.dependsOn(installApk)
112+
113+
task deleteDist (type: Delete) {
114+
doFirst {
115+
delete "$rootDir/dist"
116+
}
117+
}

test-cli-app/app/src/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

test-cli-app/build.gradle

Lines changed: 16 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,25 @@
1-
apply plugin: 'com.android.model.application'
1+
/*
2+
* Usage:
3+
* gradlew assembleDebug - Builds an Android apk in debug
4+
* gradlew assembleRelease - Builds an Android apk in release
5+
* gradlew runtests - Builds and runs the test applciation and pull an test results xml file in /dist/android_unit_test_results.xml
6+
*/
27

3-
import groovy.json.JsonSlurper //used to parse package.json
48

5-
model {
6-
android {
7-
compileSdkVersion = 23
8-
buildToolsVersion = "23.0.3"
99

10-
defaultConfig.with {
11-
applicationId = "org.nativescript.runtimedebug"
12-
minSdkVersion.apiLevel = 17
13-
targetSdkVersion.apiLevel = 22
14-
versionCode = 1
15-
versionName = "1.0"
16-
}
17-
18-
lintOptions.with {
19-
abortOnError = false
20-
}
21-
}
22-
23-
android.buildTypes {
24-
release {
25-
minifyEnabled = false
26-
proguardFiles.add(file('proguard-rules.txt'))
27-
}
28-
}
29-
}
30-
31-
dependencies {
32-
compile project(':runtime')
33-
compile project(':binding-generator')
34-
compile fileTree(dir: 'libs', include: ['*.jar'])
35-
testCompile 'junit:junit:4.12'
36-
compile 'com.android.support:appcompat-v7:23.3.0'
37-
compile "com.android.support:support-v4:23.3.0"
38-
}
39-
40-
repositories {
41-
jcenter()
42-
flatDir {
43-
dirs 'src/F0', 'src/F1',
44-
'src/F2', 'src/F3',
45-
'src/F4', 'src/F5',
46-
'src/F6', 'src/F7',
47-
'src/F8', 'src/F9',
48-
'src/F10', 'src/F11'
49-
}
50-
}
51-
52-
task addAarDependencies {
53-
FileTree tree = fileTree(dir: "$projectDir/src", include: ["**/*.aar"])
54-
tree.each { File file ->
55-
// remove the extension of the file (.aar)
56-
def length = file.name.length() - 4
57-
def fileName = file.name[0..<length]
58-
println "\t+adding dependency: " + file.getAbsolutePath()
59-
project.dependencies.add("compile", [name: fileName, ext: "aar"])
60-
}
61-
}
62-
63-
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
64-
65-
/////////////////////////////// installing application ////////////////////////////
66-
67-
task installApk(type: Exec) {
68-
doFirst {
69-
println "Attempting to install buit apk"
70-
71-
if (isWinOs) {
72-
commandLine "cmd", "/c", "node", "$rootDir\\tools\\deploy-apk.js", "$rootDir\\runtimedebug\\build\\outputs\\apk\\app-debug.apk"
73-
} else {
74-
commandLine "node", "$rootDir/tools/deploy-apk.js", "$rootDir/runtimedebug/build/outputs/apk/app-debug.apk"
75-
}
10+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
11+
buildscript {
12+
repositories {
13+
jcenter()
7614
}
7715

78-
doLast {
79-
println "Install result:" + execResult
16+
dependencies {
17+
classpath 'com.android.tools.build:gradle-experimental:0.8.2'
8018
}
8119
}
8220

83-
task startInstalledApk(type: Exec) {
84-
doFirst {
85-
println "Starting test application"
86-
87-
if (isWinOs) {
88-
commandLine "cmd", "/c", "adb", "shell", "am", "start", "-n", "org.nativescript.runtimedebug/com.tns.NativeScriptActivity", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER"
89-
} else {
90-
commandLine "adb", "shell", "am", "start", "-n", "org.nativescript.runtimedebug/com.tns.NativeScriptActivity", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER"
91-
}
21+
allprojects {
22+
repositories {
23+
jcenter()
9224
}
93-
}
94-
95-
startInstalledApk.dependsOn(installApk)
25+
}

test-cli-app/gradle.properties

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Project-wide Gradle settings.
2+
3+
# IDE (e.g. Android Studio) users:
4+
# Gradle settings configured through the IDE *will override*
5+
# any settings specified in this file.
6+
7+
# For more details on how to configure your build environment visit
8+
# http://www.gradle.org/docs/current/userguide/build_environment.html
9+
10+
# Specifies the JVM arguments used for the daemon process.
11+
# The setting is particularly useful for tweaking memory settings.
12+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14+
15+
# When configured, Gradle will run in incubating parallel mode.
16+
# This option should only be used with decoupled projects. More details, visit
17+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18+
# org.gradle.parallel=true
19+
20+
#org.gradle.jvmargs=-Xmx2048M
52.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Aug 18 11:40:33 EEST 2016
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 commit comments

Comments
 (0)