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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "extensions/browser/api_test_utils.h"
6 #include "extensions/common/api/declarative/declarative_manifest_data.h"
7 #include "extensions/common/manifest_test.h"
8
9 namespace extensions {
10
11 using api_test_utils::ParseDictionary;
12 using DeclarativeManifestTest = ManifestTest;
13
14 TEST_F(DeclarativeManifestTest, Valid) {
15 scoped_refptr<Extension> extension = LoadAndExpectSuccess("event_rules.json");
16 DeclarativeManifestData* manifest_data =
17 DeclarativeManifestData::Get(extension.get());
18 ASSERT_TRUE(manifest_data);
19 std::vector<linked_ptr<DeclarativeManifestData::Rule>>& rules =
20 manifest_data->RulesForEvent("foo");
21 EXPECT_EQ(1u, rules.size());
22 scoped_ptr<base::DictionaryValue> expected_rule = ParseDictionary(
23 "{"
24 " \"actions\": [{"
25 " \"instanceType\": \"action_type\""
26 " }],"
27 " \"conditions\" : [{"
28 " \"instanceType\" : \"condition_type\""
29 " }]"
30 "}");
31 EXPECT_TRUE(expected_rule->Equals(rules[0]->ToValue().get()));
32 }
33
34 TEST_F(DeclarativeManifestTest, Invalid) {
35 LoadAndExpectError("event_rules_invalid.json",
36 "'type' is required; rule failed to populate");
37 }
38
39 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698