chromium/base/test/test_proto_loader.h

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

#ifndef BASE_TEST_TEST_PROTO_LOADER_H_
#define BASE_TEST_TEST_PROTO_LOADER_H_

#include <memory>
#include <string>
#include <string_view>
#include "base/files/file_path.h"

namespace base {

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(PROTO_TEST_IMPLEMENTATION)
#define PROTO_TEST_EXPORT
#else
#define PROTO_TEST_EXPORT
#endif  // defined(PROTO_TEST_IMPLEMENTATION)

#else  // defined(WIN32)
#if defined(PROTO_TEST_IMPLEMENTATION)
#define PROTO_TEST_EXPORT
#else
#define PROTO_TEST_EXPORT
#endif
#endif
#else  // defined(COMPONENT_BUILD)
#define PROTO_TEST_EXPORT
#endif

// This class works around the fact that chrome only includes the lite runtime
// of protobufs. Lite protobufs inherit from |MessageLite| and cannot be used to
// parse from text format. Parsing from text
// format is useful in tests. We cannot include the full version of a protobuf
// in test code because it would clash with the lite version.
//
// This class uses the protobuf descriptors (generated at compile time) to
// generate a |Message| that can be used to parse from text. This message can
// then be serialized to binary which can be parsed by the |MessageLite|.
class PROTO_TEST_EXPORT TestProtoSetLoader {};

// Same as TestProtoSetLoader, but for a single message type.
class PROTO_TEST_EXPORT TestProtoLoader {};

}  // namespace base

#endif  // BASE_TEST_TEST_PROTO_LOADER_H_