make tests more robust

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2023-10-18 07:46:09 +02:00 committed by Tobias Kaminsky
parent 973bb4a8b4
commit 5b527929ea
4 changed files with 27 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -73,14 +73,19 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
@Test
@ScreenshotTest
fun showFileDetailDetailsFragment() {
val sut = testActivityRule.launchActivity(null)
sut.addFragment(ImageDetailFragment.newInstance(oCFile, user))
val activity = testActivityRule.launchActivity(null)
val sut = ImageDetailFragment.newInstance(oCFile, user)
activity.addFragment(sut)
shortSleep()
shortSleep()
waitForIdleSync()
shortSleep()
shortSleep()
shortSleep()
screenshot(sut)
activity.runOnUiThread {
sut.hideMap()
}
screenshot(activity)
}
@Test
@ -182,6 +187,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
waitForIdleSync()
activity.runOnUiThread {
sut.fileDetailActivitiesFragment.disableLoadingActivities()
sut
.fileDetailActivitiesFragment
.setErrorContent(targetContext.resources.getString(R.string.file_detail_activity_error))

View file

@ -49,6 +49,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.parcelize.Parcelize
import org.jetbrains.annotations.VisibleForTesting
import org.osmdroid.config.Configuration
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
import org.osmdroid.util.GeoPoint
@ -260,6 +261,11 @@ class ImageDetailFragment : Fragment(), Injectable {
binding.imageLocationMapCopyright.text = binding.imageLocationMap.tileProvider.tileSource.copyrightNotice
}
@VisibleForTesting
fun hideMap() {
binding.imageLocationMap.visibility = View.GONE
}
@SuppressLint("SimpleDateFormat")
private fun gatherMetadata() {
val fileSize = DisplayUtils.bytesToHumanReadable(file.fileLength)

View file

@ -284,6 +284,10 @@ public class FileDetailActivitiesFragment extends Fragment implements
});
return;
}
if (!isLoadingActivities) {
return;
}
Thread t = new Thread(() -> {
try {
@ -454,6 +458,11 @@ public class FileDetailActivitiesFragment extends Fragment implements
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
return false;
}
@VisibleForTesting
public void disableLoadingActivities() {
isLoadingActivities = false;
}
private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {