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

Unified Diff: extensions/common/api/declarative/declarative_manifest_unittest.cc

Issue 1158693006: Create a mechanism define declarative rules via the extension manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a manifest handler Created 5 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/api/declarative/declarative_manifest_unittest.cc
diff --git a/extensions/common/api/declarative/declarative_manifest_unittest.cc b/extensions/common/api/declarative/declarative_manifest_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..032909cb4bf0302da6580c5912843848d242aea7
--- /dev/null
+++ b/extensions/common/api/declarative/declarative_manifest_unittest.cc
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/api_test_utils.h"
+#include "extensions/common/api/declarative/declarative_manifest_data.h"
+#include "extensions/common/manifest_test.h"
+
+namespace extensions {
+
+using api_test_utils::ParseDictionary;
+using DeclarativeManifestTest = ManifestTest;
+
+TEST_F(DeclarativeManifestTest, Valid) {
+ scoped_refptr<Extension> extension = LoadAndExpectSuccess("event_rules.json");
+ DeclarativeManifestData* manifest_data =
+ DeclarativeManifestData::Get(extension.get());
+ ASSERT_TRUE(manifest_data);
+ std::vector<linked_ptr<DeclarativeManifestData::Rule>>& rules =
+ manifest_data->RulesForEvent("foo");
+ EXPECT_EQ(1u, rules.size());
+ scoped_ptr<base::DictionaryValue> expected_rule = ParseDictionary(
+ "{"
+ " \"actions\": [{"
+ " \"instanceType\": \"action_type\""
+ " }],"
+ " \"conditions\" : [{"
+ " \"instanceType\" : \"condition_type\""
+ " }]"
+ "}");
+ EXPECT_TRUE(expected_rule->Equals(rules[0]->ToValue().get()));
+}
+
+TEST_F(DeclarativeManifestTest, Invalid) {
+ LoadAndExpectError("event_rules_invalid.json",
+ "'type' is required; rule failed to populate");
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698