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

Unified Diff: chrome/common/extensions/api/common_extension_api_unittest.cc

Issue 2150193002: [Extensions] Add a SimpleFeature::Validate function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Istiaque's Created 4 years, 5 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 | « no previous file | extensions/common/features/api_feature.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/common_extension_api_unittest.cc
diff --git a/chrome/common/extensions/api/common_extension_api_unittest.cc b/chrome/common/extensions/api/common_extension_api_unittest.cc
index edcb0b37c76c747d645bbf6873ad59e00e246da1..e16ecdf8de638f2e17010178230794498bec875f 100644
--- a/chrome/common/extensions/api/common_extension_api_unittest.cc
+++ b/chrome/common/extensions/api/common_extension_api_unittest.cc
@@ -676,36 +676,16 @@ TEST(ExtensionAPITest, DefaultConfigurationFeatures) {
}
}
-TEST(ExtensionAPITest, FeaturesRequireContexts) {
- // TODO(cduvall): Make this check API featues.
- std::unique_ptr<base::DictionaryValue> api_features1(
+TEST(ExtensionAPITest, JSONFeatureProviderDoesNotStoreInvalidFeatures) {
+ base::DictionaryValue features;
+ std::unique_ptr<base::DictionaryValue> feature_value(
new base::DictionaryValue());
- std::unique_ptr<base::DictionaryValue> api_features2(
- new base::DictionaryValue());
- base::DictionaryValue* test1 = new base::DictionaryValue();
- base::DictionaryValue* test2 = new base::DictionaryValue();
- base::ListValue* contexts = new base::ListValue();
- contexts->AppendString("content_script");
- test1->Set("contexts", contexts);
- test1->SetString("channel", "stable");
- test2->SetString("channel", "stable");
- api_features1->Set("test", test1);
- api_features2->Set("test", test2);
-
- struct {
- base::DictionaryValue* api_features;
- bool expect_success;
- } test_data[] = {
- { api_features1.get(), true },
- { api_features2.get(), false }
- };
-
- for (size_t i = 0; i < arraysize(test_data); ++i) {
- JSONFeatureProvider api_feature_provider(*test_data[i].api_features,
- CreateAPIFeature);
- Feature* feature = api_feature_provider.GetFeature("test");
- EXPECT_EQ(test_data[i].expect_success, feature != NULL) << i;
- }
+ // This feature is invalid (it needs an extension context), so the
+ // JSONFeatureProvider should not store it.
+ feature_value->SetString("channel", "stable");
+ features.Set("test", std::move(feature_value));
+ JSONFeatureProvider api_feature_provider(features, CreateAPIFeature);
+ EXPECT_FALSE(api_feature_provider.GetFeature("test"));
}
static void GetDictionaryFromList(const base::DictionaryValue* schema,
« no previous file with comments | « no previous file | extensions/common/features/api_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698