Skip to content

Commit

Permalink
Merge pull request orgzly-revived#312 from amberin/subfolders
Browse files Browse the repository at this point in the history
Support subfolders for Sync locations
  • Loading branch information
amberin authored Sep 4, 2024
2 parents 7c11407 + 4b0560e commit 7de715e
Show file tree
Hide file tree
Showing 63 changed files with 2,287 additions and 969 deletions.
46 changes: 43 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,41 @@ on:
workflow_dispatch:

jobs:
test:

localUnitTests:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Gradle build Fdroid
run: ./gradlew assembleFdroidDebug

- name: Gradle test Fdroid
run: ./gradlew testFdroidDebugUnitTest

- name: Add Dropbox API credentials (for DropboxRepo tests)
shell: bash
run: |
echo "dropbox.refresh_token = \"${{ secrets.DROPBOX_REFRESH_TOKEN }}\"" >> app.properties
echo "dropbox.app_key = \"${{ secrets.DROPBOX_APP_KEY }}\"" >> app.properties
- name: Gradle test Premium
run: ./gradlew testPremiumDebugUnitTest

instrumentedTests:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -39,6 +73,12 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

Expand Down Expand Up @@ -80,7 +120,7 @@ jobs:
echo "dropbox.refresh_token = \"${{ secrets.DROPBOX_REFRESH_TOKEN }}\"" >> app.properties
echo "dropbox.app_key = \"${{ secrets.DROPBOX_APP_KEY }}\"" >> app.properties
- name: Run tests
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
Expand All @@ -91,4 +131,4 @@ jobs:
disable-spellchecker: true
profile: Nexus 6
# Tests should use the build which includes Dropbox code.
script: ./gradlew connected${{matrix.flavor}}DebugAndroidTest --no-watch-fs --build-cache --info
script: ./gradlew --no-configuration-cache connected${{matrix.flavor}}DebugAndroidTest --no-watch-fs --build-cache --info
38 changes: 19 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ android {
viewBinding true
}

// testOptions {
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
// }
testOptions {
unitTests {
includeAndroidResources = true
}
}

