Skip to content

Commit 8def36d

Browse files
author
vhristov5555
committed
Add tests for issue NativeScript/android#1104 and NativeScript/android#1119. Also fix all tests which call nativevi dependency.
1 parent 91c22d2 commit 8def36d

File tree

22 files changed

+586
-49
lines changed

22 files changed

+586
-49
lines changed
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="23"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme">
27+
28+
<activity
29+
android:name="com.tns.NativeScriptActivity"
30+
android:label="@string/title_activity_kimera"
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
33+
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
35+
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:name="com.tns.ErrorReportActivity"/>
42+
</application>
43+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="17"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme">
27+
28+
<activity
29+
android:name="com.tns.NativeScriptActivity"
30+
android:label="@string/title_activity_kimera"
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
33+
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
35+
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:name="com.tns.ErrorReportActivity"/>
42+
</application>
43+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "org.nativescript.TestApp"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
defaultConfig {
10+
minSdkVersion 17
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "org.nativescript.TestApp"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
defaultConfig {
10+
minSdkVersion 23
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "org.nativescript.TestApp"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function onNavigatingTo(args) {
2+
var page = args.object;
3+
console.log("### TEST START ###");
4+
com.tns.mylib.Log();
5+
sleep(2000);
6+
console.log("### TEST SHOULD NOT CRASH ###");
7+
console.log("### TEST END ###");
8+
}
9+
exports.onNavigatingTo = onNavigatingTo;
10+
11+
function sleep(milliseconds) {
12+
var start = new Date().getTime();
13+
for (var i = 0; i < 1e7; i++) {
14+
if ((new Date().getTime() - start) > milliseconds){
15+
break;
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "mylib",
3+
"version": "1.0.0",
4+
"description": "Test",
5+
"nativescript": {
6+
"platforms": {
7+
"android": "4.1.0"
8+
}
9+
}
10+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "org.nativescript.TestApp"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
dependencies {
10+
}
11+
repositories{
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var createViewModel = require("./main-view-model").createViewModel;
2+
3+
function onNavigatingTo(args) {
4+
var page = args.object;
5+
page.bindingContext = createViewModel();
6+
}
7+
exports.onNavigatingTo = onNavigatingTo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var Observable = require("data/observable").Observable;
2+
3+
function getMessage(counter) {
4+
if (counter <= 0) {
5+
return "Hoorraaay! You unlocked the NativeScript clicker achievement!";
6+
} else {
7+
return counter + " taps left";
8+
}
9+
}
10+
11+
function createViewModel() {
12+
var viewModel = new Observable();
13+
viewModel.counter = 42;
14+
viewModel.message = getMessage(viewModel.counter);
15+
16+
viewModel.onTap = function() {
17+
console.log("### TEST START ###");
18+
var file = java.io.File.createTempFile("prefix");
19+
sleep(2000);
20+
console.log("### TEST SHOULD NOT CRASH ###");
21+
console.log("### TEST END ###");
22+
}
23+
24+
return viewModel;
25+
}
26+
27+
exports.createViewModel = createViewModel;
28+
29+
function sleep(milliseconds) {
30+
var start = new Date().getTime();
31+
for (var i = 0; i < 1e7; i++) {
32+
if ((new Date().getTime() - start) > milliseconds){
33+
break;
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "verbose-hello-world",
3+
"main": "app.js",
4+
"version": "1.7.0",
5+
"android": {
6+
"v8Flags": "--expose_gc",
7+
"autoCatchJSMethodNativeCalls": true
8+
}
9+
}

data/issues/android-runtime-993/api/main-page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ function onNavigatingTo(args) {
99
var context = utils.ad.getApplicationContext();
1010
console.log("### TEST START ###");
1111
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
12-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
12+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1313
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
14+
sleep(2000);
1415
console.log("###TEST API PASSED###");
1516
console.log("### TEST END ###");
1617
}
17-
exports.onNavigatingTo = onNavigatingTo;
18+
exports.onNavigatingTo = onNavigatingTo;
19+
20+
function sleep(milliseconds) {
21+
var start = new Date().getTime();
22+
for (var i = 0; i < 1e7; i++) {
23+
if ((new Date().getTime() - start) > milliseconds){
24+
break;
25+
}
26+
}
27+
}

data/issues/android-runtime-993/compile/main-page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ function onNavigatingTo(args) {
99
console.log("### TEST START ###");
1010
var context = utils.ad.getApplicationContext();
1111
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
12-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
12+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1313
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
14+
sleep(2000);
1415
console.log("###TEST COMPILE PASSED###");
1516
console.log("### TEST END ###");
1617
}
17-
exports.onNavigatingTo = onNavigatingTo;
18+
exports.onNavigatingTo = onNavigatingTo;
19+
20+
function sleep(milliseconds) {
21+
var start = new Date().getTime();
22+
for (var i = 0; i < 1e7; i++) {
23+
if ((new Date().getTime() - start) > milliseconds){
24+
break;
25+
}
26+
}
27+
}

data/issues/android-runtime-993/implementation/main-page.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@ function onNavigatingTo(args) {
99
console.log("### TEST START ###");
1010
var context = utils.ad.getApplicationContext();
1111
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
12-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
12+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1313
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
14+
sleep(2000);
1415
console.log("###TEST IMPLEMENTATION PASSED###");
1516
console.log("### TEST END ###");
1617
}
17-
exports.onNavigatingTo = onNavigatingTo;
18+
exports.onNavigatingTo = onNavigatingTo;
19+
function sleep(milliseconds) {
20+
var start = new Date().getTime();
21+
for (var i = 0; i < 1e7; i++) {
22+
if ((new Date().getTime() - start) > milliseconds){
23+
break;
24+
}
25+
}
26+
}

data/issues/android-runtime-993/plugins/api/main-page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ function onNavigatingTo(args) {
1111
com.tns.mylib.useDependency();
1212
var context = utils.ad.getApplicationContext();
1313
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
14-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
14+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1515
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
16+
sleep(2000);
1617
console.log("###TEST API PLUGIN PASSED###");
1718
console.log("### TEST END ###");
1819
}
19-
exports.onNavigatingTo = onNavigatingTo;
20+
exports.onNavigatingTo = onNavigatingTo;
21+
22+
function sleep(milliseconds) {
23+
var start = new Date().getTime();
24+
for (var i = 0; i < 1e7; i++) {
25+
if ((new Date().getTime() - start) > milliseconds){
26+
break;
27+
}
28+
}
29+
}

data/issues/android-runtime-993/plugins/compile/main-page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ function onNavigatingTo(args) {
1111
com.tns.mylib.useDependency();
1212
var context = utils.ad.getApplicationContext();
1313
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
14-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
14+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1515
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
16+
sleep(2000);
1617
console.log("###TEST COMPILE PLUGIN PASSED###");
1718
console.log("### TEST END ###");
1819
}
19-
exports.onNavigatingTo = onNavigatingTo;
20+
exports.onNavigatingTo = onNavigatingTo;
21+
22+
function sleep(milliseconds) {
23+
var start = new Date().getTime();
24+
for (var i = 0; i < 1e7; i++) {
25+
if ((new Date().getTime() - start) > milliseconds){
26+
break;
27+
}
28+
}
29+
}

data/issues/android-runtime-993/plugins/implementation/main-page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ function onNavigatingTo(args) {
1111
com.tns.mylib.useDependency();
1212
var context = utils.ad.getApplicationContext();
1313
var myIntent = new android.content.Intent(context, AlbumSelectActivity.class);
14-
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 5); // set limit for image selection
14+
myIntent.putExtra(ConstantsCustomGallery.INTENT_EXTRA_LIMIT, 20); // set limit for image selection
1515
application.android.foregroundActivity.startActivityForResult(myIntent, ConstantsCustomGallery.REQUEST_CODE);
16+
sleep(2000);
1617
console.log("###TEST IMPLEMENTATION PLUGIN PASSED###");
1718
console.log("### TEST END ###");
1819
}
19-
exports.onNavigatingTo = onNavigatingTo;
20+
exports.onNavigatingTo = onNavigatingTo;
21+
22+
function sleep(milliseconds) {
23+
var start = new Date().getTime();
24+
for (var i = 0; i < 1e7; i++) {
25+
if ((new Date().getTime() - start) > milliseconds){
26+
break;
27+
}
28+
}
29+
}

data/issues/android-runtime-993/plugins/with_dependency/main-page.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ function onNavigatingTo(args) {
66
page.bindingContext = createViewModel();
77
console.log("### TEST START ###");
88
com.tns.mylib.useDependency(utils.ad.getApplicationContext());
9+
sleep(2000);
910
console.log("###TEST ARR PLUGIN PASSED###");
1011
console.log("### TEST END ###");
1112
}
12-
exports.onNavigatingTo = onNavigatingTo;
13+
exports.onNavigatingTo = onNavigatingTo;
14+
15+
function sleep(milliseconds) {
16+
var start = new Date().getTime();
17+
for (var i = 0; i < 1e7; i++) {
18+
if ((new Date().getTime() - start) > milliseconds){
19+
break;
20+
}
21+
}
22+
}

out/.gitignore

-4
This file was deleted.

0 commit comments

Comments
 (0)