#include "net/shared_dictionary/shared_dictionary_header_checker_source_stream.h"
#include <memory>
#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/strings/cstring_view.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/filter/mock_source_stream.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
Type;
static constexpr SHA256HashValue kTestHash = …;
static constexpr unsigned char kBrotliSignature[] = …;
static constexpr unsigned char kWrongBrotliSignature[] = …;
static constexpr unsigned char kBrotliSignatureAndHash[] = …;
static constexpr base::span<const unsigned char> kTooSmallBrotliHeader = …;
static constexpr unsigned char kZstdSignature[] = …;
static constexpr unsigned char kWrongZstdSignature[] = …;
static constexpr unsigned char kZstdSignatureAndHash[] = …;
static constexpr base::span<const unsigned char> kTooSmallZstdHeader = …;
constexpr size_t kOutputBufferSize = …;
constexpr base::cstring_view kTestBodyData = …;
}
class SharedDictionaryHeaderCheckerSourceStreamTest
: public ::testing::TestWithParam<Type> { … };
std::string ToString(Type type) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, Description) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, MayHaveMoreBytes) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, SyncReadError) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, AsyncReadError) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, EmptyStreamSyncComplete) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest,
EmptyStreamAsyncCompleteBeforeRead) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest,
EmptyStreamAsyncCompleteAfterRead) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest,
TooSmallHeaderSyncDataSyncComplete) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest,
TooSmallHeaderSyncDataAsyncCompleteBeforeRead) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest,
TooSmallHeaderSyncDataAsyncCompleteAfterRead) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, HeaderSync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, HeaderSplittedSync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, HeaderAsync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, HeaderSplittedAsync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, WrongSinatureSync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, WrongSinatureAsync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, WrongHashSync) { … }
TEST_P(SharedDictionaryHeaderCheckerSourceStreamTest, WrongHashAsync) { … }
}