From a380adea1052d39f23c9c4d432a9380ce347d6c4 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 24 Dec 2018 00:27:25 -0500 Subject: Migrate to androidx (#178) * Initial refactor * Remove alpha version usages * Update test code * Add tests for checkbox * Fix invalid card import * Remove more old support content * Update kotlin version * Add back kotterknife with new imports * Update docs * Use bold notice * Add changelog * Remove deprecation for kotterknife * Remove unused dependencies * Update changelog --- .../kotlin/ca/allanwang/kau/kpref/KPrefTest.kt | 9 +++++---- .../kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt | 8 ++++---- .../androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt | 15 ++++++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'core/src/androidTest/kotlin/ca/allanwang') diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt index 2a9263a..52f344b 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt @@ -1,9 +1,10 @@ package ca.allanwang.kau.kpref import android.annotation.SuppressLint -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -23,7 +24,7 @@ class KPrefTest { class TestPref : KPref() { init { - initialize(InstrumentationRegistry.getTargetContext(), "kpref_test_${System.currentTimeMillis()}") + initialize(ApplicationProvider.getApplicationContext(), "kpref_test_${System.currentTimeMillis()}") } var one by kpref("one", 1) diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt index 1dac92f..13a3c77 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt @@ -1,12 +1,12 @@ package ca.allanwang.kau.utils import android.content.Context -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 import android.view.View import android.widget.FrameLayout import android.widget.TextView +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import androidx.test.platform.app.InstrumentationRegistry import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -25,7 +25,7 @@ class KotterknifeTest { @Before fun init() { - context = InstrumentationRegistry.getContext() + context = InstrumentationRegistry.getInstrumentation().context } @Test diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt index f9ce24b..7a6d2e0 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt @@ -1,8 +1,10 @@ package ca.allanwang.kau.xml -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import ca.allanwang.kau.test.R import org.junit.Test import org.junit.runner.RunWith import kotlin.test.assertEquals @@ -14,9 +16,12 @@ import kotlin.test.assertEquals @MediumTest class FaqTest { + val context: Context + get() = ApplicationProvider.getApplicationContext() + @Test fun simpleTest() { - InstrumentationRegistry.getTargetContext().kauParseFaq(R.xml.test_faq) { data -> + context.kauParseFaq(R.xml.test_faq) { data -> assertEquals(2, data.size, "FAQ size is incorrect") assertEquals("1. This is a question", data.first().question.toString(), "First question does not match") assertEquals("This is an answer", data.first().answer.toString(), "First answer does not match") @@ -27,7 +32,7 @@ class FaqTest { @Test fun withoutNumbering() { - InstrumentationRegistry.getTargetContext().kauParseFaq(R.xml.test_faq, false) { data -> + context.kauParseFaq(R.xml.test_faq, false) { data -> assertEquals(2, data.size, "FAQ size is incorrect") assertEquals("This is a question", data.first().question.toString(), "First question does not match") assertEquals("This is an answer", data.first().answer.toString(), "First answer does not match") -- cgit v1.2.3