Update to new android cordova build

Signed-off-by: Chris Cromer <chris@cromer.cl>
This commit is contained in:
2019-04-09 20:33:36 -04:00
parent 408bf02b89
commit 179caec389
414 changed files with 2292 additions and 69850 deletions

View File

@@ -22,7 +22,7 @@
# Cordova Android Test Project
The project in this directory is an Android Test project that enables those
interested in further developing cordova-android to validate their changes.
interested in further developing `cordova-android` to validate their changes.
## Requirements
@@ -33,7 +33,7 @@ writing) at least version 3.3 or newer.
## Getting Started
You can run this test project from both the command line as well as from
Android Studio.
Android Studio:
### Command Line
@@ -50,8 +50,10 @@ end-to-end, or instrumented, tests. Unit tests do not require any particular
environment to run in, but the instrumented tests, however, require a connected
Android device or emulator to run in.
To run the unit tests, run: `gradlew test`.
To run the instrumented tests, run: `gradlew connectedAndroidTest`.
- To run the unit tests, run: `gradlew test`.
- To run the instrumented tests, run: `gradlew connectedAndroidTest`.
To make sure all tests are run, add the `--rerun-tasks` parameter.
### Android Studio

View File

@@ -19,16 +19,18 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "org.apache.cordova.unittests"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false

View File

@@ -22,8 +22,6 @@
var PLATFORM_VERSION_BUILD_LABEL = '6.2.0-dev';
// file: src/scripts/require.js
/*jshint -W079 */
/*jshint -W020 */
var require,
define;

View File

@@ -22,26 +22,28 @@
var Q = require('q');
var path = require('path');
var superspawn = require('cordova-common').superspawn;
var ProjectBuilder = require('../bin/templates/cordova/lib/builders/ProjectBuilder');
// First we make sure the gradlew helper file is built and ready.
var GradleBuilder = require('../bin/templates/cordova/lib/builders/GradleBuilder');
var builder = new GradleBuilder(__dirname);
var needs_gradlew_built = builder.runGradleWrapper('gradle', 'build.gradle');
Q.resolve()
.then(_ => console.log('Preparing Gradle wrapper for Java unit tests.'))
.then(_ => new ProjectBuilder(__dirname).runGradleWrapper('gradle'))
.then(_ => gradlew('--version'))
if (!needs_gradlew_built) {
// Due to interface of gradle builder, if the gradlew file already exists, `runGradleWrapper` returns undefined.
// In this case, we will fill the gap and create a resolved promise here now, this way the next bit of code
// will jump straight to running the tests
// TODO: maybe this should be done in GradleBuilder `runGradleWrapper` method instead?
needs_gradlew_built = Q.fcall(function () { return true; });
}
.then(_ => console.log('Gradle wrapper is ready. Running tests now.'))
.then(_ => gradlew('test'))
.then(_ => console.log('Java unit tests completed successfully.'));
needs_gradlew_built.then(function () {
return superspawn.spawn(path.join(__dirname, 'gradlew'), ['test'], {stdio: 'inherit'});
}, function (err) {
console.error('There was an error building the gradlew file:', err);
}).then(function () {
console.log('Tests completed successfully.');
}).fail(function (err) {
console.error('Tests failed!', err);
process.on('unhandledRejection', err => {
// If err has a stderr property, we have seen the message already
if (!('stderr' in err)) console.error(err.message);
console.error('JAVA UNIT TESTS FAILED!');
process.exitCode = err.code || 1;
});
function gradlew () {
const wrapperPath = path.join(__dirname, 'gradlew');
return superspawn.spawn(wrapperPath, Array.from(arguments), {
stdio: 'inherit',
cwd: __dirname
});
}