Skip to content

Commit

Permalink
Merge pull request nextcloud#12057 from nextcloud/fixTwoScreenshotTests
Browse files Browse the repository at this point in the history
make tests more robust
  • Loading branch information
alperozturk96 committed Oct 19, 2023
2 parents 973bb4a + 7da1156 commit b594c35
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

waitForIdleSync()
shortSleep()
shortSleep()
shortSleep()
screenshot(sut)
waitForIdleSync()

activity.runOnUiThread {
sut.hideMap()
}

screenshot(activity)
}

@Test
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/nextcloud/ui/ImageDetailFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.os.Parcelable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.nextcloud.android.common.ui.theme.utils.ColorRole
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ private void fetchAndSetData(int lastGiven) {
});
return;
}

if (!isLoadingActivities) {
return;
}

Thread t = new Thread(() -> {
try {
Expand Down Expand Up @@ -454,6 +458,11 @@ public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
return false;
}

@VisibleForTesting
public void disableLoadingActivities() {
isLoadingActivities = false;
}

private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {

Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/analysis-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ else

# check for NotNull
if [[ $(grep org.jetbrains.annotations app/src/main/* -irl | wc -l) -gt 0 ]] ; then
notNull="org.jetbrains.annotations.NotNull is used. Please use androidx.annotation.NonNull instead.<br><br>"
notNull="org.jetbrains.annotations.* is used. Please use androidx.annotation.* instead.<br><br>"
fi

bodyContent="$codacyResult $lintResult $spotbugsResult $checkLibraryMessage $lintMessage $spotbugsMessage $gplayLimitation $notNull"
Expand Down

0 comments on commit b594c35

Please sign in to comment.