chromium/third_party/blink/renderer/platform/media/multi_buffer_data_source_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/platform/media/multi_buffer_data_source.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "base/containers/heap_array.h"
#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/mock_filters.h"
#include "media/base/mock_media_log.h"
#include "media/base/test_helpers.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_response.h"
#include "third_party/blink/renderer/platform/media/buffered_data_source_host_impl.h"
#include "third_party/blink/renderer/platform/media/multi_buffer_reader.h"
#include "third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.h"
#include "third_party/blink/renderer/platform/media/testing/mock_resource_fetch_context.h"
#include "third_party/blink/renderer/platform/media/testing/mock_web_associated_url_loader.h"
#include "third_party/blink/renderer/platform/media/testing/test_response_generator.h"

namespace blink {

_;
Assign;
Invoke;
InSequence;
NiceMock;
StrictMock;

class TestMultiBufferDataProvider;

std::set<TestMultiBufferDataProvider*> test_data_providers;

class TestMultiBufferDataProvider : public ResourceMultiBufferDataProvider {};

class TestUrlData;

class TestResourceMultiBuffer : public ResourceMultiBuffer {};

class TestUrlData : public UrlData {};

class TestUrlIndex : public UrlIndex {};

class MockBufferedDataSourceHost : public BufferedDataSourceHost {};

class MockMultiBufferDataSource : public MultiBufferDataSource {};

static const int64_t kFileSize =;
static const int64_t kFarReadPosition =;
static const int kDataSize =;

static const char kHttpUrl[] =;
static const char kFileUrl[] =;
static const char kHttpDifferentPathUrl[] =;
static const char kHttpDifferentOriginUrl[] =;

class MultiBufferDataSourceTest : public testing::Test {};

TEST_F(MultiBufferDataSourceTest, Range_Supported) {}

TEST_F(MultiBufferDataSourceTest, Range_InstanceSizeUnknown) {}

TEST_F(MultiBufferDataSourceTest, Range_NotFound) {}

TEST_F(MultiBufferDataSourceTest, Range_NotSupported) {}

TEST_F(MultiBufferDataSourceTest, Range_NotSatisfiable) {}

// Special carve-out for Apache versions that choose to return a 200 for
// Range:0- ("because it's more efficient" than a 206)
TEST_F(MultiBufferDataSourceTest, Range_SupportedButReturned200) {}

TEST_F(MultiBufferDataSourceTest, Range_MissingContentRange) {}

TEST_F(MultiBufferDataSourceTest, Range_MissingContentLength) {}

TEST_F(MultiBufferDataSourceTest, Range_WrongContentRange) {}

// Test the case where the initial response from the server indicates that
// Range requests are supported, but a later request prove otherwise.
TEST_F(MultiBufferDataSourceTest, Range_ServerLied) {}

TEST_F(MultiBufferDataSourceTest, Http_AbortWhileReading) {}

TEST_F(MultiBufferDataSourceTest, File_AbortWhileReading) {}

TEST_F(MultiBufferDataSourceTest, Http_Retry) {}

TEST_F(MultiBufferDataSourceTest, Http_RetryOnError) {}

// Make sure that we prefetch across partial responses. (crbug.com/516589)
TEST_F(MultiBufferDataSourceTest, Http_PartialResponsePrefetch) {}

TEST_F(MultiBufferDataSourceTest, Http_PartialResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_RedirectedToDifferentPathResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_RedirectedToDifferentOriginResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_ServiceWorkerGeneratedResponseAndNormalResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_ServiceWorkerProxiedAndSameURLResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_ServiceWorkerProxiedAndDifferentPathResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponse) {}

TEST_F(MultiBufferDataSourceTest,
       Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponseCors) {}

TEST_F(MultiBufferDataSourceTest, File_Retry) {}

TEST_F(MultiBufferDataSourceTest, Http_TooManyRetries) {}

TEST_F(MultiBufferDataSourceTest, File_TooManyRetries) {}

TEST_F(MultiBufferDataSourceTest, File_InstanceSizeUnknown) {}

TEST_F(MultiBufferDataSourceTest, File_Successful) {}

TEST_F(MultiBufferDataSourceTest, StopDuringRead) {}

TEST_F(MultiBufferDataSourceTest, DefaultValues) {}

TEST_F(MultiBufferDataSourceTest, SetBitrate) {}

TEST_F(MultiBufferDataSourceTest, MediaPlaybackRateChanged) {}

TEST_F(MultiBufferDataSourceTest, Http_Read) {}

TEST_F(MultiBufferDataSourceTest, Http_ShareData) {}

TEST_F(MultiBufferDataSourceTest, Http_Read_Seek) {}

TEST_F(MultiBufferDataSourceTest, File_Read) {}

TEST_F(MultiBufferDataSourceTest, Http_FinishLoading) {}

TEST_F(MultiBufferDataSourceTest, File_FinishLoading) {}

TEST_F(MultiBufferDataSourceTest, LocalResource_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest, ExternalResource_Reponse200_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response200_PreloadMetadata_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest, ExternalResource_Reponse206_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_PreloadMetadata_DeferStrategy) {}

TEST_F(MultiBufferDataSourceTest, ExternalResource_Response206_VerifyDefer) {}

TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_CancelAfterDefer) {}

// This test tries to trigger an edge case where the read callback
// never happens because the reader is deleted before that happens.
TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_CancelAfterDefer2) {}

// This test tries to trigger an edge case where the read callback
// never happens because the reader is deleted before that happens.
TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_CancelAfterDefer3) {}

TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_CancelAfterPlay) {}

// This test triggers an edge case where request destination is not
// properly set to "audio" (crbug.com/12345). The edge case is triggered when
// preload omitted or is set to metadata, and a read from an unbuffered range
// takes place.
TEST_F(MultiBufferDataSourceTest,
       ExternalResource_Response206_CheckIsClientAudioElement) {}

TEST_F(MultiBufferDataSourceTest, SeekPastEOF) {}

TEST_F(MultiBufferDataSourceTest, Http_RetryThenRedirect) {}

TEST_F(MultiBufferDataSourceTest, Http_NotStreamingAfterRedirect) {}

TEST_F(MultiBufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) {}

TEST_F(MultiBufferDataSourceTest, Http_404AfterRedirect) {}

TEST_F(MultiBufferDataSourceTest, LengthKnownAtEOF) {}

TEST_F(MultiBufferDataSourceTest, FileSizeLessThanBlockSize) {}

TEST_F(MultiBufferDataSourceTest, ResponseTypeBasic) {}

TEST_F(MultiBufferDataSourceTest, ResponseTypeCors) {}

TEST_F(MultiBufferDataSourceTest, ResponseTypeDefault) {}

TEST_F(MultiBufferDataSourceTest, ResponseTypeOpaque) {}

TEST_F(MultiBufferDataSourceTest, ResponseTypeOpaqueRedirect) {}

TEST_F(MultiBufferDataSourceTest, EtagTest) {}

TEST_F(MultiBufferDataSourceTest, CheckBufferSizes) {}

TEST_F(MultiBufferDataSourceTest, CheckBufferSizeForSmallFiles) {}

TEST_F(MultiBufferDataSourceTest, CheckBufferSizeAfterReadingALot) {}

// Provoke an edge case where the loading state may not end up transitioning
// back to "idle" when we're done loading.
TEST_F(MultiBufferDataSourceTest, Http_CheckLoadingTransition) {}

TEST_F(MultiBufferDataSourceTest, Http_Seek_Back) {}

}  // namespace blink