#include "src/trace_redaction/collect_frame_cookies.h"
#include "perfetto/ext/base/status_or.h"
#include "src/base/test/status_matchers.h"
#include "test/gtest_and_gmock.h"
#include "protos/perfetto/trace/android/frame_timeline_event.gen.h"
#include "protos/perfetto/trace/trace_packet.gen.h"
#include "protos/perfetto/trace/trace_packet.pbzero.h"
namespace perfetto::trace_redaction {
namespace {
constexpr uint64_t kTimeStep = …;
constexpr uint64_t kTimestampA = …;
constexpr uint64_t kTimestampB = …;
constexpr uint64_t kTimestampC = …;
constexpr uint64_t kTimestampD = …;
constexpr uint64_t kTimestampE = …;
constexpr int64_t kCookieA = …;
constexpr int64_t kCookieB = …;
constexpr uint64_t kUidA = …;
constexpr int32_t kPidNone = …;
constexpr int32_t kPidA = …;
enum class FrameCookieType { … };
protos::gen::TracePacket CreateExpectedSurfaceFrameStart(uint64_t ts,
int32_t pid,
int64_t cookie) { … }
protos::gen::TracePacket CreateActualSurfaceFrameStart(uint64_t ts,
int32_t pid,
int64_t cookie) { … }
protos::gen::TracePacket CreateExpectedDisplayFrameStart(uint64_t ts,
int32_t pid,
int64_t cookie) { … }
protos::gen::TracePacket CreateActualDisplayFrameStart(uint64_t ts,
int32_t pid,
int64_t cookie) { … }
protos::gen::TracePacket CreateFrameEnd(uint64_t ts, int64_t cookie) { … }
protos::gen::TracePacket CreateStartPacket(FrameCookieType type,
uint64_t ts,
int32_t pid,
int64_t cookie) { … }
void CollectCookies(const std::string& packet, Context* context) { … }
class FrameCookieTest : public testing::Test { … };
TEST_F(FrameCookieTest, ExtractsExpectedSurfaceFrameStart) { … }
TEST_F(FrameCookieTest, ExtractsActualSurfaceFrameStart) { … }
TEST_F(FrameCookieTest, ExtractsExpectedDisplayFrameStart) { … }
TEST_F(FrameCookieTest, ExtractsActualDisplayFrameStart) { … }
TEST_F(FrameCookieTest, IgnoresFrameEnd) { … }
class ReduceFrameCookiesTest
: public testing::Test,
public testing::WithParamInterface<FrameCookieType> { … };
TEST_P(ReduceFrameCookiesTest, RejectBeforeStart) { … }
TEST_P(ReduceFrameCookiesTest, AcceptAtStart) { … }
TEST_P(ReduceFrameCookiesTest, AcceptBetweenStartAndEnd) { … }
TEST_P(ReduceFrameCookiesTest, AcceptAtEnd) { … }
TEST_P(ReduceFrameCookiesTest, RejectAfterEnd) { … }
INSTANTIATE_TEST_SUITE_P(…);
class TransformStartCookiesTest
: public testing::Test,
public testing::WithParamInterface<FrameCookieType> { … };
TEST_P(TransformStartCookiesTest, RetainStartEvent) { … }
TEST_P(TransformStartCookiesTest, DropStartEvent) { … }
INSTANTIATE_TEST_SUITE_P(…);
class TransformEndFrameCookiesTest : public testing::Test { … };
TEST_F(TransformStartCookiesTest, Retain) { … }
TEST_F(TransformStartCookiesTest, Drop) { … }
}
}