Skip to content

Commit 2b63ea6

Browse files
vakrilovatanasovg
authored andcommitted
Update release to master
1 parent 8d37a26 commit 2b63ea6

File tree

9 files changed

+243
-12
lines changed

9 files changed

+243
-12
lines changed

src/assets/app/bootstrap.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,25 @@ global.__onUncaughtError = function(error){
1010
return true;
1111
}
1212

13+
require('./Infrastructure/timers');
14+
15+
global.__JUnitSaveResults = function (unitTestResults) {
16+
var pathToSdcard = '/sdcard';
17+
var unitTestFileName = 'android_unit_test_results.xml';
18+
try {
19+
var javaFile = new java.io.File(pathToSdcard, unitTestFileName);
20+
var stream = new java.io.FileOutputStream(javaFile);
21+
var actualEncoding = 'UTF-8';
22+
var writer = new java.io.OutputStreamWriter(stream, actualEncoding);
23+
writer.write(unitTestResults);
24+
writer.close();
25+
}
26+
catch (exception) {
27+
__log('failed writing to files dir: ' + exception);
28+
}
29+
};
30+
31+
require('./Infrastructure/Jasmine/jasmine-2.0.1/boot'); //runs jasmine, attaches the junitOutputter
32+
33+
1334
require("./mainpage");

src/src/com/tns/DexFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private String getClassToProxyName(String className) throws InvalidClassExceptio
208208
{
209209
throw new InvalidClassException("Can't generate proxy of proxy");
210210
}
211-
211+
212212
return classToProxy;
213213
}
214214

src/src/com/tns/JsDebugger.java

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,15 @@ int getDebuggerPortFromEnvironment()
352352

353353
if (shouldDebugBreakFlag)
354354
{
355-
356-
try
357-
{
358-
Thread.sleep(3 * 1000);
359-
}
360-
catch (InterruptedException e1)
361355
{
362-
e1.printStackTrace();
356+
try
357+
{
358+
Thread.sleep(3 * 1000);
359+
}
360+
catch (InterruptedException e1)
361+
{
362+
e1.printStackTrace();
363+
}
363364
}
364365
}
365366

@@ -556,7 +557,34 @@ private boolean shouldDebugBreak()
556557
{
557558
debugBreakFile.delete();
558559
}
560+
}
561+
562+
563+
public static Boolean shouldDebugBreakFlag = null;
564+
565+
public static boolean shouldDebugBreak(Context context)
566+
{
567+
if (shouldDebugBreakFlag != null)
568+
{
569+
return shouldDebugBreakFlag;
570+
}
571+
572+
if (!shouldEnableDebugging(context))
573+
{
574+
shouldDebugBreakFlag = false;
575+
return false;
576+
}
577+
578+
String appRoot = context.getFilesDir().getPath() + File.separator;
579+
File debugBreakFile = new File(appRoot, DEBUG_BREAK_FILENAME);
580+
if (debugBreakFile.exists())
581+
{
582+
debugBreakFile.delete();
583+
shouldDebugBreakFlag = true;
584+
return true;
585+
}
559586

560-
return shouldDebugBreakFlag;
587+
shouldDebugBreakFlag = false;
588+
return false;
561589
}
562590
}

test-app/ant.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
key.store.password=aaaaaa
2+
key.alias.password=aaaaaa
3+
key.store=./custom_sign.keystore
4+
key.alias=aaaa-alias

test-app/assets/app/modules/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ module.exports = {
1818
}
1919
}
2020

21-
module.exports.value123 = 123;
21+
module.exports.value123 = 123;

test-app/assets/app/tests/tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,6 @@ describe("Tests ", function () {
14101410

14111411
expect(exceptionCaught).toBe(true);
14121412
});
1413-
Assert(exceptionCaught === true, "TestThrowJavaScriptExceptionWhenOverideMethodImplementationIsDeleted FAILED (1): No exception is thrown");
1414-
>>>>>>> rename global functions
14151413

