diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt index e870a20d5..14a9868e7 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt @@ -257,44 +257,30 @@ class ObjectBoxToLibkiwixMigratorTest : BaseActivityTest() { @Test fun testLargeDataMigration(): Unit = runBlocking { // Test large data migration for recent searches - val numEntities = 1000 // Insert a large number of recent search entities into ObjectBox - (1..numEntities) - .asSequence() - .map { + for (i in 1..1000) { + box.put( BookmarkEntity( 0, expectedZimId, expectedZimName, expectedZimFilePath, - "https://alpine_linux/search_$it", - "title_$it", + "https://alpine_linux/search_$i", + "title_$i", expectedFavicon ) - } - .forEach(box::put) - withContext(Dispatchers.IO) { + ) + } + withContext(Dispatchers.Main) { // Migrate data into Room database objectBoxToLibkiwixMigrator.migrateBookMarks(box) } // Check if data successfully migrated to Room - objectBoxToLibkiwixMigrator.libkiwixBookmarks.bookmarks() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe( - { actualDataAfterMigration -> - assertEquals(numEntities, actualDataAfterMigration.size) - // Clear the bookmarks list from device to not affect the other test cases. - clearBookmarks() - }, - { - // Clear the bookmarks list from device to not affect the other test cases. - clearBookmarks() - throw RuntimeException( - "Exception occurred during migration. Original Exception ${it.printStackTrace()}" - ) - } - ) + val actualDataAfterMigration = + objectBoxToLibkiwixMigrator.libkiwixBookmarks.bookmarks().blockingFirst() + assertEquals(1000, actualDataAfterMigration.size) + // Clear the bookmarks list from device to not affect the other test cases. + clearBookmarks() } private fun clearBookmarks() { diff --git a/contrib/instrumentation.sh b/contrib/instrumentation.sh index c2ac3fe7e..a734fa6c6 100644 --- a/contrib/instrumentation.sh +++ b/contrib/instrumentation.sh @@ -4,19 +4,7 @@ adb logcat -c # shellcheck disable=SC2035 adb logcat *:E -v color & retry=0 - - -PACKAGE_NAME="org.kiwix.kiwixmobile" - -# Function to check if the application is installed -is_app_installed() { - adb shell pm list packages | grep -q "${PACKAGE_NAME}" -} - -if is_app_installed; then - # Clear application data to properly run the test cases. - adb shell pm clear "${PACKAGE_NAME}" -fi +adb shell pm clear "org.kiwix.kiwixmobile" while [ $retry -le 3 ]; do if ./gradlew jacocoInstrumentationTestReport; then @@ -29,17 +17,7 @@ while [ $retry -le 3 ]; do # shellcheck disable=SC2035 adb logcat *:E -v color & - PACKAGE_NAME="org.kiwix.kiwixmobile" - - # Function to check if the application is installed - is_app_installed() { - adb shell pm list packages | grep -q "${PACKAGE_NAME}" - } - - if is_app_installed; then - # Clear application data to properly run the test cases. - adb shell pm clear "${PACKAGE_NAME}" - fi + adb shell pm clear "org.kiwix.kiwixmobile" ./gradlew clean retry=$(( retry + 1 )) if [ $retry -eq 3 ]; then