Merge "Skiping view capture collection in Launcher3 tests to avoid hidden API check exception." into udc-qpr-dev

This commit is contained in:
Vadim Tryshev
2023-09-06 17:38:50 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 1 deletions

View File

@@ -103,7 +103,8 @@ public class FailureWatcher extends TestWatcher {
if (viewCaptureDataSupplier != null) {
out.putNextEntry(new ZipEntry("FS/data/misc/wmtrace/failed_test.vc"));
viewCaptureDataSupplier.get().writeTo(out);
final ExportedData exportedData = viewCaptureDataSupplier.get();
if (exportedData != null) exportedData.writeTo(out);
out.closeEntry();
}
} catch (Exception ignored) {

View File

@@ -20,6 +20,7 @@ import android.app.Application
import android.media.permission.SafeCloseable
import android.os.Bundle
import androidx.test.core.app.ApplicationProvider
import androidx.test.platform.app.InstrumentationRegistry
import com.android.app.viewcapture.SimpleViewCapture
import com.android.app.viewcapture.ViewCapture.MAIN_EXECUTOR
import com.android.app.viewcapture.data.ExportedData
@@ -50,6 +51,13 @@ class ViewCaptureRule(var alreadyOpenActivitySupplier: Supplier<Activity?>) : Te
private set
override fun apply(base: Statement, description: Description): Statement {
// Skip view capture collection in Launcher3 tests to avoid hidden API check exception.
if (
"com.android.launcher3.tests" ==
InstrumentationRegistry.getInstrumentation().context.packageName
)
return base
return object : Statement() {
override fun evaluate() {
viewCaptureData = null