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

Unified Diff: mojo/public/cpp/bindings/tests/sample_service_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/sample_service_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
index 3415d6dfc5012eff10395601298cc9c989e1e1c2..579576fd350a9244c4253d81dac760b75a73ac10 100644
--- a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
@@ -38,22 +38,13 @@ bool g_dump_message_as_text = false;
FooPtr MakeFoo() {
std::string name("foopy");
- BarPtr bar(Bar::New());
- bar->alpha = 20;
- bar->beta = 40;
- bar->gamma = 60;
- bar->type = Bar::Type::VERTICAL;
+ BarPtr bar(Bar::New(20, 40, 60, Bar::Type::VERTICAL));
std::vector<BarPtr> extra_bars(3);
for (size_t i = 0; i < extra_bars.size(); ++i) {
Bar::Type type = i % 2 == 0 ? Bar::Type::VERTICAL : Bar::Type::HORIZONTAL;
- BarPtr bar(Bar::New());
uint8_t base = static_cast<uint8_t>(i * 100);
- bar->alpha = base;
- bar->beta = base + 20;
- bar->gamma = base + 40;
- bar->type = type;
- extra_bars[i] = std::move(bar);
+ extra_bars[i] = Bar::New(base, base + 20, base + 40, type);
}
std::vector<uint8_t> data(10);
@@ -84,22 +75,11 @@ FooPtr MakeFoo() {
}
mojo::MessagePipe pipe;
- FooPtr foo(Foo::New());
- foo->name = name;
- foo->x = 1;
- foo->y = 2;
- foo->a = false;
- foo->b = true;
- foo->c = false;
- foo->bar = std::move(bar);
- foo->extra_bars = std::move(extra_bars);
- foo->data = std::move(data);
- foo->source = std::move(pipe.handle1);
- foo->input_streams = std::move(input_streams);
- foo->output_streams = std::move(output_streams);
- foo->array_of_array_of_bools = std::move(array_of_array_of_bools);
-
- return foo;
+ return Foo::New(name, 1, 2, false, true, false, std::move(bar),
+ std::move(extra_bars), std::move(data),
+ std::move(pipe.handle1), std::move(input_streams),
+ std::move(output_streams), std::move(array_of_array_of_bools),
+ base::nullopt, base::nullopt);
}
// Check that the given |Foo| is identical to the one made by |MakeFoo()|.
« no previous file with comments | « mojo/public/cpp/bindings/tests/pickled_types_blink.h ('k') | mojo/public/cpp/bindings/tests/struct_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698