14161414
it("TestThrowJavaScriptExceptionWhenCallJavaMethodWithJavaScriptPrimitiveWhenJavaRefIsExpected", function () {
14171415

test-app/custom_rules.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="custom_logic_for_metadata_generation" default="-post-compile">
3+
4+
<property name="path_to_metadata" value="./assets/metadata"/>
5+
<property name="generatedJarLocation" value="./dist" />
6+
<property name="sdk_warning" value="Currently runAntRelease step in grunt file includes an ant custom_rules.xml step which generates latest greatest metadata... Currently we generate metadata using the target sdk declared in the AndroidManifest file and if the sdk is missing the build will fail" />
7+
8+
<!-- GET MIN SDK VERSION FROM MANIFEST AND SAVE IN PROP "minSdkVersion" -->
9+
<target name="retrieve_min_version_from_manifest">
10+
11+
<xmlproperty file="./AndroidManifest.xml" collapseAttributes="true"/>
12+
13+
<property name="relative_path_to_min_declared_sdk" value="platforms/android-${manifest.uses-sdk.android:minSdkVersion}/android.jar" />
14+
15+
</target>
16+
17+
<!-- REPLACE MIN SDK JAR WITH ONE ON USER MACHINE -->
18+
<target name="copy_target_sdk" depends="retrieve_min_version_from_manifest">
19+
<echo message="WARNING: ${sdk_warning}" />
20+
21+
<copy file="${sdk.dir}/${relative_path_to_min_declared_sdk}" todir="${generatedJarLocation}"/>
22+
23+
</target>
24+
25+
<target name="copy_ns_jar" >
26+
27+
<copy file="./../dist/framework/libs/nativescript.jar" todir="./dist"/>
28+
29+
</target>
30+
31+
<target name="copy_support_jar" >
32+
33+
<copy file="./../dist/framework/libs/android-support-v4.jar" todir="./dist"/>
34+
35+
</target>
36+
37+
<target name="generate_jar_from_classes">
38+
39+
<jar destfile="${generatedJarLocation}/test-app.jar" basedir="./bin/classes"/>
40+
41+
</target>
42+
43+
<target name="delete_old_metadata">
44+
45+
<delete>
46+
47+
<fileset dir="${path_to_metadata}" includes="**/*.dat"/>
48+
49+
</delete>
50+
51+
</target>
52+
53+
54+
<!-- PASS JARS TO METADATA GENERATOR -->
55+
<!-- currently we generate metadata using the target sdk declared in the AndroidManifest file -->
56+
<target name="generate_metadata_from_given_jars" depends="copy_target_sdk, copy_ns_jar, copy_support_jar, generate_jar_from_classes, delete_old_metadata">
57+
58+
<java classname="com.telerik.metadata.Generator">
59+
60+
<arg value="./dist"></arg>
61+
62+
<arg value="${path_to_metadata}"></arg>
63+
64+
<classpath>
65+
<pathelement location="./../node_modules/tns-android-metadata-generator/classes"/>
66+
</classpath>
67+
68+
</java>
69+
70+
<echo message=" --------- created new metadata and moved it to assets/metadata" />
71+
72+
</target>
73+
74+
75+
<target name="delete_all_files_in_dist" depends="generate_metadata_from_given_jars">
76+
77+
<delete>
78+
<fileset dir="${generatedJarLocation}" includes="**/*.jar"/>
79+
</delete>
80+
81+
</target>
82+
83+
<target name="-post-compile" depends="delete_all_files_in_dist">
84+
85+
</target>
86+
87+
</project>

test-app/custom_sign.keystore

2.19 KB
Binary file not shown.

test-app/gruntfile.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//runs test app on device
2+
3+
module.exports = function(grunt) {
4+
5+
var pathModule = require("path");
6+
7+
var localCfg = {
8+
rootDir: ".",
9+
outDir: "./dist",
10+
};
11+
12+
grunt.initConfig({
13+
wait: {
14+
timeToRunTests: {
15+
options: {
16+
delay: 180000
17+
}
18+
}
19+
},
20+
clean: {
21+
build: {
22+
src: [localCfg.outDir]
23+
},
24+
metadata: {
25+
src: "./assets/metadata/*"
26+
}
27+
},
28+
mkdir: {
29+
build: {
30+
options: {
31+
create: [localCfg.outDir]
32+
}
33+
}
34+
},
35+
exec: {
36+
createBuildXml: {
37+
cmd: "android update project --path ."
38+
},
39+
runAntRelease: {
40+
cmd: "ant release"
41+
},
42+
installApkOnDevice: {
43+
cmd: "node ./tasks/deploy-apk.js ./bin/NativeScriptActivity-release.apk",
44+
cwd: "."
45+
},
46+
startInstalledApk: {
47+
cmd: "adb shell am start -n com.tns.android_runtime_testapp/com.tns.NativeScriptActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER",
48+
cwd: "./bin"
49+
},
50+
copyResultToDist: {
51+
cmd: "adb pull /sdcard/android_unit_test_results.xml",
52+
cwd: localCfg.outDir
53+
}
54+
},
55+
copy: {
56+
//these .so files need to be in the src/libs folder because the test-app refers them
57+
//later if we want to separate the tests from the build, these files can be taken from k:distributions ... stable/android-runtime/ ...
58+
generatedLibraries: {
59+
expand: true,
60+
cwd: "../src/dist/libs/",
61+
src: [
62+
"**/armeabi-v7a/*",
63+
"**/x86/*"
64+
],
65+
dest: "../src/libs/"
66+
}
67+
}
68+
});
69+
70+
grunt.loadNpmTasks("grunt-contrib-clean");
71+
grunt.loadNpmTasks("grunt-contrib-copy");
72+
grunt.loadNpmTasks("grunt-mkdir");
73+
grunt.loadNpmTasks("grunt-exec");
74+
grunt.loadNpmTasks("grunt-replace");
75+
grunt.loadNpmTasks('grunt-wait');
76+
77+
grunt.registerTask("default", [
78+
"clean:build",
79+
"mkdir:build",
80+
"copy:generatedLibraries",
81+
"exec:createBuildXml",
82+
83+
//currently runAntRelease step includes an ant custom build step which generates latest greatest metadata
84+
//currently we generate metadata using the target sdk declared in the AndroidManifest file and if the sdk is missing the build will fail
85+
"exec:runAntRelease",
86+
87+
"exec:installApkOnDevice",
88+
"exec:startInstalledApk",
89+
"wait:timeToRunTests",
90+
"exec:copyResultToDist"
91+
]);
92+
93+
}

0 commit comments

Comments
 (0)