mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add test for usePlatformDiagnostics
disabled
PiperOrigin-RevId: 728276994 (cherry picked from commit 90844f11e88ad9dbb26c7fd4bd72d99c577b9c54)
This commit is contained in:
parent
d880ab5d4f
commit
e393587787
@ -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.JPG_ASSET;
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
|
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.assumeFormatsSupported;
|
import static androidx.media3.transformer.AndroidTestUtil.assumeFormatsSupported;
|
||||||
|
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
@ -44,6 +45,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import org.junit.AssumptionViolatedException;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -69,6 +71,30 @@ public class EditingMetricsCollectorTest {
|
|||||||
testId = testName.getMethodName();
|
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
|
@Test
|
||||||
public void exportSuccess_populatesEditingEndedEvent() throws Exception {
|
public void exportSuccess_populatesEditingEndedEvent() throws Exception {
|
||||||
assumeTrue("Reporting metrics requires API 35", Util.SDK_INT >= 35);
|
assumeTrue("Reporting metrics requires API 35", Util.SDK_INT >= 35);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user