aboutsummaryrefslogtreecommitdiff
path: root/core/src/androidTest/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-31 23:02:01 -0700
committerGitHub <noreply@github.com>2017-07-31 23:02:01 -0700
commit48213d0b427c478865c75fee912ff1ae8bbaffb5 (patch)
tree7aef1d8400fc3403ee5a40aba945f33a95319359 /core/src/androidTest/kotlin/ca
parent8a4e9fd44dfbcf58aa7ab63167dcbdf8752db7d0 (diff)
downloadkau-48213d0b427c478865c75fee912ff1ae8bbaffb5.tar.gz
kau-48213d0b427c478865c75fee912ff1ae8bbaffb5.tar.bz2
kau-48213d0b427c478865c75fee912ff1ae8bbaffb5.zip
Major update to core and kotterknife; create mediapicker (#15)
* Readme * Fix kau direction bits * Truly support transparent ripples * Update changelog * Test rect as base * Replace fab transition with generic fade scale transition * Add scalexy func * Add scaleXY * Add arguments to fadeScaleTransition * Clean up ink indicator * Create setOnSingleTapListener * Fix lint and add rndColor * Create kotterknife resettables * Add readme and missing object * Create lazy resettable registered * Update core docs * Opt for separate class for resettable registry * Clean up resettable registry * Rename functions * Add ripple callback listener * Adjust kprefactivity desc color * Add more transitions * Add delete keys option * Add instrumentation tests * switch id * Revert automatic instrumental tests * Generify imagepickercore and prepare video alternative * Create working video picker * Address possible null issue * Update searchview * Make layouts public * Add changelog test * Update logo link * Add custom color gif
Diffstat (limited to 'core/src/androidTest/kotlin/ca')
-rw-r--r--core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt198
-rw-r--r--core/src/androidTest/kotlin/ca/allanwang/kau/xml/ChangelogTest.kt22
2 files changed, 220 insertions, 0 deletions
diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt
new file mode 100644
index 0000000..3282911
--- /dev/null
+++ b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt
@@ -0,0 +1,198 @@
+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 org.junit.Assert.*
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Created by Allan Wang on 2017-07-30.
+ */
+@RunWith(AndroidJUnit4::class)
+@MediumTest
+class KotterknifeTest {
+
+ lateinit var context: Context
+
+ @Before
+ fun init() {
+ context = InstrumentationRegistry.getContext()
+ }
+
+ @Test
+ fun testCast() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: TextView by bindView(1)
+ }
+
+ val example = Example(context)
+ example.addView(textViewWithId(1))
+ assertNotNull(example.name)
+ }
+
+ @Test
+ fun testFindCached() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: View by bindView(1)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ assertNotNull(example.name)
+ example.removeAllViews()
+ assertNotNull(example.name)
+ }
+
+ @Test
+ fun testOptional() {
+ class Example(context: Context) : FrameLayout(context) {
+ val present: View? by bindOptionalView(1)
+ val missing: View? by bindOptionalView(2)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ assertNotNull(example.present)
+ assertNull(example.missing)
+ }
+
+ @Test
+ fun testOptionalCached() {
+ class Example(context: Context) : FrameLayout(context) {
+ val present: View? by bindOptionalView(1)
+ val missing: View? by bindOptionalView(2)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ assertNotNull(example.present)
+ assertNull(example.missing)
+ example.removeAllViews()
+ example.addView(viewWithId(2))
+ assertNotNull(example.present)
+ assertNull(example.missing)
+ }
+
+ @Test
+ fun testMissingFails() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: TextView? by bindView(1)
+ }
+
+ val example = Example(context)
+ try {
+ example.name
+ } catch (e: IllegalStateException) {
+ assertEquals("View ID 1 for 'name' not found.", e.message)
+ }
+ }
+
+ @Test
+ fun testList() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: List<TextView> by bindViews(1, 2, 3)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ example.addView(viewWithId(2))
+ example.addView(viewWithId(3))
+ assertNotNull(example.name)
+ assertEquals(3, example.name.size)
+ }
+
+ @Test
+ fun testListCaches() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: List<TextView> by bindViews(1, 2, 3)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ example.addView(viewWithId(2))
+ example.addView(viewWithId(3))
+ assertNotNull(example.name)
+ assertEquals(3, example.name.size)
+ example.removeAllViews()
+ assertNotNull(example.name)
+ assertEquals(3, example.name.size)
+ }
+
+ @Test
+ fun testListMissingFails() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: List<TextView> by bindViews(1, 2, 3)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ example.addView(viewWithId(3))
+ try {
+ example.name
+ } catch (e: IllegalStateException) {
+ assertEquals("View ID 2 for 'name' not found.", e.message)
+ }
+ }
+
+ @Test
+ fun testOptionalList() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: List<TextView> by bindOptionalViews(1, 2, 3)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ example.addView(viewWithId(3))
+ assertNotNull(example.name)
+ assertEquals(2, example.name.size)
+ }
+
+ @Test
+ fun testOptionalListCaches() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: List<TextView> by bindOptionalViews(1, 2, 3)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ example.addView(viewWithId(3))
+ assertNotNull(example.name)
+ assertEquals(2, example.name.size)
+ example.removeAllViews()
+ assertNotNull(example.name)
+ assertEquals(2, example.name.size)
+ }
+
+ @Test
+ fun testReset() {
+ class Example(context: Context) : FrameLayout(context) {
+ val name: View? by bindOptionalViewResettable(1)
+ }
+
+ val example = Example(context)
+ example.addView(viewWithId(1))
+ assertNotNull(example.name)
+ example.removeAllViews()
+ Kotterknife.reset(example)
+ assertNull(example.name)
+ }
+
+ private fun viewWithId(id: Int): View {
+ val view = View(context)
+ view.id = id
+ return view
+ }
+
+ private fun textViewWithId(id: Int): View {
+ val view = TextView(context)
+ view.id = id
+ return view
+ }
+} \ No newline at end of file
diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/ChangelogTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/ChangelogTest.kt
new file mode 100644
index 0000000..dcff70e
--- /dev/null
+++ b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/ChangelogTest.kt
@@ -0,0 +1,22 @@
+package ca.allanwang.kau.xml
+
+import android.support.test.InstrumentationRegistry
+import android.support.test.filters.MediumTest
+import android.support.test.runner.AndroidJUnit4
+import ca.allanwang.kau.test.R
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Created by Allan Wang on 2017-07-31.
+ */
+@RunWith(AndroidJUnit4::class)
+@MediumTest
+class ChangelogTest {
+
+ @Test
+ fun simpleTest() {
+ val data = parse(InstrumentationRegistry.getTargetContext(), R.xml.text_changelog)
+ }
+
+} \ No newline at end of file