mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fixed ZimHostFragment
which is failing on API level 33.
* Improved the permission. * Enabled wifi programmatically in emulator. * Improved test case for showing "Wifi connection dialog".
This commit is contained in:
parent
ed4f072048
commit
87632c5f6a
@ -53,14 +53,16 @@ class ZimHostFragmentTest {
|
||||
arrayOf(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
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_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_NETWORK_STATE
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.assertThat
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import applyWithViewHierarchyPrinting
|
||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||
import com.adevinta.android.barista.interaction.BaristaSwipeRefreshInteractions.refresh
|
||||
@ -64,14 +65,21 @@ class ZimHostRobot : BaseRobot() {
|
||||
}
|
||||
|
||||
fun clickOnTestZim() {
|
||||
pauseForBetterTestPerformance()
|
||||
clickOn(Text("Test_Zim"))
|
||||
}
|
||||
|
||||
fun startServer() {
|
||||
// stop the server if it is already running.
|
||||
stopServerIfAlreadyStarted()
|
||||
clickOn(ViewId(R.id.startServerButton))
|
||||
assetWifiDialogDisplayed()
|
||||
onView(withText("PROCEED")).perform(click())
|
||||
}
|
||||
|
||||
private fun assetWifiDialogDisplayed() {
|
||||
pauseForBetterTestPerformance()
|
||||
isVisible(TextId(R.string.wifi_dialog_title))
|
||||
clickOn(TextId(R.string.hotspot_dialog_neutral_button))
|
||||
isVisible(Text("WiFi connection detected"))
|
||||
}
|
||||
|
||||
fun assertServerStarted() {
|
||||
@ -110,7 +118,6 @@ class ZimHostRobot : BaseRobot() {
|
||||
}
|
||||
|
||||
private fun selectZimFile(position: Int) {
|
||||
pauseForBetterTestPerformance()
|
||||
try {
|
||||
onView(
|
||||
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
|
||||
@ -119,7 +126,6 @@ class ZimHostRobot : BaseRobot() {
|
||||
)
|
||||
).check(matches(ViewMatchers.isChecked()))
|
||||
} catch (assertionError: AssertionFailedError) {
|
||||
pauseForBetterTestPerformance()
|
||||
onView(
|
||||
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
|
||||
position,
|
||||
@ -148,6 +154,6 @@ class ZimHostRobot : BaseRobot() {
|
||||
}
|
||||
|
||||
private fun pauseForBetterTestPerformance() {
|
||||
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_DOWNLOAD_TEST.toLong())
|
||||
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Enable Wi-Fi on the emulator
|
||||
adb shell svc wifi enable
|
||||
adb logcat -c
|
||||
adb logcat ./*:E -v color &
|
||||
retry=0
|
||||
@ -11,6 +13,8 @@ do
|
||||
else
|
||||
adb kill-server
|
||||
adb start-server
|
||||
# Enable Wi-Fi on the emulator
|
||||
adb shell svc wifi enable
|
||||
adb logcat -c
|
||||
adb logcat ./*:E -v color &
|
||||
./gradlew clean
|
||||
|
Loading…
x
Reference in New Issue
Block a user