mirror of
https://github.com/androidx/media.git
synced 2025-04-29 22:36:54 +08:00
Add test for usePlatformDiagnostics
disabled
PiperOrigin-RevId: 728276994
This commit is contained in:
parent
f1c62c1239
commit
90844f11e8
@ -19,6 +19,7 @@ import static androidx.media3.common.util.Util.usToMs;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.JPG_ASSET;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.assumeFormatsSupported;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@ -44,6 +45,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.AssumptionViolatedException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@ -69,6 +71,30 @@ public class EditingMetricsCollectorTest {
|
||||
testId = testName.getMethodName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void export_usePlatformDiagnosticsDisabled_doesNotCollectMetrics() throws Exception {
|
||||
if (Util.SDK_INT < 35) {
|
||||
String reason = "Metrics collection is unsupported below API 35.";
|
||||
recordTestSkipped(context, testId, reason);
|
||||
throw new AssumptionViolatedException(reason);
|
||||
}
|
||||
AtomicReference<EditingEndedEvent> editingEndedEventAtomicReference = new AtomicReference<>();
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setUsePlatformDiagnostics(false)
|
||||
.setMetricsReporterFactory(
|
||||
new TestMetricsReporterFactory(context, editingEndedEventAtomicReference::set))
|
||||
.build();
|
||||
EditedMediaItem audioVideoItem =
|
||||
new EditedMediaItem.Builder(MediaItem.fromUri(MP4_ASSET.uri)).build();
|
||||
|
||||
new TransformerAndroidTestRunner.Builder(context, transformer)
|
||||
.build()
|
||||
.run(testId, audioVideoItem);
|
||||
|
||||
assertThat(editingEndedEventAtomicReference.get()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportSuccess_populatesEditingEndedEvent() throws Exception {
|
||||
assumeTrue("Reporting metrics requires API 35", Util.SDK_INT >= 35);
|
||||
|
Loading…
x
Reference in New Issue
Block a user