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

Unified Diff: extensions/common/features/feature_provider_unittest.cc

Issue 2950353004: [Extensions Bindings] Check availability of custom API properties (Closed)
Patch Set: . Created 3 years, 6 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: 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

Powered by Google App Engine
This is Rietveld 408576698