buildTypes {
release {
Expand Down Expand Up @@ -91,12 +93,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = 11
jvmTarget = 17
}

packagingOptions {
Expand All @@ -114,7 +116,7 @@ android {
dependencies {
implementation orgJavaLocation()

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlin_coroutines")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlin_coroutines"

implementation "org.jetbrains:annotations:$versions.jetbrains_annotations"

Expand All @@ -136,7 +138,6 @@ dependencies {

// Room
implementation "androidx.room:room-runtime:$versions.android_room"
testImplementation "androidx.room:room-testing:$versions.android_room"
kapt "androidx.room:room-compiler:$versions.android_room"
implementation("androidx.room:room-ktx:$versions.android_room")

Expand All @@ -145,32 +146,31 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$versions.android_lifecycle")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$versions.android_lifecycle")

androidTestImplementation "androidx.annotation:annotation:$versions.android_annotation"

implementation "androidx.work:work-runtime-ktx:$versions.android_workmanager"

testImplementation "junit:junit:$versions.junit"
// Local JVM tests ("unit tests")
testImplementation(project(":shared-test"))
testImplementation "androidx.test.ext:junit:$versions.android_test_ext_junit"
testImplementation "org.robolectric:robolectric:$versions.robolectric"
testImplementation "io.github.atetzner:webdav-embedded-server:$versions.webdav_embedded_server"

// AndroidX Test
// Android instrumented tests
androidTestImplementation(project(":shared-test"))
androidTestImplementation "androidx.test.espresso:espresso-core:$versions.android_test_espresso"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$versions.android_test_espresso"
androidTestImplementation "androidx.test.espresso:espresso-intents:$versions.android_test_espresso"
androidTestImplementation "androidx.test:runner:$versions.android_test"
androidTestImplementation "androidx.test:rules:$versions.android_test"
androidTestImplementation "androidx.test.ext:junit:$versions.android_test_ext_junit"
androidTestImplementation "androidx.test.uiautomator:uiautomator:$versions.android_test_uiautomator"
androidTestImplementation "de.sven-jacobs:loremipsum:$versions.loremipsum"
androidTestImplementation "androidx.annotation:annotation:$versions.android_annotation"

/* For running tests on lower API versions (e.g. 18) to avoid:
* Didn't find class "androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
*/
implementation "androidx.test:core:$versions.android_test"

// For ANDROIDX_TEST_ORCHESTRATOR
// androidTestUtil "androidx.test:orchestrator:$android_test_version"

androidTestImplementation "androidx.test.uiautomator:uiautomator:$versions.android_test_uiautomator"

androidTestImplementation "de.sven-jacobs:loremipsum:$versions.loremipsum"

// Dagger
implementation "com.google.dagger:dagger:$versions.dagger"
kapt "com.google.dagger:dagger-compiler:$versions.dagger"
Expand Down
2 changes: 0 additions & 2 deletions app/src/androidTest/java/com/orgzly/android/OrgzlyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import android.Manifest;
import android.app.Activity;
import android.app.UiAutomation;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
Expand All @@ -20,7 +19,6 @@
import com.orgzly.android.repos.RepoFactory;
import com.orgzly.android.util.UserTimeFormatter;
import com.orgzly.org.datetime.OrgDateTime;
import com.orgzly.test.BuildConfig;

import org.junit.After;
import org.junit.Before;
Expand Down
9 changes: 9 additions & 0 deletions app/src/androidTest/java/com/orgzly/android/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,21 @@ public SyncRepo repoInstance(RepoType type, String url) {
return dataRepository.getRepoInstance(13, type, url);
}

public SyncRepo repoInstance(RepoType type, String url, Long id) {
return dataRepository.getRepoInstance(id, type, url);
}

public Repo setupRepo(RepoType type, String url) {
long id = dataRepository.createRepo(new RepoWithProps(new Repo(0, type, url)));

return dataRepository.getRepo(id);
}

public Repo setupRepo(RepoType type, String url, Map<String, String> props) {
long id = dataRepository.createRepo(new RepoWithProps(new Repo(0, type, url), props));
return dataRepository.getRepo(id);
}

public void deleteRepo(String url) {
Repo repo = dataRepository.getRepo(url);
if (repo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class BookPrefaceTest : OrgzlyTest() {
private fun setPrefaceSetting(@StringRes id: Int) {
onActionItemClick(R.id.activity_action_settings, R.string.settings)

clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks)
clickSetting("pref_key_preface_in_book", R.string.preface_in_book)
clickSetting(R.string.pref_title_notebooks)
clickSetting(R.string.preface_in_book)

onView(withText(id)).perform(click())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class BooksSortOrderTest : OrgzlyTest() {

private fun setBooksSortOrder(@StringRes id: Int) {
onActionItemClick(R.id.activity_action_settings, R.string.settings)
clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks)
clickSetting("pref_key_notebooks_sort_order", R.string.sort_order)
clickSetting(R.string.pref_title_notebooks)
clickSetting(R.string.sort_order)
onData(hasToString(context.getString(id))).perform(click())
pressBack()
pressBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ public void testNewNote() {

private void enableCreatedAt() {
onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_sync", R.string.sync);
clickSetting("pref_key_is_created_at_added", R.string.use_created_at_property);
clickSetting(R.string.sync);
clickSetting(R.string.use_created_at_property);
onView(withText(R.string.yes)).perform(click());
pressBack();
pressBack();
}

private void changeCreatedAtProperty(String propName) {
onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_sync", R.string.sync);
clickSetting("pref_key_created_at_property", R.string.created_at_property);
clickSetting(R.string.sync);
clickSetting(R.string.created_at_property);
onView(instanceOf(EditText.class)).perform(replaceTextCloseKeyboard(propName));
onView(withText(android.R.string.ok)).perform(click());
onView(withText(R.string.yes)).perform(click());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public void testClearDatabaseWithFragmentsInBackStack() {
onView(allOf(withText("book-two"), isDisplayed())).perform(click());
onView(withText("Note #2.")).perform(click());
onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_app", R.string.app);
clickSetting("pref_key_clear_database", R.string.clear_database);
clickSetting(R.string.app);
clickSetting(R.string.clear_database);
onView(withText(R.string.ok)).perform(click());
pressBack();
pressBack();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package com.orgzly.android.espresso

import android.os.SystemClock
import android.icu.util.Calendar
import android.os.SystemClock
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import com.orgzly.R
import com.orgzly.android.OrgzlyTest
import com.orgzly.android.espresso.util.EspressoUtils.*
import com.orgzly.android.espresso.util.EspressoUtils.onBook
import com.orgzly.android.espresso.util.EspressoUtils.onItemInAgenda
import com.orgzly.android.espresso.util.EspressoUtils.onNoteInBook
import com.orgzly.android.espresso.util.EspressoUtils.onNoteInSearch
import com.orgzly.android.espresso.util.EspressoUtils.onNotesInAgenda
import com.orgzly.android.espresso.util.EspressoUtils.onNotesInSearch
import com.orgzly.android.espresso.util.EspressoUtils.recyclerViewItemCount
import com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard
import com.orgzly.android.ui.main.MainActivity
import com.orgzly.org.datetime.OrgDateTime
import org.hamcrest.Matchers.not
Expand Down Expand Up @@ -117,6 +126,7 @@ class NoteEventsTest : OrgzlyTest() {
scenario = ActivityScenario.launch(MainActivity::class.java)

searchForTextCloseKeyboard("ad.1")
SystemClock.sleep(500)
onNotesInAgenda().check(matches(recyclerViewItemCount(2)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ class NoteFragmentTest : OrgzlyTest() {

/* Change lowest priority to A. */
onActionItemClick(R.id.activity_action_settings, R.string.settings)
clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks)
clickSetting("pref_key_min_priority", R.string.lowest_priority)
clickSetting(R.string.pref_title_notebooks)
clickSetting(R.string.lowest_priority)
onData(hasToString(containsString("A"))).perform(click())
pressBack()
pressBack()
Expand All @@ -431,8 +431,8 @@ class NoteFragmentTest : OrgzlyTest() {

/* Change lowest priority to C. */
onActionItemClick(R.id.activity_action_settings, R.string.settings)
clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks)
clickSetting("pref_key_min_priority", R.string.lowest_priority)
clickSetting(R.string.pref_title_notebooks)
clickSetting(R.string.lowest_priority)
onData(hasToString(containsString("C"))).perform(click())
pressBack()
pressBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public void testInheritedAndOwnTag() {
scenario = ActivityScenario.launch(MainActivity.class);

onView(allOf(withText("notebook-1"), isDisplayed())).perform(click());
SystemClock.sleep(200);
searchForTextCloseKeyboard("t.tag1 t.tag2");
onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed()));
onNotesInSearch().check(matches(recyclerViewItemCount(3)));
Expand Down Expand Up @@ -725,6 +726,7 @@ public void testSearchWithState() {
scenario = ActivityScenario.launch(MainActivity.class);

onView(allOf(withText("notebook"), isDisplayed())).perform(click());
SystemClock.sleep(200);
searchForTextCloseKeyboard(".it.none");
onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed()));
onNotesInSearch().check(matches(recyclerViewItemCount(3)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void testDisplayedContentInBook() {
.check(matches(allOf(withText(containsString("Content for [a-1]")), isDisplayed())));

onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks);
clickSetting("pref_key_is_notes_content_displayed_in_list", R.string.display_content);
clickSetting(R.string.pref_title_notebooks);
clickSetting(R.string.display_content);
pressBack();
pressBack();

Expand All @@ -96,8 +96,8 @@ public void testDisplayedContentInBook() {

private void setDefaultPriority(String priority) {
onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_notebooks", R.string.pref_title_notebooks);
clickSetting("pref_key_default_priority", R.string.default_priority);
clickSetting(R.string.pref_title_notebooks);
clickSetting(R.string.default_priority);
onData(hasToString(containsString(priority))).perform(click());
pressBack();
pressBack();
Expand Down
Loading

0 comments on commit 7de715e

Please sign in to comment.