update gitignore for generated tests add camera move test add realtime geojson to be excluded when generating Activity sanity tests by default show workaround for showing a MapView in a dialog add annotation tests remove older camera tests, introduce tests for move, ease and animate, bring back setLatLng and getLatLng on MapView, add tests for internal camera API. compass view tests add tests for attribution and logo. fix annotation tests Rename Actiivity test class, split up annotation tests, added MarkerView tests, added infowindow tests, added MyLocationView tests fix addRemoveLayer test by integrating map interactions inside a ViewAction
63 lines
2.5 KiB
JavaScript
63 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const ejs = require('ejs');
|
|
|
|
global.iff = function (condition, val) {
|
|
return condition() ? val : "";
|
|
}
|
|
|
|
global.camelize = function (str) {
|
|
return str.replace(/(?:^|-)(.)/g, function (_, x) {
|
|
return x.toUpperCase();
|
|
});
|
|
}
|
|
|
|
|
|
const excludeActivities = ["RealTimeGeoJsonActivity","UpdateMetadataActivity","CarDrivingActivity","MyLocationTrackingModeActivity","MyLocationToggleActivity","MyLocationTintActivity","MyLocationDrawableActivity","DoubleMapActivity", "LocationPickerActivity","GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity", "QueryRenderedFeaturesBoxHighlightActivity", "MultiMapActivity", "MapInDialogActivity"];
|
|
const appBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity';
|
|
const testBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen';
|
|
const subPackages = fs.readdirSync(appBasePath);
|
|
const ejsConversionTask = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/activity.junit.ejs', 'utf8'), {strict: true});
|
|
|
|
if (!fs.existsSync(testBasePath)){
|
|
fs.mkdirSync(testBasePath);
|
|
}
|
|
|
|
console.log("Generating test activities:");
|
|
for(const subPackage of subPackages) {
|
|
if(!(subPackage.slice(-5) == '.java')) {
|
|
const activities = fs.readdirSync(appBasePath+'/'+subPackage);
|
|
|
|
// create directories for package
|
|
if (!fs.existsSync(testBasePath+"/"+subPackage)){
|
|
fs.mkdirSync(testBasePath+"/"+subPackage);
|
|
}
|
|
|
|
for (const activity of activities) {
|
|
// strip .java from input file
|
|
const activityName = activity.slice(0, -5);
|
|
|
|
// create path for test file
|
|
const filePath = testBasePath+"/"+subPackage+"/"+activityName+'Test.java';
|
|
|
|
// try removing previous generated files
|
|
try {
|
|
fs.accessSync(filePath, fs.F_OK);
|
|
fs.unlinkSync(filePath);
|
|
console.log("Removed file: "+filePath);
|
|
} catch (e) {
|
|
console.log("No file found: "+filePath);
|
|
}
|
|
|
|
// only generate test file if not part of exclude list
|
|
if (!(excludeActivities.indexOf(activityName) > -1)) {
|
|
console.log("Created file: "+filePath);
|
|
fs.writeFileSync(filePath, ejsConversionTask([activityName, subPackage]));
|
|
}else{
|
|
console.log("Excluding file: "+filePath);
|
|
}
|
|
}
|
|
}
|
|
}
|