#include <stddef.h>
#include <stdint.h>
#include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
namespace {
struct RedmondRect { … };
struct RedmondNamedRegion { … };
bool AreEqualRectArrays(const std::vector<test::RectPtr>& rects1,
const std::vector<test::RectPtr>& rects2) { … }
}
template <>
struct TypeConverter<test::RectPtr, RedmondRect> { … };
template <>
struct TypeConverter<RedmondRect, test::RectPtr> {
static RedmondRect Convert(const test::RectPtr& input) {
RedmondRect rect;
rect.left = input->x;
rect.top = input->y;
rect.right = input->x + input->width;
rect.bottom = input->y + input->height;
return rect;
}
};
template <>
struct TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> {
static test::NamedRegionPtr Convert(const RedmondNamedRegion& input) {
return test::NamedRegion::New(
input.name, ConvertTo<std::vector<test::RectPtr>>(input.rects));
}
};
template <>
struct TypeConverter<RedmondNamedRegion, test::NamedRegionPtr> {
static RedmondNamedRegion Convert(const test::NamedRegionPtr& input) {
RedmondNamedRegion region;
if (input->name)
region.name = input->name.value();
if (input->rects) {
region.rects.reserve(input->rects->size());
for (const auto& element : *input->rects)
region.rects.push_back(element.To<RedmondRect>());
}
return region;
}
};
namespace test {
namespace …