| Index: extensions/common/features/feature_provider_unittest.cc
|
| diff --git a/extensions/common/features/feature_provider_unittest.cc b/extensions/common/features/feature_provider_unittest.cc
|
| index 2bf161f4291e12c720f1823f736a4c9043d41aff..26d641959ca0dc0cc3c73dceb2ae81faf11d7a3d 100644
|
| --- a/extensions/common/features/feature_provider_unittest.cc
|
| +++ b/extensions/common/features/feature_provider_unittest.cc
|
| @@ -180,4 +180,41 @@ TEST(FeatureProviderTest, GetChildren) {
|
| "parent.other_child.other_grandchild"));
|
| }
|
|
|
| +TEST(FeatureProviderTest, GetParent) {
|
| + FeatureProvider provider;
|
| +
|
| + auto add_feature = [&provider](base::StringPiece name,
|
| + bool no_parent = false) {
|
| + auto feature = base::MakeUnique<SimpleFeature>();
|
| + feature->set_name(name);
|
| + feature->set_noparent(no_parent);
|
| + provider.AddFeature(name, std::move(feature));
|
| + };
|
| +
|
| + add_feature("parent");
|
| + add_feature("parent.child");
|
| + add_feature("parent.child.grandchild");
|
| + add_feature("parent.other_child.other_grandchild");
|
| + add_feature("parent.unparented_child", true);
|
| +
|
| + auto is_parent = [&provider](base::StringPiece child_name,
|
| + base::StringPiece parent_name) {
|
| + Feature* child = provider.GetFeature(child_name.as_string());
|
| + ASSERT_TRUE(child) << child_name;
|
| + Feature* parent = provider.GetParent(child);
|
| + ASSERT_TRUE(parent) << parent_name;
|
| + EXPECT_EQ(parent_name.as_string(), parent->name());
|
| + };
|
| +
|
| + is_parent("parent.child", "parent");
|
| + is_parent("parent.child.grandchild", "parent.child");
|
| + is_parent("parent.other_child.other_grandchild", "parent");
|
| +
|
| + {
|
| + Feature* no_parent = provider.GetFeature("parent.unparented_child");
|
| + ASSERT_TRUE(no_parent);
|
| + EXPECT_TRUE(no_parent->no_parent());
|
| + }
|
| +}
|
| +
|
| } // namespace extensions
|
|
|