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

Commit 07ea100a authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch 'epic7-o-officialNcLib' into 'v1-oreo'

Move to official Nextcloud Library

See merge request !144
parents e68f70e0 59a45d84
Loading
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -5,8 +5,6 @@ stages:
  - build

before_script:
- git submodule sync
- git submodule update --init --recursive
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew

.gitmodules

deleted100644 → 0
+0 −3
Original line number Diff line number Diff line
[submodule "nextcloud-android-lib"]
	path = nextcloud-android-lib
	url = ../nextcloud-android-lib.git
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -2,6 +2,5 @@
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="" vcs="Git" />
    <mapping directory="$PROJECT_DIR$/nextcloud-android-lib" vcs="Git" />
  </component>
</project>
 No newline at end of file
+29 −27
Original line number Diff line number Diff line
plugins {
    id 'com.android.application'
}


import java.text.SimpleDateFormat;
apply plugin: 'com.android.application'
def versionMajor = 1
def versionMinor = 0
def versionPatch = 1
def versionMinor = 1
def versionPatch = 0



def getTestProp(String propName) {
@@ -20,13 +23,15 @@ def getTestProp(String propName) {


android {
    compileSdkVersion 31
    compileSdk 31
    defaultConfig {
        applicationId "foundation.e.drive"
        minSdkVersion 26
        minSdk 26
        targetSdk 31
        versionCode versionMajor * 1000000 + versionMinor * 1000 + versionPatch
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        setProperty("archivesBaseName", "eDrive-$versionName")
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
@@ -35,10 +40,6 @@ android {
        }
    }

    lintOptions {
      abortOnError false
    }


    testOptions {
        unitTests {
@@ -55,37 +56,38 @@ android {
        viewBinding true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

}


dependencies {
    api project(':NextcloudLib')
    implementation 'com.github.nextcloud:android-library:2.10.1'
    implementation "commons-httpclient:commons-httpclient:3.1@jar"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    api 'androidx.annotation:annotation:1.3.0'
    implementation 'androidx.core:core:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation "androidx.constraintlayout:constraintlayout:2.1.3"
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'com.github.bumptech.glide:glide:4.13.1'

    def work_version = "2.7.1"
    // (Java only)
    implementation "androidx.work:work-runtime:$work_version"
    implementation "androidx.work:work-runtime:2.7.1"
    implementation 'androidx.test:core:1.4.0'

    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    androidTestImplementation 'androidx.annotation:annotation:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation  'junit:junit:4.12'
    androidTestImplementation 'junit:junit:4.13.2'

    testImplementation 'androidx.test:runner:1.4.0'
    testImplementation 'androidx.test:rules:1.4.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.robolectric:robolectric:4.8.1'
    testImplementation 'org.mockito:mockito-inline:3.4.0'
    testImplementation "androidx.work:work-testing:$work_version"

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.robolectric:robolectric:4.4'
    testImplementation 'org.mockito:mockito-core:3.4.0'
    //testImplementation 'org.mockito:mockito-inline:3.4.0'
    testImplementation 'androidx.work:work-testing:2.7.1'
}
+0 −100
Original line number Diff line number Diff line
package foundation.e.drive.services;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ServiceTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.TimeoutException;

import static android.support.test.InstrumentationRegistry.getContext;
import static org.junit.Assert.*;




/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ObserverServiceInstrumentedTest {
    private final static String NEW_SMALL_FILE_PATH = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DOCUMENTS+File.separator+"test-small-file.txt";
    private final static String ACCOUNT_NAME= "";
    private final static String ACCOUNT_PASS="";
    private final static String ACCOUNT_TYPE="";


    @Rule
    public final ServiceTestRule mServiceRule = new ServiceTestRule();


    @Before
    public void RegisterAccount() throws Exception {
        final Account account = new Account(ACCOUNT_NAME, ACCOUNT_TYPE);
        AccountManager.get(getContext()).addAccountExplicitly(account, ACCOUNT_PASS, null);

    }


    /**
     * Souldn't it be more for a unit test ?
     * @throws IOException
     */
    @Before
    public void createLocalSmallFile() throws IOException {

        File file = new File(NEW_SMALL_FILE_PATH);
        file.createNewFile();
        String content = "this a very small content";
//write the bytes in file
        if(file.exists())
        {
            OutputStream fo = new FileOutputStream(file);
            fo.write(content.getBytes());
            fo.close();
            System.out.println("file created: "+file);
        }
    }


    @After
    public void deleteLocalSmallFile(){
        File file = new File(NEW_SMALL_FILE_PATH);
        //deleting the file
        file.delete();
    }


    @Test
    public void testWithStartedService() throws TimeoutException {
        mServiceRule.startService(
                new Intent(InstrumentationRegistry.getTargetContext(), ObserverService.class));
        //do something
    }

    @Test
    public void useAppContext() throws Exception {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();


        assertEquals("foundation.e.drive", appContext.getPackageName());
    }
}
Loading