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

Unified Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yoz Created 7 years, 11 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: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
index 3d6895c559d3856079aab304eb38a3142c7e4d0d..7dbc6b285e7c75b871b695caaf7f0c67a48a0085 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
@@ -101,28 +101,19 @@ class WebRequestRulesRegistryTest : public testing::Test {
https_condition_url_filter.SetString(keys::kInstanceTypeKey,
keys::kRequestMatcherType);
- linked_ptr<json_schema_compiler::any::Any> condition1 = make_linked_ptr(
- new json_schema_compiler::any::Any);
- condition1->Init(http_condition_url_filter);
-
- linked_ptr<json_schema_compiler::any::Any> condition2 = make_linked_ptr(
- new json_schema_compiler::any::Any);
- condition2->Init(https_condition_url_filter);
-
DictionaryValue action_dict;
action_dict.SetString(keys::kInstanceTypeKey, keys::kCancelRequestType);
- linked_ptr<json_schema_compiler::any::Any> action1 = make_linked_ptr(
- new json_schema_compiler::any::Any);
- action1->Init(action_dict);
-
linked_ptr<RulesRegistry::Rule> rule =
make_linked_ptr(new RulesRegistry::Rule);
rule->id.reset(new std::string(kRuleId1));
rule->priority.reset(new int(100));
- rule->actions.push_back(action1);
- rule->conditions.push_back(condition1);
- rule->conditions.push_back(condition2);
+ rule->actions.push_back(
+ make_linked_ptr<base::Value>(action_dict.DeepCopy()));
+ rule->conditions.push_back(
+ linked_ptr<base::Value>(http_condition_url_filter.DeepCopy()));
+ rule->conditions.push_back(
+ linked_ptr<base::Value>(https_condition_url_filter.DeepCopy()));
return rule;
}
@@ -131,23 +122,17 @@ class WebRequestRulesRegistryTest : public testing::Test {
DictionaryValue condition_dict;
condition_dict.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
- linked_ptr<json_schema_compiler::any::Any> condition = make_linked_ptr(
- new json_schema_compiler::any::Any);
- condition->Init(condition_dict);
-
DictionaryValue action_dict;
action_dict.SetString(keys::kInstanceTypeKey, keys::kCancelRequestType);
- linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr(
- new json_schema_compiler::any::Any);
- action->Init(action_dict);
-
linked_ptr<RulesRegistry::Rule> rule =
make_linked_ptr(new RulesRegistry::Rule);
rule->id.reset(new std::string(kRuleId2));
rule->priority.reset(new int(100));
- rule->actions.push_back(action);
- rule->conditions.push_back(condition);
+ rule->actions.push_back(
+ linked_ptr<base::Value>(action_dict.DeepCopy()));
+ rule->conditions.push_back(
+ linked_ptr<base::Value>(condition_dict.DeepCopy()));
return rule;
}
@@ -156,52 +141,42 @@ class WebRequestRulesRegistryTest : public testing::Test {
DictionaryValue condition_dict;
condition_dict.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
- linked_ptr<json_schema_compiler::any::Any> condition = make_linked_ptr(
- new json_schema_compiler::any::Any);
- condition->Init(condition_dict);
-
DictionaryValue action_dict;
action_dict.SetString(keys::kInstanceTypeKey, keys::kRedirectRequestType);
action_dict.SetString(keys::kRedirectUrlKey, destination);
- linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr(
- new json_schema_compiler::any::Any);
- action->Init(action_dict);
-
linked_ptr<RulesRegistry::Rule> rule =
make_linked_ptr(new RulesRegistry::Rule);
rule->id.reset(new std::string(kRuleId3));
rule->priority.reset(new int(100));
- rule->actions.push_back(action);
- rule->conditions.push_back(condition);
+ rule->actions.push_back(
+ linked_ptr<base::Value>(action_dict.DeepCopy()));
+ rule->conditions.push_back(
+ linked_ptr<base::Value>(condition_dict.DeepCopy()));
return rule;
}
// Create a rule to ignore all other rules for a destination that
// contains index.html.
linked_ptr<RulesRegistry::Rule> CreateIgnoreRule() {
- linked_ptr<json_schema_compiler::any::Any> condition = make_linked_ptr(
- new json_schema_compiler::any::Any);
DictionaryValue condition_dict;
DictionaryValue* http_condition_dict = new DictionaryValue();
http_condition_dict->SetString(keys2::kPathContainsKey, "index.html");
condition_dict.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
condition_dict.Set(keys::kUrlKey, http_condition_dict);
- condition->Init(condition_dict);
DictionaryValue action_dict;
action_dict.SetString(keys::kInstanceTypeKey, keys::kIgnoreRulesType);
action_dict.SetInteger(keys::kLowerPriorityThanKey, 150);
- linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr(
- new json_schema_compiler::any::Any);
- action->Init(action_dict);
linked_ptr<RulesRegistry::Rule> rule =
make_linked_ptr(new RulesRegistry::Rule);
rule->id.reset(new std::string(kRuleId4));
rule->priority.reset(new int(200));
- rule->actions.push_back(action);
- rule->conditions.push_back(condition);
+ rule->actions.push_back(
+ linked_ptr<base::Value>(action_dict.DeepCopy()));
+ rule->conditions.push_back(
+ linked_ptr<base::Value>(condition_dict.DeepCopy()));
return rule;
}

Powered by Google App Engine
This is Rietveld 408576698