#include "cast/streaming/impl/statistics_analyzer.h"
#include <cstdint>
#include <numeric>
#include "cast/streaming/public/statistics.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "platform/base/span.h"
#include "platform/test/fake_clock.h"
#include "platform/test/fake_task_runner.h"
#include "util/chrono_helpers.h"
#include "util/enum_name_table.h"
_;
AtLeast;
Invoke;
InvokeWithoutArgs;
Mock;
NiceMock;
Return;
Sequence;
StrictMock;
namespace openscreen::cast {
extern const EnumNameTable<StatisticType,
static_cast<size_t>(StatisticType::kNumTypes)>
kStatisticTypeNames;
extern const EnumNameTable<HistogramType,
static_cast<size_t>(HistogramType::kNumTypes)>
kHistogramTypeNames;
namespace {
constexpr int kDefaultStatsAnalysisIntervalMs = …;
constexpr int kDefaultNumEvents = …;
constexpr int kDefaultSizeBytes = …;
constexpr int kDefaultStatIntervalMs = …;
constexpr FrameEvent kDefaultFrameEvent(FrameId::first(),
StatisticsEventType::kFrameEncoded,
StatisticsEventMediaType::kVideo,
RtpTimeTicks(),
kDefaultSizeBytes,
Clock::time_point::min(),
Clock::time_point::min(),
640,
480,
milliseconds(20),
false,
0);
constexpr PacketEvent kDefaultPacketEvent(
FrameId::first(),
StatisticsEventType::kPacketSentToNetwork,
StatisticsEventMediaType::kVideo,
RtpTimeTicks(),
kDefaultSizeBytes,
Clock::time_point::min(),
Clock::time_point::min(),
0u,
100u);
void ExpectStatEq(SenderStats::StatisticsList stats_list,
StatisticType stat,
double expected_value) { … }
void ExpectHistoBuckets(const SenderStats::HistogramsList& actual_buckets_list,
HistogramType key,
const Span<const int> expected_buckets) { … }
class FakeSenderStatsClient : public SenderStatsClient { … };
class FakeClockOffsetEstimator : public ClockOffsetEstimator { … };
}
class StatisticsAnalyzerTest : public ::testing::Test { … };
TEST_F(StatisticsAnalyzerTest, FrameEncoded) { … }
TEST_F(StatisticsAnalyzerTest, FrameEncodedAndAckSent) { … }
TEST_F(StatisticsAnalyzerTest, FramePlayedOut) { … }
TEST_F(StatisticsAnalyzerTest, AllFrameEvents) { … }
TEST_F(StatisticsAnalyzerTest, FrameEncodedAndPacketSent) { … }
TEST_F(StatisticsAnalyzerTest, PacketSentAndReceived) { … }
TEST_F(StatisticsAnalyzerTest, FrameEncodedPacketSentAndReceived) { … }
TEST_F(StatisticsAnalyzerTest, AudioAndVideoFrameEncodedPacketSentAndReceived) { … }
TEST_F(StatisticsAnalyzerTest, LotsOfEventsStillWorksProperly) { … }
}