| Index: tools/json_schema_compiler/test/idl_schemas_unittest.cc
|
| diff --git a/tools/json_schema_compiler/test/idl_schemas_unittest.cc b/tools/json_schema_compiler/test/idl_schemas_unittest.cc
|
| index 2599d9e846ce36d04dfac6bed39956da875e6f6c..037983b61eb7822cc460f561270ba9298153bd0a 100644
|
| --- a/tools/json_schema_compiler/test/idl_schemas_unittest.cc
|
| +++ b/tools/json_schema_compiler/test/idl_schemas_unittest.cc
|
| @@ -205,3 +205,50 @@ TEST(IdlCompiler, ObjectTypes) {
|
| EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp));
|
| EXPECT_EQ("world", tmp);
|
| }
|
| +
|
| +TEST(IdlCompiler, Enums) {
|
| + using test::api::idl_basics::MyType3;
|
| + using test::api::idl_basics::EnumClass;
|
| + using test::api::idl_basics::EnumClassWithPrefix;
|
| +
|
| + MyType3 a;
|
| + EXPECT_EQ(a.w, test::api::idl_basics::ENUM_TYPE_NONE);
|
| +
|
| + // The type name is always used as the prefix for NONE/LAST to avoid symbol
|
| + // conflicts with types that share a prefix.
|
| + EXPECT_EQ(a.x, test::api::idl_basics::ENUM_WITH_PREFIX_NONE);
|
| + EXPECT_EQ(a.y, EnumClass::NONE);
|
| +
|
| + // Symbol conflicts aren't possible with enum classes, so we just use NONE.
|
| + EXPECT_EQ(a.z, EnumClassWithPrefix::NONE);
|
| +
|
| + a.w = test::api::idl_basics::ENUM_TYPE_NAME2;
|
| + a.x = test::api::idl_basics::PREFIX_NAME2;
|
| + a.y = EnumClass::NAME2;
|
| + a.z = EnumClassWithPrefix::PREFIX_NAME2;
|
| +
|
| + std::unique_ptr<base::DictionaryValue> serialized = a.ToValue();
|
| + MyType3 b;
|
| + EXPECT_TRUE(MyType3::Populate(*serialized.get(), &b));
|
| + EXPECT_EQ(a.w, b.w);
|
| + EXPECT_EQ(a.x, b.x);
|
| + EXPECT_EQ(a.y, b.y);
|
| + EXPECT_EQ(a.z, b.z);
|
| +
|
| + base::Value* v;
|
| + std::string w, x, y, z;
|
| + EXPECT_TRUE(serialized->Get("w", &v));
|
| + EXPECT_TRUE(v->GetAsString(&w));
|
| + EXPECT_TRUE(serialized->Get("x", &v));
|
| + EXPECT_TRUE(v->GetAsString(&x));
|
| + EXPECT_TRUE(serialized->Get("y", &v));
|
| + EXPECT_TRUE(v->GetAsString(&y));
|
| + EXPECT_TRUE(serialized->Get("z", &v));
|
| + EXPECT_TRUE(v->GetAsString(&z));
|
| +
|
| + // Only the C++ syntax should be affected, so the string representations
|
| + // should all match.
|
| + EXPECT_EQ(w, x);
|
| + EXPECT_EQ(x, y);
|
| + EXPECT_EQ(y, z);
|
| +}
|
|
|