chromium/media/formats/hls/multivariant_playlist_test_builder.h

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

#ifndef MEDIA_FORMATS_HLS_MULTIVARIANT_PLAYLIST_TEST_BUILDER_H_
#define MEDIA_FORMATS_HLS_MULTIVARIANT_PLAYLIST_TEST_BUILDER_H_

#include <string>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "media/formats/hls/audio_rendition.h"
#include "media/formats/hls/multivariant_playlist.h"
#include "media/formats/hls/playlist_test_builder.h"
#include "media/formats/hls/types.h"
#include "media/formats/hls/variant_stream.h"

namespace media::hls {

// Helper for building multivariant playlist test cases that allows writing
// assertions next to the playlist lines they check, as well as "forking" test
// cases via copying the builder.
class MultivariantPlaylistTestBuilder
    : public PlaylistTestBuilder<MultivariantPlaylist> {};

// Checks that the latest variant has the given primary rendition URI.
inline void HasPrimaryRenditionUri(const GURL& uri,
                                   const base::Location& from,
                                   const VariantStream& variant) {}

// Checks the value of `GetBandwidth` on the latest variant against the given
// value.
inline void HasBandwidth(types::DecimalInteger bandwidth,
                         const base::Location& from,
                         const VariantStream& variant) {}

// Checks the value of `GetAverageBandwidth` on the latest variant against the
// given value.
inline void HasAverageBandwidth(
    std::optional<types::DecimalInteger> average_bandwidth,
    const base::Location& from,
    const VariantStream& variant) {}

// Checks the value of `GetScore` on the latest variant against the given value.
inline void HasScore(std::optional<types::DecimalFloatingPoint> score,
                     const base::Location& from,
                     const VariantStream& variant) {}

// Checks the value of `GetCodecs` on the latest variant against the given
// value.
inline void HasCodecs(std::optional<std::vector<std::string>> codecs,
                      const base::Location& from,
                      const VariantStream& variant) {}

// Checks the value of `GetResolution` on the latest variant against the given
// value.
inline void HasResolution(std::optional<types::DecimalResolution> resolution,
                          const base::Location& from,
                          const VariantStream& variant) {}

// Checks the value of `GetFrameRate` on the latest variant against the given
// value.
inline void HasFrameRate(std::optional<types::DecimalFloatingPoint> frame_rate,
                         const base::Location& from,
                         const VariantStream& variant) {}

// Checks that the audio rendition group associated with the latest variant has
// the given `group_id`.
inline void HasAudioRenditionGroup(std::optional<std::string> group_id,
                                   const base::Location& from,
                                   const VariantStream& variant) {}

// Checks that the audio rendition has the given URI.
inline void RenditionHasUri(std::optional<GURL> uri,
                            const base::Location& from,
                            const AudioRendition& rendition) {}

// Checks that the audio rendition has the given language.
inline void HasLanguage(std::optional<std::string> language,
                        const base::Location& from,
                        const AudioRendition& rendition) {}

// Checks that the audio rendition has the given associated language.
inline void HasAssociatedLanguage(std::optional<std::string> language,
                                  const base::Location& from,
                                  const AudioRendition& rendition) {}

// Checks that the audio rendition has the given StableId.
inline void HasStableRenditionId(std::optional<types::StableId> id,
                                 const base::Location& from,
                                 const AudioRendition& rendition) {}

// Checks that the audio rendition may be autoselected (AUTOSELECT=YES or
// DEFAULT=YES).
inline void MayAutoSelect(bool value,
                          const base::Location& from,
                          const AudioRendition& rendition) {}

// Checks that the audio rendition group has a default rendition with the given
// name (or `std::nullopt` for no default rendition).
inline void HasDefaultRendition(std::optional<std::string> name,
                                const base::Location& from,
                                const AudioRenditionGroup& group) {}

}  // namespace media::hls

#endif  // MEDIA_FORMATS_HLS_MULTIVARIANT_PLAYLIST_TEST_BUILDER_H_