mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 23:07:26 -04:00
Added Notification permission in our test cases for API level 33.
* Improved our `ZimHostFragmentTest` test to boost the test case speed. It was running in 2 minutes, but after this change, it now completes in 27 seconds.
This commit is contained in:
parent
bfdf5c6e88
commit
f0eb680d21
@ -18,8 +18,9 @@
|
||||
|
||||
package org.kiwix.kiwixmobile
|
||||
|
||||
import android.Manifest.permission
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
@ -34,10 +35,22 @@ import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
||||
abstract class BaseActivityTest {
|
||||
open lateinit var activityScenario: ActivityScenario<KiwixMainActivity>
|
||||
|
||||
private val permissions = arrayOf(
|
||||
permission.READ_EXTERNAL_STORAGE,
|
||||
permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
arrayOf(
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES,
|
||||
Manifest.permission.ACCESS_NETWORK_STATE
|
||||
)
|
||||
} else {
|
||||
arrayOf(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_NETWORK_STATE
|
||||
)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var permissionRules: GrantPermissionRule =
|
||||
|
@ -51,6 +51,7 @@ class LocalFileTransferTest {
|
||||
|
||||
private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
arrayOf(
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
)
|
||||
} else {
|
||||
|
@ -46,6 +46,7 @@ class PlayStoreRestrictionDialogTest {
|
||||
|
||||
private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
arrayOf(
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
|
@ -52,6 +52,7 @@ class ZimHostFragmentTest {
|
||||
|
||||
private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
arrayOf(
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES,
|
||||
|
@ -82,12 +82,18 @@ class ZimHostRobot : BaseRobot() {
|
||||
|
||||
fun stopServerIfAlreadyStarted() {
|
||||
try {
|
||||
assertServerStarted()
|
||||
stopServer()
|
||||
// Check if the "START SERVER" button is visible because, in most scenarios,
|
||||
// this button will appear when the server is already stopped.
|
||||
// This will expedite our test case, as verifying the visibility of
|
||||
// non-visible views takes more time due to the try mechanism needed
|
||||
// to properly retrieve the view.
|
||||
assertServerStopped()
|
||||
} catch (exception: Exception) {
|
||||
// if "START SERVER" button is not visible it means server is started so close it.
|
||||
stopServer()
|
||||
Log.i(
|
||||
"ZIM_HOST_FRAGMENT",
|
||||
"Failed to stop the server, Probably because server is not running"
|
||||
"Stopped the server to perform our test case since it was already running"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user