chromium/mojo/public/cpp/bindings/tests/validation_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_math.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "mojo/public/c/system/macros.h"
#include "mojo/public/cpp/bindings/connector.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/message_dispatcher.h"
#include "mojo/public/cpp/bindings/message_header_validator.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h"
#include "mojo/public/cpp/system/message.h"
#include "mojo/public/cpp/test_support/test_support.h"
#include "mojo/public/interfaces/bindings/tests/validation_test_associated_interfaces.mojom.h"
#include "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace mojo {
namespace test {
namespace {

Message CreateRawMessage(size_t size) {}

template <typename T>
void Append(std::vector<uint8_t>* data_vector, T data) {}

bool TestInputParser(const std::string& input,
                     bool expected_result,
                     const std::vector<uint8_t>& expected_data,
                     size_t expected_num_handles) {}

std::vector<std::string> GetMatchingTests(const std::vector<std::string>& names,
                                          const std::string& prefix) {}

bool ReadFile(const std::string& path, std::string* result) {}

bool ReadAndParseDataFile(const std::string& path,
                          std::vector<uint8_t>* data,
                          size_t* num_handles) {}

bool ReadResultFile(const std::string& path, std::string* result) {}

std::string GetPath(const std::string& root, const std::string& suffix) {}

// |message| should be a newly created object.
bool ReadTestCase(const std::string& test,
                  Message* message,
                  std::string* expected) {}

void RunValidationTests(const std::string& prefix,
                        MessageReceiver* test_message_receiver) {}

class TwoStepValidator : public MessageReceiver {};

class DummyMessageReceiver : public MessageReceiver {};

class ValidationTest : public testing::Test {};

class ValidationIntegrationTest : public ValidationTest {};

class IntegrationTestInterfaceImpl : public IntegrationTestInterface {};

TEST_F(ValidationTest, InputParser) {}

TEST_F(ValidationTest, Conformance) {}

TEST_F(ValidationTest, AssociatedConformace) {}

// This test is similar to Conformance test but its goal is specifically
// do bounds-check testing of message validation. For example we test the
// detection of off-by-one errors in method ordinals.
TEST_F(ValidationTest, BoundsCheck) {}

// This test is similar to the Conformance test but for responses.
TEST_F(ValidationTest, ResponseConformance) {}

// This test is similar to the BoundsCheck test but for responses.
TEST_F(ValidationTest, ResponseBoundsCheck) {}

// Test that Remote<X> applies the correct validators and they don't conflict
// with each other:
//   - MessageHeaderValidator
//   - X::ResponseValidator_
TEST_F(ValidationIntegrationTest, Remote) {}

// Test that Receiver<X> applies the correct validators and they don't conflict
// with each other:
//   - MessageHeaderValidator
//   - X::RequestValidator_
TEST_F(ValidationIntegrationTest, Receiver) {}

// Test pointer validation (specifically, that the encoded offset is 32-bit)
TEST_F(ValidationTest, ValidateEncodedPointer) {}

// Tests the IsKnownEnumValue() function generated for BasicEnum.
TEST(EnumValueValidationTest, BasicEnum) {}

// Tests the IsKnownEnumValue() method generated for StructWithEnum.
TEST(EnumValueValidationTest, EnumWithin) {}

}  // namespace
}  // namespace test
}  // namespace mojo