### Question:
ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHolder> { public final synchronized void clear() { removeMediaSourceRange(0, getSize()); } ConcatenatingMediaSource(MediaSource... mediaSources);  ConcatenatingMediaSource(boolean isAtomic, MediaSource... mediaSources);  ConcatenatingMediaSource(
      boolean isAtomic, ShuffleOrder shuffleOrder, MediaSource... mediaSources); @SuppressWarnings("initialization")  ConcatenatingMediaSource(
      boolean isAtomic,
      boolean useLazyPreparation,
      ShuffleOrder shuffleOrder,
      MediaSource... mediaSources); final synchronized void addMediaSource(MediaSource mediaSource); final synchronized void addMediaSource(
      MediaSource mediaSource, Handler handler, Runnable onCompletionAction); final synchronized void addMediaSource(int index, MediaSource mediaSource); final synchronized void addMediaSource(
      int index, MediaSource mediaSource, Handler handler, Runnable onCompletionAction); final synchronized void addMediaSources(Collection<MediaSource> mediaSources); final synchronized void addMediaSources(
      Collection<MediaSource> mediaSources, Handler handler, Runnable onCompletionAction); final synchronized void addMediaSources(int index, Collection<MediaSource> mediaSources); final synchronized void addMediaSources(
      int index,
      Collection<MediaSource> mediaSources,
      Handler handler,
      Runnable onCompletionAction); final synchronized void removeMediaSource(int index); final synchronized void removeMediaSource(
      int index, Handler handler, Runnable onCompletionAction); final synchronized void removeMediaSourceRange(int fromIndex, int toIndex); final synchronized void removeMediaSourceRange(
      int fromIndex, int toIndex, Handler handler, Runnable onCompletionAction); final synchronized void moveMediaSource(int currentIndex, int newIndex); final synchronized void moveMediaSource(
      int currentIndex, int newIndex, Handler handler, Runnable onCompletionAction); final synchronized void clear(); final synchronized void clear(Handler handler, Runnable onCompletionAction); final synchronized int getSize(); final synchronized MediaSource getMediaSource(int index); final synchronized void setShuffleOrder(ShuffleOrder shuffleOrder); final synchronized void setShuffleOrder(
      ShuffleOrder shuffleOrder, Handler handler, Runnable onCompletionAction); @Override @Nullable Object getTag(); @Override final synchronized void prepareSourceInternal(
      @Nullable TransferListener mediaTransferListener); @Override @SuppressWarnings("MissingSuperCall") void maybeThrowSourceInfoRefreshError(); @Override final MediaPeriod createPeriod(
      MediaPeriodId id, Allocator allocator, long startPositionUs); @Override final void releasePeriod(MediaPeriod mediaPeriod); @Override final synchronized void releaseSourceInternal();  }### Answer:
@Test public void testClear() throws IOException { DummyMainThread dummyMainThread = new DummyMainThread(); final FakeMediaSource preparedChildSource = createFakeMediaSource(); final FakeMediaSource unpreparedChildSource = new FakeMediaSource( null, null); dummyMainThread.runOnMainThread( () -> { mediaSource.addMediaSource(preparedChildSource); mediaSource.addMediaSource(unpreparedChildSource); }); testRunner.prepareSource(); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); dummyMainThread.runOnMainThread(() -> mediaSource.clear(new Handler(), timelineGrabber)); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); assertThat(timeline.isEmpty()).isTrue(); preparedChildSource.assertReleased(); unpreparedChildSource.assertReleased(); }