aboutsummaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/build.gradle18
-rw-r--r--sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt61
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml6
3 files changed, 76 insertions, 9 deletions
diff --git a/sample/build.gradle b/sample/build.gradle
index 5bbdbb0..fb55b94 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -95,13 +95,17 @@ dependencies {
implementation project(':searchview')
implementation project(':mediapicker')
- androidTestImplementation("com.android.support.test.espresso:espresso-core:${kau.espresso}") {
- exclude group: 'com.android.support', module: 'support-annotations'
- }
- androidTestImplementation("com.android.support.test:runner:${kau.testRunner}") {
- exclude group: 'com.android.support', module: 'support-annotations'
- }
- androidTestImplementation kauDependency.kotlinTest
+// androidTestImplementation("com.android.support.test.espresso:espresso-core:${kau.espresso}") {
+// exclude group: 'com.android.support', module: 'support-annotations'
+// }
+// androidTestImplementation("com.android.support.test:runner:${kau.testRunner}") {
+// exclude group: 'com.android.support', module: 'support-annotations'
+// }
+// androidTestImplementation kauDependency.kotlinTest
testImplementation kauDependency.kotlinTest
testImplementation kauDependency.junit
+
+ androidTestImplementation kauDependency.kotlinTest
+ androidTestImplementation kauDependency.espresso
+ androidTestImplementation kauDependency.testRunner
}
diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt
new file mode 100644
index 0000000..39aee93
--- /dev/null
+++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt
@@ -0,0 +1,61 @@
+package ca.allanwang.kau.sample
+
+import android.support.test.espresso.DataInteraction
+import android.support.test.espresso.Espresso.onData
+import android.support.test.espresso.Espresso.onView
+import android.support.test.espresso.ViewAssertion
+import android.support.test.espresso.action.ViewActions.click
+import android.support.test.espresso.matcher.ViewMatchers.withId
+import android.support.test.espresso.matcher.ViewMatchers.withText
+import android.support.test.filters.MediumTest
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import android.view.View
+import ca.allanwang.kau.colorpicker.CircleView
+import org.hamcrest.Matchers.anything
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import kotlin.test.assertEquals
+import kotlin.test.fail
+
+
+/**
+ * Created by Allan Wang on 22/02/2018.
+ */
+@RunWith(AndroidJUnit4::class)
+@MediumTest
+class ColorPickerTest {
+
+ @get:Rule
+ val activity: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
+
+ private fun DataInteraction.click(position: Int) =
+ atPosition(position).perform(click())
+
+ private fun View.colorSelected(selected: Boolean) {
+ val circle = this as? CircleView ?: fail("View is not a CircleView")
+ assertEquals(selected, circle.colorSelected, "CircleView ${circle.tag} ${if (selected) "is not" else "is"} actually selected")
+ }
+
+ private val colorSelected = ViewAssertion { view, _ -> view.colorSelected(true) }
+
+ private val colorNotSelected = ViewAssertion { view, _ -> view.colorSelected(false) }
+
+ @Test
+ fun test() {
+ onView(withText(R.string.accent_color)).perform(click())
+ val colors = onData(anything()).inAdapterView(withId(R.id.md_grid))
+
+ colors.click(0).check(colorNotSelected) // enter sub grid
+ colors.click(0).check(colorSelected) // click first grid item
+ colors.atPosition(1).check(colorNotSelected)
+ colors.atPosition(2).check(colorNotSelected)
+ .perform(click()).check(colorSelected)
+ colors.atPosition(0).check(colorNotSelected)
+ .perform(click()).check(colorSelected)
+ // first item is now selected
+ }
+
+
+}
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index 146042c..40ca6a0 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -9,7 +9,9 @@
<version title="v3.6.4" />
<item text=":core: Fix potential NPE in restart()" />
<item text=":core: Create restartApplication()" />
- <item text="" />
+ <item text=":colorpicker: Rewrote implementation to be null and parse safe" />
+ <item text=":colorpicker: Added more encapsulation to CircleView (selected -> colorSelected; all others are private)" />
+ <item text=":colorpicker:" />
<item text="Update documentation" />
<item text="" />
@@ -224,6 +226,6 @@
<version title="v1.0" />
<item text="Initial Changelog" />
<item text="Create many extension functions" />
- <item text="Port changelog builer" />
+ <item text="Port changelog builder" />
<item text="Port ripple canvas" />
</resources> \ No newline at end of file