mirror of
https://github.com/VibedByKaKi/orgzly-android-revived.git
synced 2026-10-11 21:01:20 +02:00
Create a generic test suite for SyncRepo implementations in the "shared-test" library. This allows writing "abstract" test cases which all implementations must pass. The main challenge in creating these "abstract" tests for SyncRepo was that most implementations can be tested with local unit tests, whereas DocumentRepo requires instrumented tests, since the Android class DocumentFile is so central to it. I tried several different approaches, but ended up with this separate "shared-test" library, containing an abstract class SyncRepoTest, which helps you by defining all the test cases and contains all their inner logic. I have also tried keeping all the tests as instrumented tests, but I wanted to launch a lightweight WebDAV server for those tests, and it was not possible to get that to work in Android. The WebDAV server was also the reason why I switched from Java 11 to Java 17 in the build process. But that was due, anyway, as Java 11 is now old and unsupported.
37 lines
1,009 B
Groovy
37 lines
1,009 B
Groovy
/**
|
|
* Load Orgzly-specific properties from app.properties.
|
|
* File is not included, see sample.app.properties file.
|
|
*/
|
|
def loadAppProperties() {
|
|
Properties properties = new Properties()
|
|
|
|
def file = new File(settingsDir, 'app.properties')
|
|
|
|
if (file.exists()) {
|
|
properties.load(file.newDataInputStream())
|
|
} else {
|
|
logger.warn("Properties file ${file} does not exist")
|
|
}
|
|
|
|
return properties
|
|
}
|
|
|
|
gradle.ext.appProperties = loadAppProperties()
|
|
|
|
// Setup org-java project if "org_java" is set to an existing directory.
|
|
if (gradle.ext.appProperties.org_java_directory?.trim()) {
|
|
def path = gradle.ext.appProperties.org_java_directory
|
|
|
|
def dir = path.startsWith('/') ? new File(path) : new File(settingsDir, path)
|
|
|
|
if (dir.exists()) {
|
|
include ':org-java'
|
|
project(':org-java').projectDir = dir
|
|
gradle.ext.orgJavaDir = dir
|
|
} else {
|
|
logger.warn("Ignoring non-existent directory $dir")
|
|
}
|
|
}
|
|
|
|
include ':app'
|
|
include ':shared-test'
|