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

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

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 8f8b469959c4641b81582ddf280b61f1a007403d..36cce4f71ed278f7d4ff1a69813ce509589c528d 100644
--- a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
@@ -41,11 +41,11 @@ FooPtr MakeFoo() {
bar->alpha = 20;
bar->beta = 40;
bar->gamma = 60;
- bar->type = Bar::TYPE_VERTICAL;
+ bar->type = Bar::Type::VERTICAL;
mojo::Array<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;
+ 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;
@@ -122,12 +122,12 @@ void CheckFoo(const Foo& foo) {
EXPECT_EQ(20, foo.bar->alpha);
EXPECT_EQ(40, foo.bar->beta);
EXPECT_EQ(60, foo.bar->gamma);
- EXPECT_EQ(Bar::TYPE_VERTICAL, foo.bar->type);
+ EXPECT_EQ(Bar::Type::VERTICAL, foo.bar->type);
EXPECT_EQ(3u, foo.extra_bars.size());
for (size_t i = 0; i < foo.extra_bars.size(); i++) {
uint8_t base = static_cast<uint8_t>(i * 100);
- Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL;
+ Bar::Type type = i % 2 == 0 ? Bar::Type::VERTICAL : Bar::Type::HORIZONTAL;
EXPECT_EQ(base, foo.extra_bars[i]->alpha) << i;
EXPECT_EQ(base + 20, foo.extra_bars[i]->beta) << i;
EXPECT_EQ(base + 40, foo.extra_bars[i]->gamma) << i;
@@ -266,7 +266,7 @@ class ServiceImpl : public Service {
EXPECT_FALSE(foo.is_null());
if (!foo.is_null())
CheckFoo(*foo);
- EXPECT_EQ(BAZ_OPTIONS_EXTRA, baz);
+ EXPECT_EQ(Service::BazOptions::EXTRA, baz);
if (g_dump_message_as_text) {
// Also dump the Foo structure and all of its members.
@@ -340,7 +340,7 @@ TEST_F(BindingsSampleTest, Basic) {
CheckFoo(*foo);
PortPtr port;
- service->Frobinate(foo.Pass(), Service::BAZ_OPTIONS_EXTRA, port.Pass(),
+ service->Frobinate(foo.Pass(), Service::BazOptions::EXTRA, port.Pass(),
Service::FrobinateCallback());
delete service;
@@ -368,11 +368,11 @@ TEST_F(BindingsSampleTest, DefaultValues) {
EXPECT_DOUBLE_EQ(1.23E-20, defaults->a17);
EXPECT_TRUE(defaults->a18.is_null());
EXPECT_TRUE(defaults->a19.is_null());
- EXPECT_EQ(Bar::TYPE_BOTH, defaults->a20);
+ EXPECT_EQ(Bar::Type::BOTH, defaults->a20);
EXPECT_TRUE(defaults->a21.is_null());
ASSERT_FALSE(defaults->a22.is_null());
- EXPECT_EQ(imported::SHAPE_RECTANGLE, defaults->a22->shape);
- EXPECT_EQ(static_cast<int32_t>(imported::COLOR_BLACK), defaults->a22->color);
+ EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape);
+ EXPECT_EQ(static_cast<int32_t>(imported::Color::BLACK), defaults->a22->color);
EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23);
EXPECT_EQ(0x123456789, defaults->a24);
EXPECT_EQ(-0x123456789, defaults->a25);
« no previous file with comments | « mojo/public/cpp/bindings/tests/request_response_unittest.cc ('k') | mojo/public/cpp/bindings/tests/union_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698