Skip to content

Commit 7e28547

Browse files
committed
fix kotlin tests and format
1 parent 88ce597 commit 7e28547

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

packages/shared_preferences/shared_preferences_android/android/src/main/kotlin/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ class SharedPreferencesPlugin() : FlutterPlugin, SharedPreferencesAsyncApi {
108108
}
109109

110110
/** Adds property to data store of type List<String> as encoded String. */
111-
override fun setEncodedStringList(key: String, value: String, options: SharedPreferencesPigeonOptions) {
111+
override fun setEncodedStringList(
112+
key: String,
113+
value: String,
114+
options: SharedPreferencesPigeonOptions
115+
) {
112116
return runBlocking { dataStoreSetString(key, value) }
113117
}
114118

@@ -312,7 +316,11 @@ class SharedPreferencesBackend(
312316
}
313317

314318
/** Adds property to data store of type List<String>. */
315-
override fun setEncodedStringList(key: String, value: String, options: SharedPreferencesPigeonOptions) {
319+
override fun setEncodedStringList(
320+
key: String,
321+
value: String,
322+
options: SharedPreferencesPigeonOptions
323+
) {
316324
return createSharedPreferences(options).edit().putString(key, value).apply()
317325
}
318326

packages/shared_preferences/shared_preferences_android/android/src/test/kotlin/io/flutter/plugins/sharedpreferences/SharedPreferencesTest.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ internal class SharedPreferencesTest {
9595
@Test
9696
fun testSetAndGetStringListWithDataStore() {
9797
val plugin = pluginSetup(dataStoreOptions)
98-
plugin.setStringList(listKey, testList, dataStoreOptions)
98+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
9999
Assert.assertEquals(plugin.getStringList(listKey, dataStoreOptions), testList)
100100
}
101101

@@ -106,7 +106,7 @@ internal class SharedPreferencesTest {
106106
plugin.setString(stringKey, testString, dataStoreOptions)
107107
plugin.setInt(intKey, testInt, dataStoreOptions)
108108
plugin.setDouble(doubleKey, testDouble, dataStoreOptions)
109-
plugin.setStringList(listKey, testList, dataStoreOptions)
109+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
110110
val keyList = plugin.getKeys(listOf(boolKey, stringKey), dataStoreOptions)
111111
Assert.assertEquals(keyList.size, 2)
112112
Assert.assertTrue(keyList.contains(stringKey))
@@ -120,7 +120,7 @@ internal class SharedPreferencesTest {
120120
plugin.setString(stringKey, testString, dataStoreOptions)
121121
plugin.setInt(intKey, testInt, dataStoreOptions)
122122
plugin.setDouble(doubleKey, testDouble, dataStoreOptions)
123-
plugin.setStringList(listKey, testList, dataStoreOptions)
123+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
124124

125125
plugin.clear(null, dataStoreOptions)
126126

@@ -138,7 +138,7 @@ internal class SharedPreferencesTest {
138138
plugin.setString(stringKey, testString, dataStoreOptions)
139139
plugin.setInt(intKey, testInt, dataStoreOptions)
140140
plugin.setDouble(doubleKey, testDouble, dataStoreOptions)
141-
plugin.setStringList(listKey, testList, dataStoreOptions)
141+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
142142

143143
val all = plugin.getAll(null, dataStoreOptions)
144144

@@ -156,7 +156,7 @@ internal class SharedPreferencesTest {
156156
plugin.setString(stringKey, testString, dataStoreOptions)
157157
plugin.setInt(intKey, testInt, dataStoreOptions)
158158
plugin.setDouble(doubleKey, testDouble, dataStoreOptions)
159-
plugin.setStringList(listKey, testList, dataStoreOptions)
159+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
160160

161161
plugin.clear(listOf(boolKey, stringKey), dataStoreOptions)
162162

@@ -174,7 +174,7 @@ internal class SharedPreferencesTest {
174174
plugin.setString(stringKey, testString, dataStoreOptions)
175175
plugin.setInt(intKey, testInt, dataStoreOptions)
176176
plugin.setDouble(doubleKey, testDouble, dataStoreOptions)
177-
plugin.setStringList(listKey, testList, dataStoreOptions)
177+
plugin.setEncodedStringList(listKey, testList, dataStoreOptions)
178178

179179
val all = plugin.getAll(listOf(boolKey, stringKey), dataStoreOptions)
180180

@@ -216,7 +216,7 @@ internal class SharedPreferencesTest {
216216
@Test
217217
fun testSetAndGetStringListWithSharedPreferences() {
218218
val plugin = pluginSetup(sharedPreferencesOptions)
219-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
219+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
220220
Assert.assertEquals(plugin.getStringList(listKey, sharedPreferencesOptions), testList)
221221
}
222222

@@ -227,7 +227,7 @@ internal class SharedPreferencesTest {
227227
plugin.setString(stringKey, testString, sharedPreferencesOptions)
228228
plugin.setInt(intKey, testInt, sharedPreferencesOptions)
229229
plugin.setDouble(doubleKey, testDouble, sharedPreferencesOptions)
230-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
230+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
231231
val keyList = plugin.getKeys(listOf(boolKey, stringKey), sharedPreferencesOptions)
232232
Assert.assertEquals(keyList.size, 2)
233233
Assert.assertTrue(keyList.contains(stringKey))
@@ -241,7 +241,7 @@ internal class SharedPreferencesTest {
241241
plugin.setString(stringKey, testString, sharedPreferencesOptions)
242242
plugin.setInt(intKey, testInt, sharedPreferencesOptions)
243243
plugin.setDouble(doubleKey, testDouble, sharedPreferencesOptions)
244-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
244+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
245245

246246
plugin.clear(null, sharedPreferencesOptions)
247247

@@ -259,7 +259,7 @@ internal class SharedPreferencesTest {
259259
plugin.setString(stringKey, testString, sharedPreferencesOptions)
260260
plugin.setInt(intKey, testInt, sharedPreferencesOptions)
261261
plugin.setDouble(doubleKey, testDouble, sharedPreferencesOptions)
262-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
262+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
263263

264264
val all = plugin.getAll(null, sharedPreferencesOptions)
265265

@@ -277,7 +277,7 @@ internal class SharedPreferencesTest {
277277
plugin.setString(stringKey, testString, sharedPreferencesOptions)
278278
plugin.setInt(intKey, testInt, sharedPreferencesOptions)
279279
plugin.setDouble(doubleKey, testDouble, sharedPreferencesOptions)
280-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
280+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
281281

282282
plugin.clear(listOf(boolKey, stringKey), sharedPreferencesOptions)
283283

@@ -295,7 +295,7 @@ internal class SharedPreferencesTest {
295295
plugin.setString(stringKey, testString, sharedPreferencesOptions)
296296
plugin.setInt(intKey, testInt, sharedPreferencesOptions)
297297
plugin.setDouble(doubleKey, testDouble, sharedPreferencesOptions)
298-
plugin.setStringList(listKey, testList, sharedPreferencesOptions)
298+
plugin.setEncodedStringList(listKey, testList, sharedPreferencesOptions)
299299

300300
val all = plugin.getAll(listOf(boolKey, stringKey), sharedPreferencesOptions)
301301

0 commit comments

Comments
 (0)