Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15a7cbf4 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

1811 fix test error

parent ffe440b7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -92,6 +92,21 @@ adb logcat --pid=$(adb shell pidof -s foundation.e.drive)

You can also use the script `dev-tools.sh` to run those command. Use : `./dev-tools.sh -h` to display options


**Disable File Observer**


```bash
adb shell am broadcast -a foundation.e.drive.action.ENABLE_FILE_OBSERVER --receiver-include-background --ez file_observer_enable false
```

**Enable File Observer**


```bash
adb shell am broadcast -a foundation.e.drive.action.ENABLE_FILE_OBSERVER --receiver-include-background --ez file_observer_enable true
```

### local NC for testing

Use following documentation to set up a local NC instance
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@
                <action android:name="foundation.e.drive.action.FORCE_SCAN" />
                <action android:name="foundation.e.drive.action.DUMP_DATABASE"/>
                <action android:name="foundation.e.drive.action.FULL_LOG_ON_PROD"/>
                <action android:name="foundation.e.drive.action.ENABLE_FILE_OBSERVER"/>
                <action android:name="foundation.e.drive.action.TEST_SYNC"/>
            </intent-filter>
        </receiver>
+19 −0
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ import java.util.ArrayList;
import java.util.List;

import foundation.e.drive.EdriveApplication;
import foundation.e.drive.account.AccountUtils;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.fileObservers.FileObserverManager;
import foundation.e.drive.models.SyncRequest;
import foundation.e.drive.models.SyncedFileState;
import foundation.e.drive.models.SyncedFolder;
@@ -41,7 +43,10 @@ public class DebugCmdReceiver extends BroadcastReceiver {
    public static final String ACTION_FORCE_SCAN = "foundation.e.drive.action.FORCE_SCAN";
    public static final String ACTION_DUMP_DATABASE = "foundation.e.drive.action.DUMP_DATABASE";
    public static final String ACTION_FULL_LOG_ON_PROD = "foundation.e.drive.action.FULL_LOG_ON_PROD";
    public static final String ACTION_ENABLE_FILE_OBSERVER = "foundation.e.drive.action.ENABLE_FILE_OBSERVER";

    private static final String FULL_LOG_ENABLE_KEY = "full_log_enable";
    private static final String FILE_OBSERVER_ENABLE_KEY = "file_observer_enable";

    @Override
    public void onReceive(@NonNull Context context, @NonNull Intent intent) {
@@ -62,6 +67,20 @@ public class DebugCmdReceiver extends BroadcastReceiver {
                ReleaseTree.allowDebugLogOnProd(allow_full_log);
                Timber.d("Allow full log on prod: %s", allow_full_log);
                break;
            case ACTION_ENABLE_FILE_OBSERVER:
                if (AccountUtils.getAccount(context) == null) {
                    Timber.d("Ignore intent: no account");
                }

                final EdriveApplication application = (EdriveApplication) context.getApplicationContext();
                final boolean enabled = intent.getBooleanExtra(FILE_OBSERVER_ENABLE_KEY, true);
                Timber.i("Intent received: enable FileObserver: %s", enabled);
                if (enabled) {
                    application.startRecursiveFileObserver();
                } else {
                    application.stopRecursiveFileObserver();
                }
                break;
            case ACTION_TEST_SYNC:
                Timber.d("Test SyncWorker.kt started");
                final SyncRequestCollector collector = (SyncRequestCollector) SyncProxy.INSTANCE;
+21 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ function printHelp() {
    -h : print this help
    -L : (required value: true|false) : true: enable/ false: disable full log
    -l : (option: --clear) : --clear: clear logcat before. Otherwise just display logcat. Default: false
    -n : Start nextcloud docker instance
    -o : (required value: true|false) true: enable File Observer / false: disable File Observer
    -p : Pull database directory from device into current computer folder
    -s : test sync : Create 10 empty files in 'Document' folder and try to upload them
    ";
@@ -79,7 +81,23 @@ function testSync() {
    adb shell am broadcast -a foundation.e.drive.action.TEST_SYNC --receiver-include-background
}

while getopts acCdfhL:lps flag
function startNCDocker() {
    docker run -d -p 8080:80 -e NEXTCLOUD_TRUSTED_DOMAINS="<your computer IP>:8080" -e SQLITE_DATABASE=nc -e NEXTCLOUD_ADMIN_USER=admin -e NEXTCLOUD_ADMIN_PASSWORD=admin nextcloud:26
}

function enableFileObserver() {
    if [ -z "$1" ]; then
        echo "The parameter -L require a value (true|false)"
    elif [ "$1" != "true" ] && [ "$1" != "false" ]; then
        echo "Invalid parameter: $1. You need to provide: (true|false)"
    else
        echo "Sending broacast with $1 as parameter"
        adb shell am broadcast -a foundation.e.drive.action.ENABLE_FILE_OBSERVER --receiver-include-background --ez file_observer_enable "$1"
    fi
}


while getopts acCdfhL:lnops flag
do
    case "${flag}" in
        a) registerAccount;;
@@ -90,6 +108,8 @@ do
        h) printHelp;;
        l) displayLogcat;;
        L) setFullLog ${OPTARG};;
        n) startNCDocker;;
        o) enableFileObserver ${OPTARG};;
        p) pullDatabase;;
        s) testSync;;
    esac