Verifying that ViewCapture data is not empty

Flag: N/A
Test: presubmit
Bug: 286251603
Change-Id: I45b6f858cfa13a12203a61ee80ac2e7988360d58
This commit is contained in:
Vadim Tryshev
2023-07-24 10:32:53 -07:00
parent 101ea3e4e5
commit aa79bd9a07
@@ -23,8 +23,10 @@ import androidx.test.core.app.ApplicationProvider
import com.android.app.viewcapture.SimpleViewCapture
import com.android.app.viewcapture.ViewCapture.MAIN_EXECUTOR
import com.android.app.viewcapture.data.ExportedData
import com.android.launcher3.tapl.TestHelpers
import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter
import com.android.launcher3.util.viewcapture_analysis.ViewCaptureAnalyzer
import org.junit.Assert.assertTrue
import java.util.function.Supplier
import org.junit.rules.TestRule
import org.junit.runner.Description
@@ -79,7 +81,7 @@ class ViewCaptureRule(var alreadyOpenActivitySupplier: Supplier<Activity?>) : Te
MAIN_EXECUTOR.execute { windowListenerCloseables.onEach(SafeCloseable::close) }
}
ViewCaptureAnalyzer.assertNoAnomalies(viewCaptureData)
analyzeViewCapture()
}
private fun startCapturingExistingActivity(
@@ -104,4 +106,17 @@ class ViewCaptureRule(var alreadyOpenActivitySupplier: Supplier<Activity?>) : Te
}
}
}
private fun analyzeViewCapture() {
// OOP tests don't produce ViewCapture data
if (!TestHelpers.isInLauncherProcess()) return
ViewCaptureAnalyzer.assertNoAnomalies(viewCaptureData)
var frameCount = 0
for (i in 0 until viewCaptureData!!.windowDataCount) {
frameCount += viewCaptureData!!.getWindowData(i).frameDataCount
}
assertTrue("Empty ViewCapture data", frameCount > 0)
}
}