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 2945383002: [Extensions] Fix FeatureProvider::GetChildren() (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
« no previous file with comments | « extensions/common/features/feature_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bc019e3f2280d4e706cf6e4d7196532991f26b72..2bf161f4291e12c720f1823f736a4c9043d41aff 100644
--- a/extensions/common/features/feature_provider_unittest.cc
+++ b/extensions/common/features/feature_provider_unittest.cc
@@ -9,12 +9,14 @@
#include <string>
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/manifest.h"
#include "extensions/common/value_builder.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -150,4 +152,32 @@ TEST(FeatureProviderTest, PermissionFeatureAvailability) {
.result());
}
+TEST(FeatureProviderTest, GetChildren) {
+ 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);
+
+ Feature* parent = provider.GetFeature("parent");
+ ASSERT_TRUE(parent);
+ std::vector<Feature*> children = provider.GetChildren(*parent);
+ std::set<std::string> children_names;
+ for (const Feature* child : children)
+ children_names.insert(child->name());
+ EXPECT_THAT(children_names, testing::UnorderedElementsAre(
+ "parent.child", "parent.child.grandchild",
+ "parent.other_child.other_grandchild"));
+}
+
} // namespace extensions
« no previous file with comments | « extensions/common/features/feature_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698