chromium/third_party/perfetto/src/protozero/proto_decoder_unittest.cc

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "perfetto/protozero/proto_decoder.h"

#include "perfetto/ext/base/utils.h"
#include "perfetto/protozero/message.h"
#include "perfetto/protozero/proto_utils.h"
#include "perfetto/protozero/scattered_heap_buffer.h"
#include "perfetto/protozero/static_buffer.h"
#include "test/gtest_and_gmock.h"

#include "src/protozero/test/example_proto/test_messages.pb.h"
#include "src/protozero/test/example_proto/test_messages.pbzero.h"

// Generated by the protozero plugin.
namespace pbtest = protozero::test::protos::pbzero;

// Generated by the official protobuf compiler.
namespace pbgold = protozero::test::protos;

namespace protozero {
namespace {

_;
ElementsAre;
InSequence;
Invoke;
usingnamespaceproto_utils;

TEST(ProtoDecoderTest, ReadString) {}

TEST(ProtoDecoderTest, SkipVeryLargeFields) {}

TEST(ProtoDecoderTest, SingleRepeatedField) {}

TEST(ProtoDecoderTest, RepeatedVariableLengthField) {}

TEST(ProtoDecoderTest, SingleRepeatedFieldWithExpansion) {}

TEST(ProtoDecoderTest, NoRepeatedField) {}

TEST(ProtoDecoderTest, RepeatedFields) {}

TEST(ProtoDecoderTest, FixedData) {}

TEST(ProtoDecoderTest, FindField) {}

TEST(ProtoDecoderTest, MoveTypedDecoder) {}

TEST(ProtoDecoderTest, PackedRepeatedVarint) {}

TEST(ProtoDecoderTest, PackedRepeatedFixed32) {}

TEST(ProtoDecoderTest, PackedRepeatedFixed64) {}

TEST(ProtoDecoderTest, ZeroLengthPackedRepeatedField) {}

TEST(ProtoDecoderTest, MalformedPackedFixedBuffer) {}

TEST(ProtoDecoderTest, MalformedPackedVarIntBuffer) {}

// Tests that:
// 1. Very big field ids (>= 2**24) are just skipped but don't fail parsing.
//    This is a regression test for b/145339282 (DataSourceConfig.for_testing
//    having a very large ID == 268435455 until Android R).
// 2. Moderately big" field ids can be parsed correctly. See also
//    https://github.com/google/perfetto/issues/510 .
TEST(ProtoDecoderTest, BigFieldIds) {}

// Edge case for SkipBigFieldIds, the message contains only one field with a
// very big id. Test that we skip it and return an invalid field, instead of
// geetting stuck in some loop.
TEST(ProtoDecoderTest, OneBigFieldIdOnly) {}

// Check what happens when trying to parse packed repeated field and finding a
// mismatching wire type instead. A compliant protobuf decoder should accept it,
// but protozero doesn't handle that. At least it shouldn't crash.
TEST(ProtoDecoderTest, PacketRepeatedWireTypeMismatch) {}

TEST(ProtoDecoderTest, RepeatedMaxFieldIdStack) {}

}  // namespace
}  // namespace protozero