aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-07-01 14:44:34 -0700
committerAllan Wang <me@allanwang.ca>2019-07-01 14:44:34 -0700
commit39bda3064e75a8a4be100afa4f5e7adee33c2f17 (patch)
tree61349f45b00f1697d6824aca5fcd2546735e0f23
parent1f9198a1c05223edc7abb095f483d02cda5f1122 (diff)
downloadkau-39bda3064e75a8a4be100afa4f5e7adee33c2f17.tar.gz
kau-39bda3064e75a8a4be100afa4f5e7adee33c2f17.tar.bz2
kau-39bda3064e75a8a4be100afa4f5e7adee33c2f17.zip
Update changelog and add post setter test
-rw-r--r--core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt12
-rw-r--r--docs/Changelog.md2
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml4
3 files changed, 15 insertions, 3 deletions
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 735302c..143b83f 100644
--- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt
+++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt
@@ -41,11 +41,15 @@ class KPrefTest {
initialize(ApplicationProvider.getApplicationContext<Context>(), "kpref_test_${System.currentTimeMillis()}")
}
+ var postSetterCount: Int = 0
+
var one by kpref("one", 1)
var two by kpref("two", 2f)
- var `true` by kpref("true", true)
+ var `true` by kpref("true", true, postSetter = {
+ postSetterCount++
+ })
var hello by kpref("hello", "hello")
@@ -113,4 +117,10 @@ class KPrefTest {
assertPrefEquals(true, { oneShot })
assertPrefEquals(false, { androidPref.oneShot })
}
+
+ @Test
+ fun postSetter() {
+ pref { `true` = true }
+ assertPrefEquals(1, { postSetterCount }, "Post setter was not called")
+ }
}
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 0ccf69c..b282830 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -3,6 +3,8 @@
## v5.0.1
* :adapter: Moved fastadapter elements to new module, :fastadapter:. To migrate, simply rename the dependency. If you don't use fast adapter, no changes are necessary
* :adapter: Make NoAnimatorChange an object; previously a class
+* :core: KPref now supports in memory only variants for testing; pass KPrefBuilderInMemory to KPref constructor
+* :core: KPref initializer takes in SharedPreferences so user can configure it
## v5.0.0
* Update Android SDK to 29 and Kotlin to 1.3.31
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index 0e38015..6144685 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -9,8 +9,8 @@
<version title="v5.0.1" />
<item text=":adapter: Moved fastadapter elements to new module, :fastadapter:. To migrate, simply rename the dependency. If you don't use fast adapter, no changes are necessary" />
<item text=":adapter: Make NoAnimatorChange an object; previously a class" />
- <item text="" />
- <item text="" />
+ <item text=":core: KPref now supports in memory only variants for testing; pass KPrefBuilderInMemory to KPref constructor" />
+ <item text=":core: KPref initializer takes in SharedPreferences so user can configure it" />
<item text="" />
<version title="v5.0.0" />