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

Commit 5c870480 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

Move instrumented tests to robolectric unit tests

parent 46106bee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -109,11 +109,11 @@ dependencies {
    implementation 'io.reactivex.rxjava2:rxjava:2.2.21'

    // Testing
    testImplementation 'androidx.test:core:1.3.0'
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:3.10.0'
    testImplementation 'org.robolectric:robolectric:4.5.1'
    testImplementation 'androidx.test:core:1.3.0'
    testImplementation 'androidx.arch.core:core-testing:2.1.0'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
}
+1 −0
Original line number Diff line number Diff line
@@ -52,4 +52,5 @@ dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.robolectric:robolectric:4.5.1'
}
 No newline at end of file
+0 −17
Original line number Diff line number Diff line
package it.niedermann.android.markdown;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
public class ExampleUnitTest {
    @Test
    public void addition_isCorrect() {
        assertEquals(4, 2 + 2);
    }
}
 No newline at end of file
+6 −2
Original line number Diff line number Diff line
package it.niedermann.android.markdown;

import android.os.Build;

import androidx.core.text.HtmlCompat;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(AndroidJUnit4.class)
@RunWith(RobolectricTestRunner.class)
@Config(sdk = {Build.VERSION_CODES.P})
public class ListTagHandlerTest extends TestCase {

    //language=html
+7 −9
Original line number Diff line number Diff line
package it.niedermann.android.markdown;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -24,13 +23,14 @@ import java.util.Map;
import it.niedermann.android.markdown.model.EListType;
import it.niedermann.android.markdown.model.SearchSpan;

@RunWith(AndroidJUnit4.class)
@RunWith(RobolectricTestRunner.class)
@Config(sdk = {Build.VERSION_CODES.P})
public class MarkdownUtilTest extends TestCase {

    @Test
    public void testGetStartOfLine() {
        //language=md
        StringBuilder test = new StringBuilder(
        final StringBuilder test = new StringBuilder(
                "# Test-Note\n" + // line start 0
                        "\n" + // line start 12
                        "- [ ] this is a test note\n" + // line start 13
@@ -660,8 +660,6 @@ public class MarkdownUtilTest extends TestCase {
            final Method removeSpans = MarkdownUtil.class.getDeclaredMethod("removeSpans", Spannable.class, Class.class);
            removeSpans.setAccessible(true);

            final Context context = ApplicationProvider.getApplicationContext();

            final Editable editable_1 = new SpannableStringBuilder("Lorem Ipsum dolor sit amet");
            editable_1.setSpan(new SearchSpan(Color.RED, Color.GRAY, false, false), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            editable_1.setSpan(new ForegroundColorSpan(Color.BLUE), 6, 11, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);