Skip to content

Commit 249dfbd

Browse files
author
Krzysztof Borowy
committed
address comments, e2e for next
1 parent 38c7c15 commit 249dfbd

File tree

7 files changed

+44
-7
lines changed

7 files changed

+44
-7
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ jobs:
218218
- run:
219219
name: Build APK
220220
command: yarn build:e2e:android
221+
- run:
222+
name: Build APK with Next storage
223+
working_directory: example/android
224+
command: ./gradlew assembleNext --max-workers 2
221225
- persist_to_workspace:
222226
root: ~/async_storage
223227
paths:
@@ -292,6 +296,9 @@ jobs:
292296
- run:
293297
name: Run e2e tests
294298
command: yarn test:e2e:android
299+
- run:
300+
name: Run e2e tests for Next storage
301+
command: yarn detox test -c android.emu.release.next --maxConcurrency 1
295302

296303
Release:
297304
<<: *js_defaults

android/src/main/java/com/reactnativecommunity/asyncstorage/SerialExecutor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import java.util.ArrayDeque;
44
import java.util.concurrent.Executor;
55

6-
// Adapted from https://android.googlesource.com/platform/frameworks/base.git/+/1488a3a19d4681a41fb45570c15e14d99db1cb66/core/java/android/os/AsyncTask.java#237
6+
/**
7+
* Detox is using this implementation detail in its environment setup,
8+
* so in order for Next storage to work, this class has been made public
9+
* <p>
10+
* Adapted from https://android.googlesource.com/platform/frameworks/base.git/+/1488a3a19d4681a41fb45570c15e14d99db1cb66/core/java/android/os/AsyncTask.java#237
11+
*/
712
public class SerialExecutor implements Executor {
813
private final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>();
914
private Runnable mActive;
@@ -27,6 +32,7 @@ public void run() {
2732
scheduleNext();
2833
}
2934
}
35+
3036
synchronized void scheduleNext() {
3137
if ((mActive = mTasks.poll()) != null) {
3238
executor.execute(mActive);

android/src/main/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpers.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ fun ReadableArray.toEntryList(): List<Entry> {
1414
val key = keyValue[0]
1515
val value = keyValue[1]
1616

17-
if (key == null || key !is String) {
17+
if (key !is String) {
1818
when (key) {
1919
null -> throw AsyncStorageError.keyIsNull()
20-
!is String -> throw AsyncStorageError.keyNotString()
20+
else -> throw AsyncStorageError.keyNotString()
2121
}
2222
}
2323

android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import kotlinx.coroutines.launch
1919
class StorageModule(reactContext: ReactContext) : ReactContextBaseJavaModule(), CoroutineScope {
2020
override fun getName() = "RNC_AsyncSQLiteDBStorage"
2121

22-
// this executor is here only to please detox, which relies on internal implementation
23-
// of current Async Storage
22+
// this executor is not used by the module, but it must exists
23+
// Detox relies on this implementation detail to run
2424
@VisibleForTesting
2525
private val executor = SerialExecutor(Dispatchers.Main.asExecutor())
2626

example/android/build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ task fetchDependencies() {
2828
buildscript {
2929
ext.kotlinVersion = '1.4.21'
3030

31+
// Mainly for Detox testing for using Next Storage
32+
// when building next, force using next storage
33+
if(gradle.startParameter.getTaskNames().contains("assembleNext")) {
34+
rootProject.setProperty("AsyncStorage_useNextStorage", "true")
35+
}
36+
3137
repositories {
3238
google()
3339
jcenter()
@@ -65,7 +71,17 @@ allprojects {
6571
}
6672
}
6773

68-
androidExtension.buildTypes.release.signingConfig = androidExtension.signingConfigs.test
74+
androidExtension.buildTypes {
75+
release {
76+
signingConfig androidExtension.signingConfigs.test
77+
}
78+
79+
next {
80+
initWith release
81+
matchingFallbacks = ["debug", "release"]
82+
}
83+
}
84+
6985
androidExtension.testBuildType = 'release'
7086

7187
androidExtension.sourceSets.androidTest.java.srcDirs += "$rootDir/app/src/androidTest/java"

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Enable dedicated thread pool executor
2424
AsyncStorage_dedicatedExecutor=true
25-
AsyncStorage_useNextStorage=true
25+
AsyncStorage_useNextStorage=false
2626

2727
android.useAndroidX=true
2828
android.enableJetifier=true

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@
128128
"device": {
129129
"avdName": "Emu_E2E"
130130
}
131+
},
132+
"android.emu.release.next": {
133+
"binaryPath": "example/android/app/build/outputs/apk/next/app-next.apk",
134+
"testBinaryPath": "example/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk",
135+
"type": "android.emulator",
136+
"device": {
137+
"avdName": "Emu_E2E"
138+
}
131139
}
132140
}
133141
},

0 commit comments

Comments
 (0)