Compare commits

..

12 Commits

Author SHA1 Message Date
Ken Naito
1c9e7fc96a fix: backbutton test code (#1307) 2021-08-02 20:25:04 +09:00
Erisu
5e52b7ee77 fix: logging method 2021-08-02 15:15:27 +09:00
Erisu
f3e98c8651 refactor: rename java_unit_tests command & test runner file 2021-08-02 14:30:25 +09:00
Erisu
bbc9bcae14 refactor: java test runner 2021-08-02 14:30:25 +09:00
Erisu
cd49902ca3 fix: add androidx.test:rules library 2021-08-02 14:30:25 +09:00
Erisu
f4a0e1ec78 ci: add Java instrumentation tests 2021-08-02 14:30:25 +09:00
Mosab A
b6c5db3e37 feat: bump Google Services Gradle Plugin@4.3.8 (#1303) 2021-08-02 14:21:11 +09:00
Mosab A
cba3410b17 feat: bump kotlin@1.5.21 (#1302) 2021-08-02 14:21:02 +09:00
エリス
565ac9c7b1 fix: fall back to project root repositories.gradle (#1300) 2021-08-02 14:19:40 +09:00
エリス
1636d70f25 feat: support http w/ content src fix (#1298) 2021-07-30 17:08:23 +09:00
エリス
4e5892c5ed chore: bump version 10.1.0-dev (#1301) 2021-07-30 17:08:04 +09:00
Erisu
e69ab6a687 chore: bump version 10.0.2-dev 2021-07-27 23:23:36 +09:00
12 changed files with 88 additions and 33 deletions

View File

@@ -29,7 +29,13 @@ buildscript {
}
allprojects {
apply from: 'repositories.gradle'
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}

View File

@@ -4,10 +4,10 @@
"GRADLE_VERSION": "7.1.1",
"MIN_BUILD_TOOLS_VERSION": "30.0.3",
"AGP_VERSION": "4.2.2",
"KOTLIN_VERSION": "1.5.20",
"KOTLIN_VERSION": "1.5.21",
"ANDROIDX_APP_COMPAT_VERSION": "1.3.0",
"ANDROIDX_WEBKIT_VERSION": "1.4.0",
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.5",
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.8",
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false
}

View File

@@ -24,16 +24,19 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.content.Context;
public class ConfigXmlParser {
private static String TAG = "ConfigXmlParser";
private String launchUrl = null;
private static String SCHEME_HTTP = "http";
private static String SCHEME_HTTPS = "https";
private static String DEFAULT_HOSTNAME = "localhost";
private String launchUrl;
private String contentSrc;
private CordovaPreferences prefs = new CordovaPreferences();
private ArrayList<PluginEntry> pluginEntries = new ArrayList<PluginEntry>(20);
@@ -47,11 +50,7 @@ public class ConfigXmlParser {
public String getLaunchUrl() {
if (launchUrl == null) {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
}
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/index.html";
setStartUrl(contentSrc);
}
return launchUrl;
@@ -130,7 +129,10 @@ public class ConfigXmlParser {
else if (strNode.equals("content")) {
String src = xml.getAttributeValue(null, "src");
if (src != null) {
setStartUrl(src);
contentSrc = src;
} else {
// Default
contentSrc = "index.html";
}
}
}
@@ -147,20 +149,40 @@ public class ConfigXmlParser {
}
}
private String getLaunchUrlPrefix() {
if (prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
return "file:///android_asset/www/";
} else {
String scheme = prefs.getString("scheme", SCHEME_HTTPS).toLowerCase();
String hostname = prefs.getString("hostname", DEFAULT_HOSTNAME);
if (!scheme.contentEquals(SCHEME_HTTP) && !scheme.contentEquals(SCHEME_HTTPS)) {
LOG.d(TAG, "The provided scheme \"" + scheme + "\" is not valid. " +
"Defaulting to \"" + SCHEME_HTTPS + "\". " +
"(Valid Options=" + SCHEME_HTTP + "," + SCHEME_HTTPS + ")");
scheme = SCHEME_HTTPS;
}
return scheme + "://" + hostname + '/';
}
}
private void setStartUrl(String src) {
Pattern schemeRegex = Pattern.compile("^[a-z-]+://");
Matcher matcher = schemeRegex.matcher(src);
if (matcher.find()) {
launchUrl = src;
} else {
String launchUrlPrefix = getLaunchUrlPrefix();
// remove leading slash, "/", from content src if existing,
if (src.charAt(0) == '/') {
src = src.substring(1);
}
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/" + src;
} else {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
}
launchUrl = launchUrlPrefix + src;
}
}
}

View File

@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
* are not expected to implement it.
*/
public interface CordovaWebView {
public static final String CORDOVA_VERSION = "10.0.1";
public static final String CORDOVA_VERSION = "10.1.0-dev";
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "cordova-android",
"version": "10.0.1",
"version": "10.1.0-dev",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-android",
"version": "10.0.1",
"version": "10.1.0-dev",
"description": "cordova-android release",
"main": "lib/Api.js",
"repository": "github:apache/cordova-android",
@@ -12,13 +12,13 @@
],
"scripts": {
"prepare": "cordova-js build > templates/project/assets/www/cordova.js",
"test": "npm run lint && npm run cover && npm run java-unit-tests",
"test": "npm run lint && npm run cover && npm run java-tests",
"lint": "eslint lib spec test \"templates/cordova/**/!(*.*)\"",
"unit-tests": "jasmine --config=spec/unit/jasmine.json",
"cover": "nyc jasmine --config=spec/coverage.json",
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
"java-unit-tests": "node test/run_java_unit_tests.js",
"clean:java-unit-tests": "node test/clean.js"
"java-tests": "node test/java_test_runner.js",
"clean:java-tests": "node test/clean.js"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",

View File

@@ -60,7 +60,13 @@ buildscript {
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
apply from: 'repositories.gradle'
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}

View File

@@ -30,7 +30,13 @@ buildscript {
}
allprojects {
apply from: 'repositories.gradle'
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}

View File

@@ -56,6 +56,8 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-web:3.1.1', {
exclude group: 'androidx.test.espresso', module: 'androidx.annotation'
})
androidTestImplementation 'androidx.test:rules:1.4.0'
}
repositories {
google()

View File

@@ -158,7 +158,7 @@ public class BackButtonMultipageTest {
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
}
private void assertPageSample(String url) {
private void assertPageSample(String url) throws Throwable {
assertEquals(url, mActivity.onPageFinishedUrl.take());
}
}

View File

@@ -21,7 +21,7 @@ const fs = require('fs-extra');
const path = require('path');
/**
* This script is to be run manually (e.g. by npm run clean:java-unit-tests) if
* This script is to be run manually (e.g. by npm run clean:java-tests) if
* you want to upgrade gradlew or test its proper generation.
*/

View File

@@ -46,9 +46,13 @@ class AndroidTestRunner {
return new ProjectBuilder(this.projectDir).runGradleWrapper('gradle');
}
_log (...args) {
console.log(...[`[${this.testTitle}]`, ...args]);
}
run () {
return Promise.resolve()
.then(_ => console.log(`[${this.testTitle}] Preparing Gradle wrapper for Java unit tests.`))
.then(_ => this._log('Staging Project Files'))
.then(_ => {
// TODO we should probably not only copy these files, but instead create a new project from scratch
fs.copyFileSync(path.resolve(this.projectDir, '../../framework/cdv-gradle-config-defaults.json'), path.resolve(this.projectDir, 'cdv-gradle-config.json'));
@@ -57,26 +61,35 @@ class AndroidTestRunner {
path.join(this.projectDir, 'app/src/main/assets/www/cordova.js')
);
})
.then(_ => this._log('Creating Gradle Wrapper'))
.then(_ => this._createProjectBuilder())
.then(_ => this._log('Getting Gradle Wrapper Version Info'))
.then(_ => this._gradlew('--version'))
.then(_ => console.log(`[${this.testTitle}] Gradle wrapper is ready. Running tests now.`))
.then(_ => this._log('Running Java Unit Tests'))
.then(_ => this._gradlew('test'))
.then(_ => console.log(`[${this.testTitle}] Java unit tests completed successfully`));
.then(_ => this._log('Finished Java Unit Test'))
.then(_ => this._log('Running Java Instrumentation Tests'))
.then(_ => this._gradlew('connectedAndroidTest'))
.then(_ => this._log('Finished Java Instrumentation Tests'));
}
}
Promise.resolve()
.then(_ => console.log('Starting to run all android platform tests'))
.then(_ => console.log('Starting Android Platform Java Tests'))
// AndroidX Test
.then(_ => new AndroidTestRunner('AndroidX Project', path.resolve(__dirname, 'androidx')))
.then(test => test.run())
.then(_ => console.log('Finished running all android platform tests'));
.then(_ => console.log('Finished Running Android Platform Java Tests'));
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!');
console.error('JAVA TESTS FAILED!');
process.exitCode = err.code || 1;
});