Exclude shot for normal builds

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2024-02-22 10:13:22 +01:00
parent 3780d8364e
commit 002f61a2de
No known key found for this signature in database
GPG Key ID: 0E00D4D47D0C5AF7
20 changed files with 44 additions and 19 deletions

View File

@ -8,7 +8,7 @@ permissions:
contents: read
pull-requests: write
concurrency:
concurrency:
group: screenshot-test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
@ -73,6 +73,8 @@ jobs:
run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
- name: Run screenshot tests
env:
SHOT_TEST: "true"
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # v2.30.1
with:
api-level: ${{ matrix.api-level }}

View File

@ -1,6 +1,6 @@
import com.github.spotbugs.snom.SpotBugsTask
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.internal.jvm.Jvm
buildscript {
@ -32,7 +32,12 @@ apply plugin: 'pmd'
apply from: "$rootProject.projectDir/jacoco.gradle"
apply plugin: 'com.github.spotbugs'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'shot'
// needed to make renovate run without shot, as shot requires Android SDK
// https://github.com/pedrovgs/Shot/issues/300
if (shotTest) {
apply plugin: 'shot'
}
apply plugin: 'com.google.devtools.ksp'
@ -99,7 +104,11 @@ android {
}
// arguments to be passed to functional tests
testInstrumentationRunner "com.nextcloud.client.ScreenshotTestRunner"
if (shotTest) {
testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
} else {
testInstrumentationRunner "com.nextcloud.client.TestRunner"
}
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
@ -431,11 +440,13 @@ detekt {
config.setFrom("detekt.yml")
}
shot {
showOnlyFailingTestsInReports = ciBuild
// CI environment renders some shadows slightly different from local VMs
// Add a 0.5% tolerance to account for that
tolerance = ciBuild ? 0.5 : 0
if (shotTest) {
shot {
showOnlyFailingTestsInReports = ciBuild
// CI environment renders some shadows slightly different from local VMs
// Add a 0.5% tolerance to account for that
tolerance = ciBuild ? 0.5 : 0
}
}
jacoco {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -137,7 +137,7 @@ class FileDisplayActivityIT : AbstractOnServerIT() {
.perform(NavigationViewActions.navigateTo(R.id.nav_shared))
shortSleep()
shortSleep()
screenshot(sut)
// screenshot(sut) // todo run without real server
}
@Test

View File

@ -27,11 +27,11 @@ import android.app.Application
import android.app.Instrumentation
import android.content.Context
import android.os.Build
import androidx.test.runner.AndroidJUnitRunner
import com.github.tmurakami.dexopener.DexOpener
import com.karumi.shot.ShotTestRunner
import com.nextcloud.test.TestMainApp
class ScreenshotTestRunner : ShotTestRunner() {
class TestRunner : AndroidJUnitRunner() {
@Throws(ClassNotFoundException::class, IllegalAccessException::class, InstantiationException::class)
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
/*

View File

@ -25,6 +25,7 @@ package com.owncloud.android.ui.dialog;
import com.owncloud.android.AbstractIT;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.utils.ScreenshotTest;
import org.junit.Rule;
import org.junit.Test;
@ -41,6 +42,7 @@ public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
false);
@Test
@ScreenshotTest
public void showNotEnoughSpaceDialogForFolder() {
FileDisplayActivity test = activityRule.launchActivity(null);
OCFile ocFile = new OCFile("/Document/");
@ -56,6 +58,7 @@ public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
}
@Test
@ScreenshotTest
public void showNotEnoughSpaceDialogForFile() {
FileDisplayActivity test = activityRule.launchActivity(null);
OCFile ocFile = new OCFile("/Video.mp4");

View File

@ -26,6 +26,7 @@ import com.owncloud.android.AbstractIT;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.ScreenshotTest;
import org.junit.Rule;
import org.junit.Test;
@ -41,7 +42,7 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
false);
@Test
// @ScreenshotTest // todo run without real server
@ScreenshotTest
public void displaySimpleTextFile() throws IOException {
FileDisplayActivity sut = activityRule.launchActivity(null);
@ -59,7 +60,7 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
}
@Test
// @ScreenshotTest // todo run without real server
@ScreenshotTest
public void displayJavaSnippetFile() throws IOException {
FileDisplayActivity sut = activityRule.launchActivity(null);

View File

@ -109,6 +109,7 @@ class TrashbinActivityIT : AbstractIT() {
}
@Test
@ScreenshotTest
fun normalUser() {
val sut: TrashbinActivity = activityRule.launchActivity(null)
@ -124,6 +125,7 @@ class TrashbinActivityIT : AbstractIT() {
}
@Test
@ScreenshotTest
fun differentUser() {
val temp = Account("differentUser@https://nextcloud.localhost", MainApp.getAccountType(targetContext))

View File

@ -235,14 +235,19 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
thumbnailView.setImageBitmap(thumbnail);
}
} else {
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
file.getFileName(),
context,
viewThemeUtils));
// generate new thumbnail
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
try {
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
storageManager,
user,
asyncTasks);
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
storageManager,
user,
asyncTasks);
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncThumbnailDrawable(context.getResources(),

View File

@ -21,6 +21,7 @@ buildscript {
roomVersion = "2.6.1"
ciBuild = System.getenv("CI") == "true"
shotTest = System.getenv("SHOT_TEST") == "true"
}
}

View File

@ -73,7 +73,7 @@ fi
if [[ $4 = "all" ]]; then
scripts/runAllScreenshotCombinations "noCI" "$1" "-Pandroid.testInstrumentationRunnerArguments.class=$class$method"
else
./gradlew --offline gplayDebugExecuteScreenshotTests $record \
SHOT_TEST=true ./gradlew --offline gplayDebugExecuteScreenshotTests $record \
-Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED" \
-Pscreenshot=true \
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \