Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: mojo/public/cpp/bindings/tests/type_conversion_unittest.cc

Issue 2689513003: Add field-initializing constructors to generated mojo structs. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
index 53abdff9554d4d9d68c47f97375d0e9dd3a63bf0..b0124aa0e229907819339e79f7e8b6e31c643fa3 100644
--- a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
@@ -44,12 +44,8 @@ bool AreEqualRectArrays(const std::vector<test::RectPtr>& rects1,
template <>
struct TypeConverter<test::RectPtr, RedmondRect> {
static test::RectPtr Convert(const RedmondRect& input) {
- test::RectPtr rect(test::Rect::New());
- rect->x = input.left;
- rect->y = input.top;
- rect->width = input.right - input.left;
- rect->height = input.bottom - input.top;
- return rect;
+ return test::Rect::New(input.left, input.top, input.right - input.left,
+ input.bottom - input.top);
}
};
@@ -68,10 +64,8 @@ struct TypeConverter<RedmondRect, test::RectPtr> {
template <>
struct TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> {
static test::NamedRegionPtr Convert(const RedmondNamedRegion& input) {
- test::NamedRegionPtr region(test::NamedRegion::New());
- region->name.emplace(input.name);
- region->rects = ConvertTo<std::vector<test::RectPtr>>(input.rects);
- return region;
+ return test::NamedRegion::New(
+ input.name, ConvertTo<std::vector<test::RectPtr>>(input.rects));
}
};
@@ -94,11 +88,7 @@ namespace test {
namespace {
TEST(TypeConversionTest, CustomTypeConverter) {
- RectPtr rect(Rect::New());
- rect->x = 10;
- rect->y = 20;
- rect->width = 50;
- rect->height = 45;
+ RectPtr rect(Rect::New(10, 20, 50, 45));
RedmondRect rr = rect.To<RedmondRect>();
EXPECT_EQ(10, rr.left);
« no previous file with comments | « mojo/public/cpp/bindings/tests/test_native_types_chromium.typemap ('k') | mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698